OLD | NEW |
1 // Copyright 2011 The Chromium Authors. All rights reserved. | 1 // Copyright 2011 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_impl.h" | 5 #include "cc/layers/texture_layer_impl.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/strings/stringprintf.h" | 9 #include "base/strings/stringprintf.h" |
10 #include "cc/output/renderer.h" | 10 #include "cc/output/renderer.h" |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 FreeTextureMailbox(); | 42 FreeTextureMailbox(); |
43 texture_mailbox_ = mailbox; | 43 texture_mailbox_ = mailbox; |
44 release_callback_ = release_callback.Pass(); | 44 release_callback_ = release_callback.Pass(); |
45 own_mailbox_ = true; | 45 own_mailbox_ = true; |
46 valid_texture_copy_ = false; | 46 valid_texture_copy_ = false; |
47 SetNeedsPushProperties(); | 47 SetNeedsPushProperties(); |
48 } | 48 } |
49 | 49 |
50 scoped_ptr<LayerImpl> TextureLayerImpl::CreateLayerImpl( | 50 scoped_ptr<LayerImpl> TextureLayerImpl::CreateLayerImpl( |
51 LayerTreeImpl* tree_impl) { | 51 LayerTreeImpl* tree_impl) { |
52 return TextureLayerImpl::Create(tree_impl, id()).PassAs<LayerImpl>(); | 52 return TextureLayerImpl::Create(tree_impl, id()); |
53 } | 53 } |
54 | 54 |
55 void TextureLayerImpl::PushPropertiesTo(LayerImpl* layer) { | 55 void TextureLayerImpl::PushPropertiesTo(LayerImpl* layer) { |
56 LayerImpl::PushPropertiesTo(layer); | 56 LayerImpl::PushPropertiesTo(layer); |
57 | 57 |
58 TextureLayerImpl* texture_layer = static_cast<TextureLayerImpl*>(layer); | 58 TextureLayerImpl* texture_layer = static_cast<TextureLayerImpl*>(layer); |
59 texture_layer->SetFlipped(flipped_); | 59 texture_layer->SetFlipped(flipped_); |
60 texture_layer->SetUVTopLeft(uv_top_left_); | 60 texture_layer->SetUVTopLeft(uv_top_left_); |
61 texture_layer->SetUVBottomRight(uv_bottom_right_); | 61 texture_layer->SetUVBottomRight(uv_bottom_right_); |
62 texture_layer->SetVertexOpacity(vertex_opacity_); | 62 texture_layer->SetVertexOpacity(vertex_opacity_); |
(...skipping 13 matching lines...) Expand all Loading... |
76 | 76 |
77 if (own_mailbox_) { | 77 if (own_mailbox_) { |
78 DCHECK(!external_texture_resource_); | 78 DCHECK(!external_texture_resource_); |
79 if ((draw_mode == DRAW_MODE_HARDWARE && texture_mailbox_.IsTexture()) || | 79 if ((draw_mode == DRAW_MODE_HARDWARE && texture_mailbox_.IsTexture()) || |
80 (draw_mode == DRAW_MODE_SOFTWARE && | 80 (draw_mode == DRAW_MODE_SOFTWARE && |
81 texture_mailbox_.IsSharedMemory())) { | 81 texture_mailbox_.IsSharedMemory())) { |
82 external_texture_resource_ = | 82 external_texture_resource_ = |
83 resource_provider->CreateResourceFromTextureMailbox( | 83 resource_provider->CreateResourceFromTextureMailbox( |
84 texture_mailbox_, release_callback_.Pass()); | 84 texture_mailbox_, release_callback_.Pass()); |
85 DCHECK(external_texture_resource_); | 85 DCHECK(external_texture_resource_); |
86 texture_copy_.reset(); | 86 texture_copy_ = nullptr; |
87 valid_texture_copy_ = false; | 87 valid_texture_copy_ = false; |
88 } | 88 } |
89 if (external_texture_resource_) | 89 if (external_texture_resource_) |
90 own_mailbox_ = false; | 90 own_mailbox_ = false; |
91 } | 91 } |
92 | 92 |
93 if (!valid_texture_copy_ && draw_mode == DRAW_MODE_HARDWARE && | 93 if (!valid_texture_copy_ && draw_mode == DRAW_MODE_HARDWARE && |
94 texture_mailbox_.IsSharedMemory()) { | 94 texture_mailbox_.IsSharedMemory()) { |
95 DCHECK(!external_texture_resource_); | 95 DCHECK(!external_texture_resource_); |
96 // Have to upload a copy to a texture for it to be used in a | 96 // Have to upload a copy to a texture for it to be used in a |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
187 return SimpleEnclosedRegion(visible_content_rect()); | 187 return SimpleEnclosedRegion(visible_content_rect()); |
188 | 188 |
189 if (blend_background_color_ && (SkColorGetA(background_color()) == 0xFF)) | 189 if (blend_background_color_ && (SkColorGetA(background_color()) == 0xFF)) |
190 return SimpleEnclosedRegion(visible_content_rect()); | 190 return SimpleEnclosedRegion(visible_content_rect()); |
191 | 191 |
192 return SimpleEnclosedRegion(); | 192 return SimpleEnclosedRegion(); |
193 } | 193 } |
194 | 194 |
195 void TextureLayerImpl::ReleaseResources() { | 195 void TextureLayerImpl::ReleaseResources() { |
196 FreeTextureMailbox(); | 196 FreeTextureMailbox(); |
197 texture_copy_.reset(); | 197 texture_copy_ = nullptr; |
198 external_texture_resource_ = 0; | 198 external_texture_resource_ = 0; |
199 valid_texture_copy_ = false; | 199 valid_texture_copy_ = false; |
200 } | 200 } |
201 | 201 |
202 void TextureLayerImpl::SetPremultipliedAlpha(bool premultiplied_alpha) { | 202 void TextureLayerImpl::SetPremultipliedAlpha(bool premultiplied_alpha) { |
203 premultiplied_alpha_ = premultiplied_alpha; | 203 premultiplied_alpha_ = premultiplied_alpha; |
204 SetNeedsPushProperties(); | 204 SetNeedsPushProperties(); |
205 } | 205 } |
206 | 206 |
207 void TextureLayerImpl::SetBlendBackgroundColor(bool blend) { | 207 void TextureLayerImpl::SetBlendBackgroundColor(bool blend) { |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
241 | 241 |
242 void TextureLayerImpl::FreeTextureMailbox() { | 242 void TextureLayerImpl::FreeTextureMailbox() { |
243 if (own_mailbox_) { | 243 if (own_mailbox_) { |
244 DCHECK(!external_texture_resource_); | 244 DCHECK(!external_texture_resource_); |
245 if (release_callback_) { | 245 if (release_callback_) { |
246 release_callback_->Run(texture_mailbox_.sync_point(), | 246 release_callback_->Run(texture_mailbox_.sync_point(), |
247 false, | 247 false, |
248 layer_tree_impl()->BlockingMainThreadTaskRunner()); | 248 layer_tree_impl()->BlockingMainThreadTaskRunner()); |
249 } | 249 } |
250 texture_mailbox_ = TextureMailbox(); | 250 texture_mailbox_ = TextureMailbox(); |
251 release_callback_.reset(); | 251 release_callback_ = nullptr; |
252 } else if (external_texture_resource_) { | 252 } else if (external_texture_resource_) { |
253 DCHECK(!own_mailbox_); | 253 DCHECK(!own_mailbox_); |
254 ResourceProvider* resource_provider = | 254 ResourceProvider* resource_provider = |
255 layer_tree_impl()->resource_provider(); | 255 layer_tree_impl()->resource_provider(); |
256 resource_provider->DeleteResource(external_texture_resource_); | 256 resource_provider->DeleteResource(external_texture_resource_); |
257 external_texture_resource_ = 0; | 257 external_texture_resource_ = 0; |
258 } | 258 } |
259 } | 259 } |
260 | 260 |
261 } // namespace cc | 261 } // namespace cc |
OLD | NEW |