// 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 #include #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 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 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 GetPicture() const override; bool Update() override; void RunMicroBenchmark(MicroBenchmark* benchmark) override; void CaptureContent(const gfx::Rect& rect, std::vector* 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 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 client_ = nullptr; bool is_backdrop_filter_mask_ = false; ProtectedSequenceWritable recording_source_; ProtectedSequenceForbidden instrumentation_object_tracker_; ProtectedSequenceWritable last_updated_invalidation_; ProtectedSequenceReadable update_source_frame_number_; }; } // namespace cc #endif // CC_LAYERS_PICTURE_LAYER_H_