1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99
|
// Copyright 2012 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_LAYERS_PICTURE_LAYER_H_
#define CC_LAYERS_PICTURE_LAYER_H_
#include <memory>
#include <vector>
#include "base/memory/raw_ptr.h"
#include "cc/base/devtools_instrumentation.h"
#include "cc/base/invalidation_region.h"
#include "cc/benchmarks/micro_benchmark_controller.h"
#include "cc/layers/layer.h"
#include "cc/layers/recording_source.h"
namespace cc {
class ContentLayerClient;
class DisplayItemList;
class RasterSource;
class CC_EXPORT PictureLayer : public Layer {
public:
static scoped_refptr<PictureLayer> Create(ContentLayerClient* client);
PictureLayer(const PictureLayer&) = delete;
PictureLayer& operator=(const PictureLayer&) = delete;
void ClearClient();
void SetIsBackdropFilterMask(bool is_backdrop_filter_mask);
bool is_backdrop_filter_mask() const { return is_backdrop_filter_mask_; }
// Layer interface.
std::unique_ptr<LayerImpl> CreateLayerImpl(
LayerTreeImpl* tree_impl) const override;
void SetLayerTreeHost(LayerTreeHost* host) override;
void SetNeedsDisplayRect(const gfx::Rect& layer_rect) override;
bool RequiresSetNeedsDisplayOnHdrHeadroomChange() const override;
sk_sp<const SkPicture> GetPicture() const override;
bool Update() override;
void RunMicroBenchmark(MicroBenchmark* benchmark) override;
void CaptureContent(const gfx::Rect& rect,
std::vector<NodeInfo>* content) const override;
ContentLayerClient* client() { return client_; }
// Forces an update of recording source even without invalidation.
void SetForceUpdateRecordingSource();
RecordingSource& GetRecordingSourceForTesting() {
return recording_source_.Write(*this);
}
const RecordingSource& GetRecordingSourceForTesting() const {
return recording_source_.Read(*this);
}
protected:
explicit PictureLayer(ContentLayerClient* client);
~PictureLayer() override;
void PushDirtyPropertiesTo(
LayerImpl* layer,
uint8_t dirty_flag,
const CommitState& commit_state,
const ThreadUnsafeCommitState& unsafe_state) override;
bool HasDrawableContent() const override;
// Can be overridden in tests to customize RasterSource.
virtual scoped_refptr<RasterSource> CreateRasterSource() const;
private:
friend class TestSerializationPictureLayer;
// Called on impl thread
void DropRecordingSourceContentIfInvalid(int source_frame_number);
const DisplayItemList* GetDisplayItemList() const;
// These fields are not protected because they are only modified during
// LayerTreeHost::PaintContent().
raw_ptr<ContentLayerClient, DanglingUntriaged> client_ = nullptr;
bool is_backdrop_filter_mask_ = false;
ProtectedSequenceWritable<RecordingSource> recording_source_;
ProtectedSequenceForbidden<devtools_instrumentation::ScopedLayerObjectTracker>
instrumentation_object_tracker_;
ProtectedSequenceWritable<Region> last_updated_invalidation_;
ProtectedSequenceReadable<int> update_source_frame_number_;
};
} // namespace cc
#endif // CC_LAYERS_PICTURE_LAYER_H_
|