| 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 "base/strings/stringprintf.h" | 7 #include "base/strings/stringprintf.h" |
| 8 #include "cc/layers/quad_sink.h" | 8 #include "cc/layers/quad_sink.h" |
| 9 #include "cc/output/renderer.h" | 9 #include "cc/output/renderer.h" |
| 10 #include "cc/quads/texture_draw_quad.h" | 10 #include "cc/quads/texture_draw_quad.h" |
| 11 #include "cc/trees/layer_tree_impl.h" | 11 #include "cc/trees/layer_tree_impl.h" |
| 12 | 12 |
| 13 namespace cc { | 13 namespace cc { |
| 14 | 14 |
| 15 TextureLayerImpl::TextureLayerImpl(LayerTreeImpl* tree_impl, | 15 TextureLayerImpl::TextureLayerImpl(LayerTreeImpl* tree_impl, |
| 16 int id, | 16 int id, |
| 17 bool uses_mailbox) | 17 bool uses_mailbox) |
| 18 : LayerImpl(tree_impl, id), | 18 : LayerImpl(tree_impl, id), |
| 19 texture_id_(0), | 19 texture_id_(0), |
| 20 external_texture_resource_(0), | 20 external_texture_resource_(0), |
| 21 premultiplied_alpha_(true), | 21 premultiplied_alpha_(true), |
| 22 blend_background_color_(false), |
| 22 flipped_(true), | 23 flipped_(true), |
| 23 uv_top_left_(0.f, 0.f), | 24 uv_top_left_(0.f, 0.f), |
| 24 uv_bottom_right_(1.f, 1.f), | 25 uv_bottom_right_(1.f, 1.f), |
| 25 uses_mailbox_(uses_mailbox), | 26 uses_mailbox_(uses_mailbox), |
| 26 own_mailbox_(false) { | 27 own_mailbox_(false) { |
| 27 vertex_opacity_[0] = 1.0f; | 28 vertex_opacity_[0] = 1.0f; |
| 28 vertex_opacity_[1] = 1.0f; | 29 vertex_opacity_[1] = 1.0f; |
| 29 vertex_opacity_[2] = 1.0f; | 30 vertex_opacity_[2] = 1.0f; |
| 30 vertex_opacity_[3] = 1.0f; | 31 vertex_opacity_[3] = 1.0f; |
| 31 } | 32 } |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 79 } | 80 } |
| 80 | 81 |
| 81 void TextureLayerImpl::AppendQuads(QuadSink* quad_sink, | 82 void TextureLayerImpl::AppendQuads(QuadSink* quad_sink, |
| 82 AppendQuadsData* append_quads_data) { | 83 AppendQuadsData* append_quads_data) { |
| 83 DCHECK(external_texture_resource_); | 84 DCHECK(external_texture_resource_); |
| 84 | 85 |
| 85 SharedQuadState* shared_quad_state = | 86 SharedQuadState* shared_quad_state = |
| 86 quad_sink->UseSharedQuadState(CreateSharedQuadState()); | 87 quad_sink->UseSharedQuadState(CreateSharedQuadState()); |
| 87 AppendDebugBorderQuad(quad_sink, shared_quad_state, append_quads_data); | 88 AppendDebugBorderQuad(quad_sink, shared_quad_state, append_quads_data); |
| 88 | 89 |
| 90 SkColor bg_color = blend_background_color_ ? |
| 91 background_color() : SK_ColorTRANSPARENT; |
| 89 gfx::Rect quad_rect(content_bounds()); | 92 gfx::Rect quad_rect(content_bounds()); |
| 90 gfx::Rect opaque_rect(contents_opaque() ? quad_rect : gfx::Rect()); | 93 gfx::Rect opaque_rect = contents_opaque() || (SkColorGetA(bg_color) == 0xFF) ? |
| 94 quad_rect : gfx::Rect(); |
| 91 scoped_ptr<TextureDrawQuad> quad = TextureDrawQuad::Create(); | 95 scoped_ptr<TextureDrawQuad> quad = TextureDrawQuad::Create(); |
| 92 quad->SetNew(shared_quad_state, | 96 quad->SetNew(shared_quad_state, |
| 93 quad_rect, | 97 quad_rect, |
| 94 opaque_rect, | 98 opaque_rect, |
| 95 external_texture_resource_, | 99 external_texture_resource_, |
| 96 premultiplied_alpha_, | 100 premultiplied_alpha_, |
| 97 uv_top_left_, | 101 uv_top_left_, |
| 98 uv_bottom_right_, | 102 uv_bottom_right_, |
| 99 vertex_opacity_, | 103 vertex_opacity_, |
| 104 bg_color, |
| 100 flipped_); | 105 flipped_); |
| 101 | 106 |
| 102 // Perform explicit clipping on a quad to avoid setting a scissor later. | 107 // Perform explicit clipping on a quad to avoid setting a scissor later. |
| 103 if (shared_quad_state->is_clipped && quad->PerformClipping()) | 108 if (shared_quad_state->is_clipped && quad->PerformClipping()) |
| 104 shared_quad_state->is_clipped = false; | 109 shared_quad_state->is_clipped = false; |
| 105 if (!quad->rect.IsEmpty()) | 110 if (!quad->rect.IsEmpty()) |
| 106 quad_sink->Append(quad.PassAs<DrawQuad>(), append_quads_data); | 111 quad_sink->Append(quad.PassAs<DrawQuad>(), append_quads_data); |
| 107 } | 112 } |
| 108 | 113 |
| 109 void TextureLayerImpl::DidDraw(ResourceProvider* resource_provider) { | 114 void TextureLayerImpl::DidDraw(ResourceProvider* resource_provider) { |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 157 } else if (external_texture_resource_) { | 162 } else if (external_texture_resource_) { |
| 158 DCHECK(!own_mailbox_); | 163 DCHECK(!own_mailbox_); |
| 159 ResourceProvider* resource_provider = | 164 ResourceProvider* resource_provider = |
| 160 layer_tree_impl()->resource_provider(); | 165 layer_tree_impl()->resource_provider(); |
| 161 resource_provider->DeleteResource(external_texture_resource_); | 166 resource_provider->DeleteResource(external_texture_resource_); |
| 162 external_texture_resource_ = 0; | 167 external_texture_resource_ = 0; |
| 163 } | 168 } |
| 164 } | 169 } |
| 165 | 170 |
| 166 } // namespace cc | 171 } // namespace cc |
| OLD | NEW |