OLD | NEW |
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 Loading... |
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 //printf("TextureLayer::setNearestNeighbor %d\n", nearest_neighbor); |
| 71 if (nearest_neighbor_ == nearest_neighbor) |
| 72 return; |
| 73 nearest_neighbor_ = nearest_neighbor; |
| 74 //printf("TextureLayer::setNearestNeighbor setneedscommit\n"); |
| 75 SetNeedsCommit(); |
| 76 } |
| 77 |
68 void TextureLayer::SetUV(const gfx::PointF& top_left, | 78 void TextureLayer::SetUV(const gfx::PointF& top_left, |
69 const gfx::PointF& bottom_right) { | 79 const gfx::PointF& bottom_right) { |
70 if (uv_top_left_ == top_left && uv_bottom_right_ == bottom_right) | 80 if (uv_top_left_ == top_left && uv_bottom_right_ == bottom_right) |
71 return; | 81 return; |
72 uv_top_left_ = top_left; | 82 uv_top_left_ = top_left; |
73 uv_bottom_right_ = bottom_right; | 83 uv_bottom_right_ = bottom_right; |
74 SetNeedsCommit(); | 84 SetNeedsCommit(); |
75 } | 85 } |
76 | 86 |
77 void TextureLayer::SetVertexOpacity(float bottom_left, | 87 void TextureLayer::SetVertexOpacity(float bottom_left, |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
231 // different textures. Such callers notify this layer that the texture has | 241 // different textures. Such callers notify this layer that the texture has |
232 // changed by calling SetNeedsDisplay, so check for that here. | 242 // changed by calling SetNeedsDisplay, so check for that here. |
233 return updated || !update_rect_.IsEmpty(); | 243 return updated || !update_rect_.IsEmpty(); |
234 } | 244 } |
235 | 245 |
236 void TextureLayer::PushPropertiesTo(LayerImpl* layer) { | 246 void TextureLayer::PushPropertiesTo(LayerImpl* layer) { |
237 Layer::PushPropertiesTo(layer); | 247 Layer::PushPropertiesTo(layer); |
238 | 248 |
239 TextureLayerImpl* texture_layer = static_cast<TextureLayerImpl*>(layer); | 249 TextureLayerImpl* texture_layer = static_cast<TextureLayerImpl*>(layer); |
240 texture_layer->SetFlipped(flipped_); | 250 texture_layer->SetFlipped(flipped_); |
| 251 texture_layer->SetNearestNeighbor(nearest_neighbor_); |
241 texture_layer->SetUVTopLeft(uv_top_left_); | 252 texture_layer->SetUVTopLeft(uv_top_left_); |
242 texture_layer->SetUVBottomRight(uv_bottom_right_); | 253 texture_layer->SetUVBottomRight(uv_bottom_right_); |
243 texture_layer->SetVertexOpacity(vertex_opacity_); | 254 texture_layer->SetVertexOpacity(vertex_opacity_); |
244 texture_layer->SetPremultipliedAlpha(premultiplied_alpha_); | 255 texture_layer->SetPremultipliedAlpha(premultiplied_alpha_); |
245 texture_layer->SetBlendBackgroundColor(blend_background_color_); | 256 texture_layer->SetBlendBackgroundColor(blend_background_color_); |
246 if (needs_set_mailbox_) { | 257 if (needs_set_mailbox_) { |
247 TextureMailbox texture_mailbox; | 258 TextureMailbox texture_mailbox; |
248 scoped_ptr<SingleReleaseCallbackImpl> release_callback_impl; | 259 scoped_ptr<SingleReleaseCallbackImpl> release_callback_impl; |
249 if (holder_ref_) { | 260 if (holder_ref_) { |
250 TextureMailboxHolder* holder = holder_ref_->holder(); | 261 TextureMailboxHolder* holder = holder_ref_->holder(); |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
333 void TextureLayer::TextureMailboxHolder::ReturnAndReleaseOnImplThread( | 344 void TextureLayer::TextureMailboxHolder::ReturnAndReleaseOnImplThread( |
334 uint32 sync_point, | 345 uint32 sync_point, |
335 bool is_lost, | 346 bool is_lost, |
336 BlockingTaskRunner* main_thread_task_runner) { | 347 BlockingTaskRunner* main_thread_task_runner) { |
337 Return(sync_point, is_lost); | 348 Return(sync_point, is_lost); |
338 main_thread_task_runner->PostTask( | 349 main_thread_task_runner->PostTask( |
339 FROM_HERE, base::Bind(&TextureMailboxHolder::InternalRelease, this)); | 350 FROM_HERE, base::Bind(&TextureMailboxHolder::InternalRelease, this)); |
340 } | 351 } |
341 | 352 |
342 } // namespace cc | 353 } // namespace cc |
OLD | NEW |