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

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

Issue 558083002: [cc] Add nearest neighbor filtering for TextureLayer. (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/texture_layer.h ('k') | cc/layers/texture_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 2010 The Chromium Authors. All rights reserved. 1 // Copyright 2010 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/texture_layer.h" 5 #include "cc/layers/texture_layer.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/callback_helpers.h" 8 #include "base/callback_helpers.h"
9 #include "base/location.h" 9 #include "base/location.h"
10 #include "base/synchronization/lock.h" 10 #include "base/synchronization/lock.h"
11 #include "cc/base/simple_enclosed_region.h" 11 #include "cc/base/simple_enclosed_region.h"
12 #include "cc/layers/texture_layer_client.h" 12 #include "cc/layers/texture_layer_client.h"
13 #include "cc/layers/texture_layer_impl.h" 13 #include "cc/layers/texture_layer_impl.h"
14 #include "cc/resources/single_release_callback.h" 14 #include "cc/resources/single_release_callback.h"
15 #include "cc/resources/single_release_callback_impl.h" 15 #include "cc/resources/single_release_callback_impl.h"
16 #include "cc/trees/blocking_task_runner.h" 16 #include "cc/trees/blocking_task_runner.h"
17 #include "cc/trees/layer_tree_host.h" 17 #include "cc/trees/layer_tree_host.h"
18 18
19 namespace cc { 19 namespace cc {
20 20
21 scoped_refptr<TextureLayer> TextureLayer::CreateForMailbox( 21 scoped_refptr<TextureLayer> TextureLayer::CreateForMailbox(
22 TextureLayerClient* client) { 22 TextureLayerClient* client) {
23 return scoped_refptr<TextureLayer>(new TextureLayer(client)); 23 return scoped_refptr<TextureLayer>(new TextureLayer(client));
24 } 24 }
25 25
26 TextureLayer::TextureLayer(TextureLayerClient* client) 26 TextureLayer::TextureLayer(TextureLayerClient* client)
27 : Layer(), 27 : Layer(),
28 client_(client), 28 client_(client),
29 flipped_(true), 29 flipped_(true),
30 nearest_neighbor_(false),
30 uv_top_left_(0.f, 0.f), 31 uv_top_left_(0.f, 0.f),
31 uv_bottom_right_(1.f, 1.f), 32 uv_bottom_right_(1.f, 1.f),
32 premultiplied_alpha_(true), 33 premultiplied_alpha_(true),
33 blend_background_color_(false), 34 blend_background_color_(false),
34 rate_limit_context_(false), 35 rate_limit_context_(false),
35 needs_set_mailbox_(false) { 36 needs_set_mailbox_(false) {
36 vertex_opacity_[0] = 1.0f; 37 vertex_opacity_[0] = 1.0f;
37 vertex_opacity_[1] = 1.0f; 38 vertex_opacity_[1] = 1.0f;
38 vertex_opacity_[2] = 1.0f; 39 vertex_opacity_[2] = 1.0f;
39 vertex_opacity_[3] = 1.0f; 40 vertex_opacity_[3] = 1.0f;
(...skipping 18 matching lines...) Expand all
58 return TextureLayerImpl::Create(tree_impl, id()); 59 return TextureLayerImpl::Create(tree_impl, id());
59 } 60 }
60 61
61 void TextureLayer::SetFlipped(bool flipped) { 62 void TextureLayer::SetFlipped(bool flipped) {
62 if (flipped_ == flipped) 63 if (flipped_ == flipped)
63 return; 64 return;
64 flipped_ = flipped; 65 flipped_ = flipped;
65 SetNeedsCommit(); 66 SetNeedsCommit();
66 } 67 }
67 68
69 void TextureLayer::SetNearestNeighbor(bool nearest_neighbor) {
70 if (nearest_neighbor_ == nearest_neighbor)
71 return;
72 nearest_neighbor_ = nearest_neighbor;
73 SetNeedsCommit();
74 }
75
68 void TextureLayer::SetUV(const gfx::PointF& top_left, 76 void TextureLayer::SetUV(const gfx::PointF& top_left,
69 const gfx::PointF& bottom_right) { 77 const gfx::PointF& bottom_right) {
70 if (uv_top_left_ == top_left && uv_bottom_right_ == bottom_right) 78 if (uv_top_left_ == top_left && uv_bottom_right_ == bottom_right)
71 return; 79 return;
72 uv_top_left_ = top_left; 80 uv_top_left_ = top_left;
73 uv_bottom_right_ = bottom_right; 81 uv_bottom_right_ = bottom_right;
74 SetNeedsCommit(); 82 SetNeedsCommit();
75 } 83 }
76 84
77 void TextureLayer::SetVertexOpacity(float bottom_left, 85 void TextureLayer::SetVertexOpacity(float bottom_left,
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
231 // different textures. Such callers notify this layer that the texture has 239 // different textures. Such callers notify this layer that the texture has
232 // changed by calling SetNeedsDisplay, so check for that here. 240 // changed by calling SetNeedsDisplay, so check for that here.
233 return updated || !update_rect_.IsEmpty(); 241 return updated || !update_rect_.IsEmpty();
234 } 242 }
235 243
236 void TextureLayer::PushPropertiesTo(LayerImpl* layer) { 244 void TextureLayer::PushPropertiesTo(LayerImpl* layer) {
237 Layer::PushPropertiesTo(layer); 245 Layer::PushPropertiesTo(layer);
238 246
239 TextureLayerImpl* texture_layer = static_cast<TextureLayerImpl*>(layer); 247 TextureLayerImpl* texture_layer = static_cast<TextureLayerImpl*>(layer);
240 texture_layer->SetFlipped(flipped_); 248 texture_layer->SetFlipped(flipped_);
249 texture_layer->SetNearestNeighbor(nearest_neighbor_);
241 texture_layer->SetUVTopLeft(uv_top_left_); 250 texture_layer->SetUVTopLeft(uv_top_left_);
242 texture_layer->SetUVBottomRight(uv_bottom_right_); 251 texture_layer->SetUVBottomRight(uv_bottom_right_);
243 texture_layer->SetVertexOpacity(vertex_opacity_); 252 texture_layer->SetVertexOpacity(vertex_opacity_);
244 texture_layer->SetPremultipliedAlpha(premultiplied_alpha_); 253 texture_layer->SetPremultipliedAlpha(premultiplied_alpha_);
245 texture_layer->SetBlendBackgroundColor(blend_background_color_); 254 texture_layer->SetBlendBackgroundColor(blend_background_color_);
246 if (needs_set_mailbox_) { 255 if (needs_set_mailbox_) {
247 TextureMailbox texture_mailbox; 256 TextureMailbox texture_mailbox;
248 scoped_ptr<SingleReleaseCallbackImpl> release_callback_impl; 257 scoped_ptr<SingleReleaseCallbackImpl> release_callback_impl;
249 if (holder_ref_) { 258 if (holder_ref_) {
250 TextureMailboxHolder* holder = holder_ref_->holder(); 259 TextureMailboxHolder* holder = holder_ref_->holder();
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
333 void TextureLayer::TextureMailboxHolder::ReturnAndReleaseOnImplThread( 342 void TextureLayer::TextureMailboxHolder::ReturnAndReleaseOnImplThread(
334 uint32 sync_point, 343 uint32 sync_point,
335 bool is_lost, 344 bool is_lost,
336 BlockingTaskRunner* main_thread_task_runner) { 345 BlockingTaskRunner* main_thread_task_runner) {
337 Return(sync_point, is_lost); 346 Return(sync_point, is_lost);
338 main_thread_task_runner->PostTask( 347 main_thread_task_runner->PostTask(
339 FROM_HERE, base::Bind(&TextureMailboxHolder::InternalRelease, this)); 348 FROM_HERE, base::Bind(&TextureMailboxHolder::InternalRelease, this));
340 } 349 }
341 350
342 } // namespace cc 351 } // namespace cc
OLDNEW
« no previous file with comments | « cc/layers/texture_layer.h ('k') | cc/layers/texture_layer_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698