Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(212)

Side by Side Diff: cc/layers/picture_layer.h

Issue 2141233002: cc: Clean up RecordingSource API (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address comments Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 13
14 namespace {
vmpstr 2016/07/20 22:18:10 I don't think anonymous namespace in a header file
Menglin 2016/07/20 22:39:31 OK.
15
16 #ifdef NDEBUG
17 const bool kDefaultClearCanvasSetting = false;
18 #else
19 const bool kDefaultClearCanvasSetting = true;
20 #endif
21
22 } // namespace
23
14 namespace cc { 24 namespace cc {
15 25
16 class ContentLayerClient; 26 class ContentLayerClient;
17 class RecordingSource; 27 class DisplayItemList;
28 class RasterSource;
18 class ResourceUpdateQueue; 29 class ResourceUpdateQueue;
19 30
31 struct PictureLayerData {
vmpstr 2016/07/20 22:18:10 These should probably move to separate files.
Menglin 2016/07/20 22:39:31 Some header file just for these two structs?
vmpstr 2016/07/20 23:55:55 Or even a header per... The rule is usually one cl
32 PictureLayerData();
33 ~PictureLayerData();
34
35 gfx::Size size;
vmpstr 2016/07/20 22:18:10 Can you rename this to something more meaningful?
Menglin 2016/07/20 22:39:31 Looking at code here, I think it's the recorded re
vmpstr 2016/07/20 23:55:54 Yeah I think that's a good idea.
36 int slow_down_raster_scale_factor_for_debug = 0;
37 bool generate_discardable_images_metadata = false;
38 bool requires_clear = false;
39 bool is_solid_color = false;
40 bool clear_canvas_with_debug_color = kDefaultClearCanvasSetting;
41 SkColor solid_color = SK_ColorTRANSPARENT;
42 SkColor background_color = SK_ColorTRANSPARENT;
43 };
44
45 // Encapsulates all data received from the ContentLayerClient.
46 struct ContentLayerClientData {
47 ContentLayerClientData();
48 ContentLayerClientData(const ContentLayerClientData&);
49 ~ContentLayerClientData();
50
51 gfx::Rect recorded_viewport;
52 scoped_refptr<DisplayItemList> display_list;
53 size_t painter_reported_memory_usage = 0;
54 };
55
20 class CC_EXPORT PictureLayer : public Layer { 56 class CC_EXPORT PictureLayer : public Layer {
21 public: 57 public:
58 // TODO(schenney) Remove RECORD_WITH_SK_NULL_CANVAS when we no longer
59 // support a non-Slimming Paint path.
60 enum RecordingMode {
61 RECORD_NORMALLY,
62 RECORD_WITH_SK_NULL_CANVAS,
63 RECORD_WITH_PAINTING_DISABLED,
64 RECORD_WITH_CACHING_DISABLED,
65 RECORD_WITH_CONSTRUCTION_DISABLED,
66 RECORD_WITH_SUBSEQUENCE_CACHING_DISABLED,
67 RECORDING_MODE_COUNT, // Must be the last entry.
68 };
69
22 static scoped_refptr<PictureLayer> Create(ContentLayerClient* client); 70 static scoped_refptr<PictureLayer> Create(ContentLayerClient* client);
23 71
24 void ClearClient(); 72 void ClearClient();
25 73
26 void SetNearestNeighbor(bool nearest_neighbor); 74 void SetNearestNeighbor(bool nearest_neighbor);
27 75
28 // Layer interface. 76 // Layer interface.
29 std::unique_ptr<LayerImpl> CreateLayerImpl(LayerTreeImpl* tree_impl) override; 77 std::unique_ptr<LayerImpl> CreateLayerImpl(LayerTreeImpl* tree_impl) override;
30 void SetLayerTreeHost(LayerTreeHost* host) override; 78 void SetLayerTreeHost(LayerTreeHost* host) override;
31 void PushPropertiesTo(LayerImpl* layer) override; 79 void PushPropertiesTo(LayerImpl* layer) override;
32 void SetNeedsDisplayRect(const gfx::Rect& layer_rect) override; 80 void SetNeedsDisplayRect(const gfx::Rect& layer_rect) override;
33 bool Update() override; 81 bool Update() override;
34 void SetIsMask(bool is_mask) override; 82 void SetIsMask(bool is_mask) override;
35 sk_sp<SkPicture> GetPicture() const override; 83 sk_sp<SkPicture> GetPicture() const override;
36 bool IsSuitableForGpuRasterization() const override; 84 bool IsSuitableForGpuRasterization() const override;
37 85
38 void RunMicroBenchmark(MicroBenchmark* benchmark) override; 86 void RunMicroBenchmark(MicroBenchmark* benchmark) override;
39 87
40 ContentLayerClient* client() { return inputs_.client; } 88 ContentLayerClient* client() { return inputs_.client; }
41 89
42 RecordingSource* GetRecordingSourceForTesting() { 90 bool UpdateAndExpandInvalidation(
43 return recording_source_.get(); 91 Region* invalidation,
44 } 92 const gfx::Size& layer_size,
93 PictureLayer::RecordingMode recording_mode,
94 PictureLayerData* layer_data,
95 ContentLayerClientData* client_data,
96 InvalidationRegion* invalidation_state) const;
97
98 void ResetLayerAndClientData();
99 void SetGenerateDiscardableImagesMetadata(bool generate_metadata);
100 void SetBackgroundColorSimple(SkColor background_color);
101 void SetRequiresClear(bool requires_clear);
102 void SetNeedsDisplayRectSimple(const gfx::Rect& layer_rect);
103 gfx::Size GetSizeInLayerData() const;
104 const DisplayItemList* GetDisplayItemList();
105
106 // These functions are virtual for testing.
107 virtual scoped_refptr<RasterSource> CreateRasterSource(
108 const PictureLayerData& layer_data,
109 const ContentLayerClientData& client_data,
110 bool can_use_lcd_text) const;
45 111
46 protected: 112 protected:
47 explicit PictureLayer(ContentLayerClient* client); 113 explicit PictureLayer(ContentLayerClient* client);
48 // Allow tests to inject a recording source. 114 // Tests will pass in data instead of a RecordingSource.
49 PictureLayer(ContentLayerClient* client, 115 PictureLayer(ContentLayerClient* client,
50 std::unique_ptr<RecordingSource> source); 116 const PictureLayerData& layer_data,
117 const ContentLayerClientData& client_data);
51 ~PictureLayer() override; 118 ~PictureLayer() override;
52 119
53 bool HasDrawableContent() const override; 120 bool HasDrawableContent() const override;
54 void SetTypeForProtoSerialization(proto::LayerNode* proto) const override; 121 void SetTypeForProtoSerialization(proto::LayerNode* proto) const override;
55 void LayerSpecificPropertiesToProto(proto::LayerProperties* proto) override; 122 void LayerSpecificPropertiesToProto(proto::LayerProperties* proto) override;
56 void FromLayerSpecificPropertiesProto( 123 void FromLayerSpecificPropertiesProto(
57 const proto::LayerProperties& proto) override; 124 const proto::LayerProperties& proto) override;
58 125
59 bool is_mask() const { return is_mask_; } 126 bool is_mask() const { return is_mask_; }
60 127
128 PictureLayerData layer_data_;
129 ContentLayerClientData client_data_;
130
61 private: 131 private:
62 friend class TestSerializationPictureLayer; 132 friend class TestSerializationPictureLayer;
63 133
64 void DropRecordingSourceContentIfInvalid(); 134 void DropRecordingSourceContentIfInvalid();
65 135
66 std::unique_ptr<RecordingSource> recording_source_; 136 void UpdateInvalidationForNewViewport(const gfx::Rect& old_recorded_viewport,
137 const gfx::Rect& new_recorded_viewport,
138 Region* invalidation) const;
139
140 void FinishDisplayItemListUpdate(PictureLayerData* layer_data,
141 ContentLayerClientData* client_data) const;
142
143 void DetermineIfSolidColor(PictureLayerData* layer_data,
144 ContentLayerClientData* client_data) const;
145
67 devtools_instrumentation:: 146 devtools_instrumentation::
68 ScopedLayerObjectTracker instrumentation_object_tracker_; 147 ScopedLayerObjectTracker instrumentation_object_tracker_;
69 148
70 Region last_updated_invalidation_; 149 Region last_updated_invalidation_;
71 150
72 int update_source_frame_number_; 151 int update_source_frame_number_;
73 bool is_mask_; 152 bool is_mask_;
74 153
75 // Encapsulates all data, callbacks or interfaces received from the embedder. 154 // Encapsulates all data, callbacks or interfaces received from the embedder.
76 struct Inputs { 155 struct Inputs {
77 ContentLayerClient* client = nullptr; 156 ContentLayerClient* client = nullptr;
78 bool nearest_neighbor = false; 157 bool nearest_neighbor = false;
79 }; 158 };
80 159
81 Inputs inputs_; 160 Inputs inputs_;
82 161
162 InvalidationRegion invalidation_;
163
83 DISALLOW_COPY_AND_ASSIGN(PictureLayer); 164 DISALLOW_COPY_AND_ASSIGN(PictureLayer);
84 }; 165 };
85 166
86 } // namespace cc 167 } // namespace cc
87 168
88 #endif // CC_LAYERS_PICTURE_LAYER_H_ 169 #endif // CC_LAYERS_PICTURE_LAYER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698