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

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

Issue 789433003: [cc] Add nearest neighbor filtering for PictureLayer. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Sync and rebase Created 6 years 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
« no previous file with comments | « cc/layers/picture_layer.h ('k') | cc/layers/picture_layer_impl.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "cc/layers/content_layer_client.h" 8 #include "cc/layers/content_layer_client.h"
9 #include "cc/layers/picture_layer_impl.h" 9 #include "cc/layers/picture_layer_impl.h"
10 #include "cc/resources/display_list_recording_source.h" 10 #include "cc/resources/display_list_recording_source.h"
11 #include "cc/resources/picture_pile.h" 11 #include "cc/resources/picture_pile.h"
12 #include "cc/trees/layer_tree_impl.h" 12 #include "cc/trees/layer_tree_impl.h"
13 #include "third_party/skia/include/core/SkPictureRecorder.h" 13 #include "third_party/skia/include/core/SkPictureRecorder.h"
14 #include "ui/gfx/geometry/rect_conversions.h" 14 #include "ui/gfx/geometry/rect_conversions.h"
15 15
16 namespace cc { 16 namespace cc {
17 17
18 scoped_refptr<PictureLayer> PictureLayer::Create(ContentLayerClient* client) { 18 scoped_refptr<PictureLayer> PictureLayer::Create(ContentLayerClient* client) {
19 return make_scoped_refptr(new PictureLayer(client)); 19 return make_scoped_refptr(new PictureLayer(client));
20 } 20 }
21 21
22 PictureLayer::PictureLayer(ContentLayerClient* client) 22 PictureLayer::PictureLayer(ContentLayerClient* client)
23 : client_(client), 23 : client_(client),
24 instrumentation_object_tracker_(id()), 24 instrumentation_object_tracker_(id()),
25 update_source_frame_number_(-1), 25 update_source_frame_number_(-1),
26 can_use_lcd_text_for_update_(true), 26 can_use_lcd_text_for_update_(true),
27 is_mask_(false) { 27 is_mask_(false),
28 nearest_neighbor_(false) {
28 } 29 }
29 30
30 PictureLayer::PictureLayer(ContentLayerClient* client, 31 PictureLayer::PictureLayer(ContentLayerClient* client,
31 scoped_ptr<RecordingSource> source) 32 scoped_ptr<RecordingSource> source)
32 : PictureLayer(client) { 33 : PictureLayer(client) {
33 recording_source_ = source.Pass(); 34 recording_source_ = source.Pass();
34 } 35 }
35 36
36 PictureLayer::~PictureLayer() { 37 PictureLayer::~PictureLayer() {
37 } 38 }
(...skipping 20 matching lines...) Expand all
58 << recording_source_bounds.ToString(); 59 << recording_source_bounds.ToString();
59 60
60 if (update_source_frame_number_ != source_frame_number && 61 if (update_source_frame_number_ != source_frame_number &&
61 recording_source_bounds != impl_bounds) { 62 recording_source_bounds != impl_bounds) {
62 // Update may not get called for the layer (if it's not in the viewport 63 // Update may not get called for the layer (if it's not in the viewport
63 // for example, even though it has resized making the recording source no 64 // for example, even though it has resized making the recording source no
64 // longer valid. In this case just destroy the recording source. 65 // longer valid. In this case just destroy the recording source.
65 recording_source_->SetEmptyBounds(); 66 recording_source_->SetEmptyBounds();
66 } 67 }
67 68
69 layer_impl->SetNearestNeighbor(nearest_neighbor_);
70
68 scoped_refptr<RasterSource> raster_source = 71 scoped_refptr<RasterSource> raster_source =
69 recording_source_->CreateRasterSource(); 72 recording_source_->CreateRasterSource();
70 raster_source->SetBackgoundColor(SafeOpaqueBackgroundColor()); 73 raster_source->SetBackgoundColor(SafeOpaqueBackgroundColor());
71 raster_source->SetRequiresClear(!contents_opaque() && 74 raster_source->SetRequiresClear(!contents_opaque() &&
72 !client_->FillsBoundsCompletely()); 75 !client_->FillsBoundsCompletely());
73 layer_impl->UpdateRasterSource(raster_source, &recording_invalidation_, 76 layer_impl->UpdateRasterSource(raster_source, &recording_invalidation_,
74 nullptr); 77 nullptr);
75 DCHECK(recording_invalidation_.IsEmpty()); 78 DCHECK(recording_invalidation_.IsEmpty());
76 } 79 }
77 80
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 201
199 bool PictureLayer::IsSuitableForGpuRasterization() const { 202 bool PictureLayer::IsSuitableForGpuRasterization() const {
200 return recording_source_->IsSuitableForGpuRasterization(); 203 return recording_source_->IsSuitableForGpuRasterization();
201 } 204 }
202 205
203 void PictureLayer::ClearClient() { 206 void PictureLayer::ClearClient() {
204 client_ = nullptr; 207 client_ = nullptr;
205 UpdateDrawsContent(HasDrawableContent()); 208 UpdateDrawsContent(HasDrawableContent());
206 } 209 }
207 210
211 void PictureLayer::SetNearestNeighbor(bool nearest_neighbor) {
212 if (nearest_neighbor_ == nearest_neighbor)
213 return;
214
215 nearest_neighbor_ = nearest_neighbor;
216 SetNeedsCommit();
217 }
218
208 bool PictureLayer::HasDrawableContent() const { 219 bool PictureLayer::HasDrawableContent() const {
209 return client_ && Layer::HasDrawableContent(); 220 return client_ && Layer::HasDrawableContent();
210 } 221 }
211 222
212 void PictureLayer::RunMicroBenchmark(MicroBenchmark* benchmark) { 223 void PictureLayer::RunMicroBenchmark(MicroBenchmark* benchmark) {
213 benchmark->RunOnLayer(this); 224 benchmark->RunOnLayer(this);
214 } 225 }
215 226
216 } // namespace cc 227 } // namespace cc
OLDNEW
« no previous file with comments | « cc/layers/picture_layer.h ('k') | cc/layers/picture_layer_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698