Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CC_LAYERS_PICTURE_LAYER_H_ | 5 #ifndef CC_LAYERS_PICTURE_LAYER_H_ |
| 6 #define CC_LAYERS_PICTURE_LAYER_H_ | 6 #define CC_LAYERS_PICTURE_LAYER_H_ |
| 7 | 7 |
| 8 #include "base/macros.h" | 8 #include "base/macros.h" |
| 9 #include "cc/base/invalidation_region.h" | 9 #include "cc/base/invalidation_region.h" |
| 10 #include "cc/debug/devtools_instrumentation.h" | 10 #include "cc/debug/devtools_instrumentation.h" |
| 11 #include "cc/debug/micro_benchmark_controller.h" | 11 #include "cc/debug/micro_benchmark_controller.h" |
| 12 #include "cc/layers/layer.h" | 12 #include "cc/layers/layer.h" |
| 13 #include "cc/playback/recording_source.h" | |
| 13 | 14 |
| 14 namespace cc { | 15 namespace cc { |
| 15 | 16 |
| 16 class ContentLayerClient; | 17 class ContentLayerClient; |
| 17 class RecordingSource; | 18 class RecordingSource; |
| 18 class ResourceUpdateQueue; | 19 class ResourceUpdateQueue; |
| 19 | 20 |
| 20 class CC_EXPORT PictureLayer : public Layer { | 21 class CC_EXPORT PictureLayer : public Layer { |
| 21 public: | 22 public: |
| 22 static scoped_refptr<PictureLayer> Create(ContentLayerClient* client); | 23 static scoped_refptr<PictureLayer> Create(ContentLayerClient* client); |
| 23 | 24 |
| 24 void ClearClient(); | 25 void ClearClient(); |
| 25 | 26 |
| 26 void SetNearestNeighbor(bool nearest_neighbor); | 27 void SetNearestNeighbor(bool nearest_neighbor); |
| 27 | 28 |
| 28 // Layer interface. | 29 // Layer interface. |
| 29 std::unique_ptr<LayerImpl> CreateLayerImpl(LayerTreeImpl* tree_impl) override; | 30 std::unique_ptr<LayerImpl> CreateLayerImpl(LayerTreeImpl* tree_impl) override; |
| 30 void SetLayerTreeHost(LayerTreeHost* host) override; | 31 void SetLayerTreeHost(LayerTreeHost* host) override; |
| 31 void PushPropertiesTo(LayerImpl* layer) override; | 32 void PushPropertiesTo(LayerImpl* layer) override; |
| 32 void SetNeedsDisplayRect(const gfx::Rect& layer_rect) override; | 33 void SetNeedsDisplayRect(const gfx::Rect& layer_rect) override; |
| 33 bool Update() override; | 34 bool Update() override; |
| 34 void SetIsMask(bool is_mask) override; | 35 void SetIsMask(bool is_mask) override; |
| 35 sk_sp<SkPicture> GetPicture() const override; | 36 sk_sp<SkPicture> GetPicture() const override; |
| 36 bool IsSuitableForGpuRasterization() const override; | 37 bool IsSuitableForGpuRasterization() const override; |
| 37 | 38 |
| 38 void RunMicroBenchmark(MicroBenchmark* benchmark) override; | 39 void RunMicroBenchmark(MicroBenchmark* benchmark) override; |
| 39 | 40 |
| 40 ContentLayerClient* client() { return inputs_.client; } | 41 ContentLayerClient* client() { return inputs_.client; } |
| 41 | 42 |
| 42 RecordingSource* GetRecordingSourceForTesting() { | 43 bool UpdateAndExpandInvalidation( |
| 43 return recording_source_.get(); | 44 Region* invalidation, |
| 44 } | 45 const gfx::Size& layer_size, |
| 46 RecordingSource::RecordingMode recording_mode, | |
| 47 PictureLayerData* pl_data, | |
|
vmpstr
2016/07/19 23:43:22
layer_data or picture_layer_data (here and everywh
Menglin
2016/07/20 21:25:22
Done. I'm very bad at names...
| |
| 48 ContentLayerClientData* clc_data, | |
|
vmpstr
2016/07/19 23:43:22
client_data (here and everywhere)
Menglin
2016/07/20 21:25:22
Done.
| |
| 49 InvalidationRegion* invalidation_state) const; | |
| 50 | |
| 51 void SetEmptyBounds(); | |
|
vmpstr
2016/07/19 23:43:22
This is confusing since cc::Layer has a SetBounds
Menglin
2016/07/20 21:25:22
change it to ResetLayerAndClientData
| |
| 52 void SetSlowdownRasterScaleFactor(int factor); | |
| 53 void SetGenerateDiscardableImagesMetadata(bool generate_metadata); | |
| 54 void SetBackgroundColorSimple(SkColor background_color); | |
| 55 void SetRequiresClear(bool requires_clear); | |
| 56 void SetNeedsDisplayRectSimple(const gfx::Rect& layer_rect); | |
| 57 gfx::Size GetSize() const; | |
|
vmpstr
2016/07/19 23:43:22
Some of these concept become ambiguous/weird when
Menglin
2016/07/20 21:25:22
removed Clear. change GetSize to GetSizeInLayerDat
| |
| 58 const DisplayItemList* GetDisplayItemList(); | |
| 45 | 59 |
| 46 protected: | 60 protected: |
| 47 explicit PictureLayer(ContentLayerClient* client); | 61 explicit PictureLayer(ContentLayerClient* client); |
| 48 // Allow tests to inject a recording source. | 62 // Tests will pass in data instead of a RecordingSource. |
| 49 PictureLayer(ContentLayerClient* client, | 63 PictureLayer(ContentLayerClient* client, |
| 50 std::unique_ptr<RecordingSource> source); | 64 const PictureLayerData& pl_data, |
| 65 const ContentLayerClientData& clc_data); | |
| 51 ~PictureLayer() override; | 66 ~PictureLayer() override; |
| 52 | 67 |
| 53 bool HasDrawableContent() const override; | 68 bool HasDrawableContent() const override; |
| 54 void SetTypeForProtoSerialization(proto::LayerNode* proto) const override; | 69 void SetTypeForProtoSerialization(proto::LayerNode* proto) const override; |
| 55 void LayerSpecificPropertiesToProto(proto::LayerProperties* proto) override; | 70 void LayerSpecificPropertiesToProto(proto::LayerProperties* proto) override; |
| 56 void FromLayerSpecificPropertiesProto( | 71 void FromLayerSpecificPropertiesProto( |
| 57 const proto::LayerProperties& proto) override; | 72 const proto::LayerProperties& proto) override; |
| 58 | 73 |
| 74 void Clear(); | |
| 75 | |
| 59 bool is_mask() const { return is_mask_; } | 76 bool is_mask() const { return is_mask_; } |
| 60 | 77 |
| 78 PictureLayerData pl_data_; | |
| 79 ContentLayerClientData clc_data_; | |
| 80 | |
| 61 private: | 81 private: |
| 62 friend class TestSerializationPictureLayer; | 82 friend class TestSerializationPictureLayer; |
| 63 | 83 |
| 64 void DropRecordingSourceContentIfInvalid(); | 84 void DropRecordingSourceContentIfInvalid(); |
| 65 | 85 |
| 66 std::unique_ptr<RecordingSource> recording_source_; | 86 void UpdateInvalidationForNewViewport(const gfx::Rect& old_recorded_viewport, |
| 87 const gfx::Rect& new_recorded_viewport, | |
| 88 Region* invalidation) const; | |
| 89 | |
| 90 void FinishDisplayItemListUpdate(PictureLayerData* pl_data, | |
| 91 ContentLayerClientData* clc_data) const; | |
| 92 | |
| 93 void DetermineIfSolidColor(PictureLayerData* pl_data, | |
| 94 ContentLayerClientData* clc_data) const; | |
| 95 | |
| 67 devtools_instrumentation:: | 96 devtools_instrumentation:: |
| 68 ScopedLayerObjectTracker instrumentation_object_tracker_; | 97 ScopedLayerObjectTracker instrumentation_object_tracker_; |
| 69 | 98 |
| 70 Region last_updated_invalidation_; | 99 Region last_updated_invalidation_; |
| 71 | 100 |
| 72 int update_source_frame_number_; | 101 int update_source_frame_number_; |
| 73 bool is_mask_; | 102 bool is_mask_; |
| 74 | 103 |
| 75 // Encapsulates all data, callbacks or interfaces received from the embedder. | 104 // Encapsulates all data, callbacks or interfaces received from the embedder. |
| 76 struct Inputs { | 105 struct Inputs { |
| 77 ContentLayerClient* client = nullptr; | 106 ContentLayerClient* client = nullptr; |
| 78 bool nearest_neighbor = false; | 107 bool nearest_neighbor = false; |
| 79 }; | 108 }; |
| 80 | 109 |
| 81 Inputs inputs_; | 110 Inputs inputs_; |
| 82 | 111 |
| 112 InvalidationRegion invalidation_; | |
| 113 | |
| 83 DISALLOW_COPY_AND_ASSIGN(PictureLayer); | 114 DISALLOW_COPY_AND_ASSIGN(PictureLayer); |
| 84 }; | 115 }; |
| 85 | 116 |
| 86 } // namespace cc | 117 } // namespace cc |
| 87 | 118 |
| 88 #endif // CC_LAYERS_PICTURE_LAYER_H_ | 119 #endif // CC_LAYERS_PICTURE_LAYER_H_ |
| OLD | NEW |