| 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" |
| 11 #include "cc/quads/texture_draw_quad.h" | 11 #include "cc/quads/texture_draw_quad.h" |
| 12 #include "cc/resources/platform_color.h" | 12 #include "cc/resources/platform_color.h" |
| 13 #include "cc/resources/scoped_resource.h" | 13 #include "cc/resources/scoped_resource.h" |
| 14 #include "cc/resources/single_release_callback_impl.h" | 14 #include "cc/resources/single_release_callback_impl.h" |
| 15 #include "cc/trees/layer_tree_impl.h" | 15 #include "cc/trees/layer_tree_impl.h" |
| 16 #include "cc/trees/occlusion.h" | 16 #include "cc/trees/occlusion.h" |
| 17 | 17 |
| 18 namespace cc { | 18 namespace cc { |
| 19 | 19 |
| 20 TextureLayerImpl::TextureLayerImpl(LayerTreeImpl* tree_impl, int id) | 20 TextureLayerImpl::TextureLayerImpl(LayerTreeImpl* tree_impl, int id) |
| 21 : LayerImpl(tree_impl, id), | 21 : LayerImpl(tree_impl, id), |
| 22 external_texture_resource_(0), | 22 external_texture_resource_(0), |
| 23 premultiplied_alpha_(true), | 23 premultiplied_alpha_(true), |
| 24 blend_background_color_(false), | 24 blend_background_color_(false), |
| 25 flipped_(true), | 25 flipped_(true), |
| 26 nearest_neighbor_(false), |
| 26 uv_top_left_(0.f, 0.f), | 27 uv_top_left_(0.f, 0.f), |
| 27 uv_bottom_right_(1.f, 1.f), | 28 uv_bottom_right_(1.f, 1.f), |
| 28 own_mailbox_(false), | 29 own_mailbox_(false), |
| 29 valid_texture_copy_(false) { | 30 valid_texture_copy_(false) { |
| 30 vertex_opacity_[0] = 1.0f; | 31 vertex_opacity_[0] = 1.0f; |
| 31 vertex_opacity_[1] = 1.0f; | 32 vertex_opacity_[1] = 1.0f; |
| 32 vertex_opacity_[2] = 1.0f; | 33 vertex_opacity_[2] = 1.0f; |
| 33 vertex_opacity_[3] = 1.0f; | 34 vertex_opacity_[3] = 1.0f; |
| 34 } | 35 } |
| 35 | 36 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 55 void TextureLayerImpl::PushPropertiesTo(LayerImpl* layer) { | 56 void TextureLayerImpl::PushPropertiesTo(LayerImpl* layer) { |
| 56 LayerImpl::PushPropertiesTo(layer); | 57 LayerImpl::PushPropertiesTo(layer); |
| 57 | 58 |
| 58 TextureLayerImpl* texture_layer = static_cast<TextureLayerImpl*>(layer); | 59 TextureLayerImpl* texture_layer = static_cast<TextureLayerImpl*>(layer); |
| 59 texture_layer->SetFlipped(flipped_); | 60 texture_layer->SetFlipped(flipped_); |
| 60 texture_layer->SetUVTopLeft(uv_top_left_); | 61 texture_layer->SetUVTopLeft(uv_top_left_); |
| 61 texture_layer->SetUVBottomRight(uv_bottom_right_); | 62 texture_layer->SetUVBottomRight(uv_bottom_right_); |
| 62 texture_layer->SetVertexOpacity(vertex_opacity_); | 63 texture_layer->SetVertexOpacity(vertex_opacity_); |
| 63 texture_layer->SetPremultipliedAlpha(premultiplied_alpha_); | 64 texture_layer->SetPremultipliedAlpha(premultiplied_alpha_); |
| 64 texture_layer->SetBlendBackgroundColor(blend_background_color_); | 65 texture_layer->SetBlendBackgroundColor(blend_background_color_); |
| 66 texture_layer->SetNearestNeighbor(nearest_neighbor_); |
| 65 if (own_mailbox_) { | 67 if (own_mailbox_) { |
| 66 texture_layer->SetTextureMailbox(texture_mailbox_, | 68 texture_layer->SetTextureMailbox(texture_mailbox_, |
| 67 release_callback_.Pass()); | 69 release_callback_.Pass()); |
| 68 own_mailbox_ = false; | 70 own_mailbox_ = false; |
| 69 } | 71 } |
| 70 } | 72 } |
| 71 | 73 |
| 72 bool TextureLayerImpl::WillDraw(DrawMode draw_mode, | 74 bool TextureLayerImpl::WillDraw(DrawMode draw_mode, |
| 73 ResourceProvider* resource_provider) { | 75 ResourceProvider* resource_provider) { |
| 74 if (draw_mode == DRAW_MODE_RESOURCELESS_SOFTWARE) | 76 if (draw_mode == DRAW_MODE_RESOURCELESS_SOFTWARE) |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 169 quad->SetNew(shared_quad_state, | 171 quad->SetNew(shared_quad_state, |
| 170 quad_rect, | 172 quad_rect, |
| 171 opaque_rect, | 173 opaque_rect, |
| 172 visible_quad_rect, | 174 visible_quad_rect, |
| 173 id, | 175 id, |
| 174 premultiplied_alpha_, | 176 premultiplied_alpha_, |
| 175 uv_top_left_, | 177 uv_top_left_, |
| 176 uv_bottom_right_, | 178 uv_bottom_right_, |
| 177 bg_color, | 179 bg_color, |
| 178 vertex_opacity_, | 180 vertex_opacity_, |
| 179 flipped_); | 181 flipped_, |
| 182 nearest_neighbor_); |
| 180 } | 183 } |
| 181 | 184 |
| 182 SimpleEnclosedRegion TextureLayerImpl::VisibleContentOpaqueRegion() const { | 185 SimpleEnclosedRegion TextureLayerImpl::VisibleContentOpaqueRegion() const { |
| 183 if (contents_opaque()) | 186 if (contents_opaque()) |
| 184 return SimpleEnclosedRegion(visible_content_rect()); | 187 return SimpleEnclosedRegion(visible_content_rect()); |
| 185 | 188 |
| 186 if (blend_background_color_ && (SkColorGetA(background_color()) == 0xFF)) | 189 if (blend_background_color_ && (SkColorGetA(background_color()) == 0xFF)) |
| 187 return SimpleEnclosedRegion(visible_content_rect()); | 190 return SimpleEnclosedRegion(visible_content_rect()); |
| 188 | 191 |
| 189 return SimpleEnclosedRegion(); | 192 return SimpleEnclosedRegion(); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 204 void TextureLayerImpl::SetBlendBackgroundColor(bool blend) { | 207 void TextureLayerImpl::SetBlendBackgroundColor(bool blend) { |
| 205 blend_background_color_ = blend; | 208 blend_background_color_ = blend; |
| 206 SetNeedsPushProperties(); | 209 SetNeedsPushProperties(); |
| 207 } | 210 } |
| 208 | 211 |
| 209 void TextureLayerImpl::SetFlipped(bool flipped) { | 212 void TextureLayerImpl::SetFlipped(bool flipped) { |
| 210 flipped_ = flipped; | 213 flipped_ = flipped; |
| 211 SetNeedsPushProperties(); | 214 SetNeedsPushProperties(); |
| 212 } | 215 } |
| 213 | 216 |
| 217 void TextureLayerImpl::SetNearestNeighbor(bool nearest_neighbor) { |
| 218 nearest_neighbor_ = nearest_neighbor; |
| 219 SetNeedsPushProperties(); |
| 220 } |
| 221 |
| 214 void TextureLayerImpl::SetUVTopLeft(const gfx::PointF top_left) { | 222 void TextureLayerImpl::SetUVTopLeft(const gfx::PointF top_left) { |
| 215 uv_top_left_ = top_left; | 223 uv_top_left_ = top_left; |
| 216 SetNeedsPushProperties(); | 224 SetNeedsPushProperties(); |
| 217 } | 225 } |
| 218 | 226 |
| 219 void TextureLayerImpl::SetUVBottomRight(const gfx::PointF bottom_right) { | 227 void TextureLayerImpl::SetUVBottomRight(const gfx::PointF bottom_right) { |
| 220 uv_bottom_right_ = bottom_right; | 228 uv_bottom_right_ = bottom_right; |
| 221 SetNeedsPushProperties(); | 229 SetNeedsPushProperties(); |
| 222 } | 230 } |
| 223 | 231 |
| (...skipping 25 matching lines...) Expand all Loading... |
| 249 } else if (external_texture_resource_) { | 257 } else if (external_texture_resource_) { |
| 250 DCHECK(!own_mailbox_); | 258 DCHECK(!own_mailbox_); |
| 251 ResourceProvider* resource_provider = | 259 ResourceProvider* resource_provider = |
| 252 layer_tree_impl()->resource_provider(); | 260 layer_tree_impl()->resource_provider(); |
| 253 resource_provider->DeleteResource(external_texture_resource_); | 261 resource_provider->DeleteResource(external_texture_resource_); |
| 254 external_texture_resource_ = 0; | 262 external_texture_resource_ = 0; |
| 255 } | 263 } |
| 256 } | 264 } |
| 257 | 265 |
| 258 } // namespace cc | 266 } // namespace cc |
| OLD | NEW |