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

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

Issue 181063022: cc: Trigger GPU rasterization based on a per-layer hint (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 9 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 | Annotate | Revision Log
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 "cc/layers/content_layer_client.h" 7 #include "cc/layers/content_layer_client.h"
8 #include "cc/layers/picture_layer_impl.h" 8 #include "cc/layers/picture_layer_impl.h"
9 #include "cc/trees/layer_tree_impl.h" 9 #include "cc/trees/layer_tree_impl.h"
10 #include "ui/gfx/rect_conversions.h" 10 #include "ui/gfx/rect_conversions.h"
11 11
12 namespace cc { 12 namespace cc {
13 13
14 scoped_refptr<PictureLayer> PictureLayer::Create(ContentLayerClient* client) { 14 scoped_refptr<PictureLayer> PictureLayer::Create(ContentLayerClient* client) {
15 return make_scoped_refptr(new PictureLayer(client)); 15 return make_scoped_refptr(new PictureLayer(client));
16 } 16 }
17 17
18 PictureLayer::PictureLayer(ContentLayerClient* client) 18 PictureLayer::PictureLayer(ContentLayerClient* client)
19 : client_(client), 19 : client_(client),
20 pile_(make_scoped_refptr(new PicturePile())), 20 pile_(make_scoped_refptr(new PicturePile())),
21 instrumentation_object_tracker_(id()), 21 instrumentation_object_tracker_(id()),
22 is_mask_(false), 22 is_mask_(false),
23 has_gpu_rasterization_hint_(false),
23 update_source_frame_number_(-1) { 24 update_source_frame_number_(-1) {
24 } 25 }
25 26
26 PictureLayer::~PictureLayer() { 27 PictureLayer::~PictureLayer() {
27 } 28 }
28 29
29 bool PictureLayer::DrawsContent() const { 30 bool PictureLayer::DrawsContent() const {
30 return Layer::DrawsContent() && client_; 31 return Layer::DrawsContent() && client_;
31 } 32 }
32 33
(...skipping 11 matching lines...) Expand all
44 // may disagree and either one could have been pushed to layer_impl. 45 // may disagree and either one could have been pushed to layer_impl.
45 pile_->Resize(gfx::Size()); 46 pile_->Resize(gfx::Size());
46 pile_->UpdateRecordedRegion(); 47 pile_->UpdateRecordedRegion();
47 } else if (update_source_frame_number_ == 48 } else if (update_source_frame_number_ ==
48 layer_tree_host()->source_frame_number()) { 49 layer_tree_host()->source_frame_number()) {
49 // If update called, then pile size must match bounds pushed to impl layer. 50 // If update called, then pile size must match bounds pushed to impl layer.
50 DCHECK_EQ(layer_impl->bounds().ToString(), pile_->size().ToString()); 51 DCHECK_EQ(layer_impl->bounds().ToString(), pile_->size().ToString());
51 } 52 }
52 53
53 layer_impl->SetIsMask(is_mask_); 54 layer_impl->SetIsMask(is_mask_);
55 layer_impl->SetHasGpuRasterizationHint(has_gpu_rasterization_hint_);
56
54 // Unlike other properties, invalidation must always be set on layer_impl. 57 // Unlike other properties, invalidation must always be set on layer_impl.
55 // See PictureLayerImpl::PushPropertiesTo for more details. 58 // See PictureLayerImpl::PushPropertiesTo for more details.
56 layer_impl->invalidation_.Clear(); 59 layer_impl->invalidation_.Clear();
57 layer_impl->invalidation_.Swap(&pile_invalidation_); 60 layer_impl->invalidation_.Swap(&pile_invalidation_);
58 layer_impl->pile_ = PicturePileImpl::CreateFromOther(pile_.get()); 61 layer_impl->pile_ = PicturePileImpl::CreateFromOther(pile_.get());
59 } 62 }
60 63
61 void PictureLayer::SetLayerTreeHost(LayerTreeHost* host) { 64 void PictureLayer::SetLayerTreeHost(LayerTreeHost* host) {
62 Layer::SetLayerTreeHost(host); 65 Layer::SetLayerTreeHost(host);
63 if (host) { 66 if (host) {
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 pile_invalidation_.Clear(); 130 pile_invalidation_.Clear();
128 } 131 }
129 132
130 return updated; 133 return updated;
131 } 134 }
132 135
133 void PictureLayer::SetIsMask(bool is_mask) { 136 void PictureLayer::SetIsMask(bool is_mask) {
134 is_mask_ = is_mask; 137 is_mask_ = is_mask;
135 } 138 }
136 139
140 void PictureLayer::SetHasGpuRasterizationHint(bool has_hint) {
141 DCHECK(IsPropertyChangeAllowed());
142 if (has_gpu_rasterization_hint_ == has_hint)
143 return;
144 has_gpu_rasterization_hint_ = has_hint;
145 SetNeedsCommit();
146 }
147
137 bool PictureLayer::SupportsLCDText() const { 148 bool PictureLayer::SupportsLCDText() const {
138 return true; 149 return true;
139 } 150 }
140 151
141 skia::RefPtr<SkPicture> PictureLayer::GetPicture() const { 152 skia::RefPtr<SkPicture> PictureLayer::GetPicture() const {
142 // We could either flatten the PicturePile into a single SkPicture, 153 // We could either flatten the PicturePile into a single SkPicture,
143 // or paint a fresh one depending on what we intend to do with the 154 // or paint a fresh one depending on what we intend to do with the
144 // picture. For now we just paint a fresh one to get consistent results. 155 // picture. For now we just paint a fresh one to get consistent results.
145 if (!DrawsContent()) 156 if (!DrawsContent())
146 return skia::RefPtr<SkPicture>(); 157 return skia::RefPtr<SkPicture>();
147 158
148 int width = bounds().width(); 159 int width = bounds().width();
149 int height = bounds().height(); 160 int height = bounds().height();
150 gfx::RectF opaque; 161 gfx::RectF opaque;
151 162
152 skia::RefPtr<SkPicture> picture = skia::AdoptRef(new SkPicture); 163 skia::RefPtr<SkPicture> picture = skia::AdoptRef(new SkPicture);
153 SkCanvas* canvas = picture->beginRecording(width, height); 164 SkCanvas* canvas = picture->beginRecording(width, height);
154 client_->PaintContents(canvas, gfx::Rect(width, height), &opaque); 165 client_->PaintContents(canvas, gfx::Rect(width, height), &opaque);
155 picture->endRecording(); 166 picture->endRecording();
156 return picture; 167 return picture;
157 } 168 }
158 169
159 void PictureLayer::RunMicroBenchmark(MicroBenchmark* benchmark) { 170 void PictureLayer::RunMicroBenchmark(MicroBenchmark* benchmark) {
160 benchmark->RunOnLayer(this); 171 benchmark->RunOnLayer(this);
161 } 172 }
162 173
163 } // namespace cc 174 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698