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

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

Issue 2688673003: cc: Distinguish single texture mask from normal masks (Closed)
Patch Set: Created 3 years, 10 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 #include "cc/layers/picture_layer.h" 5 #include "cc/layers/picture_layer.h"
6 6
7 #include "base/auto_reset.h" 7 #include "base/auto_reset.h"
8 #include "base/trace_event/trace_event.h" 8 #include "base/trace_event/trace_event.h"
9 #include "cc/layers/content_layer_client.h" 9 #include "cc/layers/content_layer_client.h"
10 #include "cc/layers/picture_layer_impl.h" 10 #include "cc/layers/picture_layer_impl.h"
11 #include "cc/paint/paint_record.h" 11 #include "cc/paint/paint_record.h"
12 #include "cc/playback/recording_source.h" 12 #include "cc/playback/recording_source.h"
13 #include "cc/trees/layer_tree_host.h" 13 #include "cc/trees/layer_tree_host.h"
14 #include "cc/trees/layer_tree_impl.h" 14 #include "cc/trees/layer_tree_impl.h"
15 #include "ui/gfx/geometry/rect_conversions.h" 15 #include "ui/gfx/geometry/rect_conversions.h"
16 16
17 namespace cc { 17 namespace cc {
18 18
19 PictureLayer::PictureLayerInputs::PictureLayerInputs() = default; 19 PictureLayer::PictureLayerInputs::PictureLayerInputs() = default;
20 20
21 PictureLayer::PictureLayerInputs::~PictureLayerInputs() = default; 21 PictureLayer::PictureLayerInputs::~PictureLayerInputs() = default;
22 22
23 scoped_refptr<PictureLayer> PictureLayer::Create(ContentLayerClient* client) { 23 scoped_refptr<PictureLayer> PictureLayer::Create(ContentLayerClient* client) {
24 return make_scoped_refptr(new PictureLayer(client)); 24 return make_scoped_refptr(new PictureLayer(client));
25 } 25 }
26 26
27 PictureLayer::PictureLayer(ContentLayerClient* client) 27 PictureLayer::PictureLayer(ContentLayerClient* client)
28 : instrumentation_object_tracker_(id()), 28 : instrumentation_object_tracker_(id()),
29 update_source_frame_number_(-1), 29 update_source_frame_number_(-1),
30 is_mask_(false) { 30 is_mask_(false),
31 is_single_texture_mask_(false) {
31 picture_layer_inputs_.client = client; 32 picture_layer_inputs_.client = client;
32 } 33 }
33 34
34 PictureLayer::PictureLayer(ContentLayerClient* client, 35 PictureLayer::PictureLayer(ContentLayerClient* client,
35 std::unique_ptr<RecordingSource> source) 36 std::unique_ptr<RecordingSource> source)
36 : PictureLayer(client) { 37 : PictureLayer(client) {
37 recording_source_ = std::move(source); 38 recording_source_ = std::move(source);
38 } 39 }
39 40
40 PictureLayer::~PictureLayer() { 41 PictureLayer::~PictureLayer() {
41 } 42 }
42 43
43 std::unique_ptr<LayerImpl> PictureLayer::CreateLayerImpl( 44 std::unique_ptr<LayerImpl> PictureLayer::CreateLayerImpl(
44 LayerTreeImpl* tree_impl) { 45 LayerTreeImpl* tree_impl) {
45 return PictureLayerImpl::Create(tree_impl, id(), is_mask_); 46 return PictureLayerImpl::Create(tree_impl, id(), is_mask_,
47 is_single_texture_mask_);
46 } 48 }
47 49
48 void PictureLayer::PushPropertiesTo(LayerImpl* base_layer) { 50 void PictureLayer::PushPropertiesTo(LayerImpl* base_layer) {
49 Layer::PushPropertiesTo(base_layer); 51 Layer::PushPropertiesTo(base_layer);
50 TRACE_EVENT0("cc", "PictureLayer::PushPropertiesTo"); 52 TRACE_EVENT0("cc", "PictureLayer::PushPropertiesTo");
51 PictureLayerImpl* layer_impl = static_cast<PictureLayerImpl*>(base_layer); 53 PictureLayerImpl* layer_impl = static_cast<PictureLayerImpl*>(base_layer);
52 // TODO(danakj): Make is_mask_ a constructor parameter for PictureLayer. 54 // TODO(danakj): Make is_mask_ a constructor parameter for PictureLayer.
53 DCHECK_EQ(layer_impl->is_mask(), is_mask_); 55 DCHECK_EQ(layer_impl->is_mask(), is_mask_);
56 DCHECK_EQ(layer_impl->is_single_texture_mask(), is_single_texture_mask_);
54 DropRecordingSourceContentIfInvalid(); 57 DropRecordingSourceContentIfInvalid();
55 58
56 layer_impl->SetNearestNeighbor(picture_layer_inputs_.nearest_neighbor); 59 layer_impl->SetNearestNeighbor(picture_layer_inputs_.nearest_neighbor);
57 60
58 // Preserve lcd text settings from the current raster source. 61 // Preserve lcd text settings from the current raster source.
59 bool can_use_lcd_text = layer_impl->RasterSourceUsesLCDText(); 62 bool can_use_lcd_text = layer_impl->RasterSourceUsesLCDText();
60 scoped_refptr<RasterSource> raster_source = 63 scoped_refptr<RasterSource> raster_source =
61 recording_source_->CreateRasterSource(can_use_lcd_text); 64 recording_source_->CreateRasterSource(can_use_lcd_text);
62 layer_impl->set_gpu_raster_max_texture_size( 65 layer_impl->set_gpu_raster_max_texture_size(
63 layer_tree_host()->device_viewport_size()); 66 layer_tree_host()->device_viewport_size());
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 last_updated_invalidation_.Clear(); 137 last_updated_invalidation_.Clear();
135 } 138 }
136 139
137 return updated; 140 return updated;
138 } 141 }
139 142
140 void PictureLayer::SetIsMask(bool is_mask) { 143 void PictureLayer::SetIsMask(bool is_mask) {
141 is_mask_ = is_mask; 144 is_mask_ = is_mask;
142 } 145 }
143 146
147 void PictureLayer::SetIsSingleTextureMask(bool is_single_texture_mask) {
148 is_single_texture_mask_ = is_single_texture_mask;
149 }
150
144 sk_sp<SkPicture> PictureLayer::GetPicture() const { 151 sk_sp<SkPicture> PictureLayer::GetPicture() const {
145 // We could either flatten the RecordingSource into a single SkPicture, or 152 // We could either flatten the RecordingSource into a single SkPicture, or
146 // paint a fresh one depending on what we intend to do with it. For now we 153 // paint a fresh one depending on what we intend to do with it. For now we
147 // just paint a fresh one to get consistent results. 154 // just paint a fresh one to get consistent results.
148 if (!DrawsContent()) 155 if (!DrawsContent())
149 return nullptr; 156 return nullptr;
150 157
151 gfx::Size layer_size = bounds(); 158 gfx::Size layer_size = bounds();
152 RecordingSource recording_source; 159 RecordingSource recording_source;
153 Region recording_invalidation; 160 Region recording_invalidation;
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
226 picture_layer_inputs_.display_list = nullptr; 233 picture_layer_inputs_.display_list = nullptr;
227 picture_layer_inputs_.painter_reported_memory_usage = 0; 234 picture_layer_inputs_.painter_reported_memory_usage = 0;
228 } 235 }
229 } 236 }
230 237
231 const DisplayItemList* PictureLayer::GetDisplayItemList() { 238 const DisplayItemList* PictureLayer::GetDisplayItemList() {
232 return picture_layer_inputs_.display_list.get(); 239 return picture_layer_inputs_.display_list.get();
233 } 240 }
234 241
235 } // namespace cc 242 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698