[go: nahoru, domu]

blob: 18c802d8b75d5af772205fd7498b7df0af220bb3 [file] [log] [blame]
// Copyright 2017 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CC_PAINT_DECODE_STASHING_IMAGE_PROVIDER_H_
#define CC_PAINT_DECODE_STASHING_IMAGE_PROVIDER_H_
#include "base/memory/raw_ptr.h"
#include "cc/paint/image_provider.h"
#include "cc/paint/paint_export.h"
#include "third_party/abseil-cpp/absl/container/inlined_vector.h"
namespace cc {
// An ImageProvider that passes decode requests through to the
// |source_provider| but keeps the decode cached throughtout its lifetime,
// instead of passing the ref to the caller.
class CC_PAINT_EXPORT DecodeStashingImageProvider : public ImageProvider {
public:
// |source_provider| must outlive this class.
explicit DecodeStashingImageProvider(ImageProvider* source_provider);
DecodeStashingImageProvider(const DecodeStashingImageProvider&) = delete;
~DecodeStashingImageProvider() override;
DecodeStashingImageProvider& operator=(const DecodeStashingImageProvider&) =
delete;
// ImageProvider implementation.
ImageProvider::ScopedResult GetRasterContent(
const DrawImage& draw_image) override;
// Releases all stashed images. The caller must ensure that it is safe to
// unlock any images acquired before this.
void Reset();
private:
raw_ptr<ImageProvider> source_provider_;
absl::InlinedVector<ScopedResult, 1> decoded_images_;
};
} // namespace cc
#endif // CC_PAINT_DECODE_STASHING_IMAGE_PROVIDER_H_