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 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
97 } | 98 } |
98 | 99 |
99 void TextureLayerImpl::AppendQuads(QuadSink* quad_sink, | 100 void TextureLayerImpl::AppendQuads(QuadSink* quad_sink, |
100 AppendQuadsData* append_quads_data) { | 101 AppendQuadsData* append_quads_data) { |
101 DCHECK(external_texture_resource_); | 102 DCHECK(external_texture_resource_); |
102 | 103 |
103 SharedQuadState* shared_quad_state = | 104 SharedQuadState* shared_quad_state = |
104 quad_sink->UseSharedQuadState(CreateSharedQuadState()); | 105 quad_sink->UseSharedQuadState(CreateSharedQuadState()); |
105 AppendDebugBorderQuad(quad_sink, shared_quad_state, append_quads_data); | 106 AppendDebugBorderQuad(quad_sink, shared_quad_state, append_quads_data); |
106 | 107 |
| 108 SkColor bg_color = blend_background_color_ ? |
| 109 background_color() : SK_ColorTRANSPARENT; |
| 110 bool opaque = contents_opaque() || (SkColorGetA(bg_color) == 0xFF); |
| 111 |
107 gfx::Rect quad_rect(content_bounds()); | 112 gfx::Rect quad_rect(content_bounds()); |
108 gfx::Rect opaque_rect(contents_opaque() ? quad_rect : gfx::Rect()); | 113 gfx::Rect opaque_rect = opaque ? quad_rect : gfx::Rect(); |
109 scoped_ptr<TextureDrawQuad> quad = TextureDrawQuad::Create(); | 114 scoped_ptr<TextureDrawQuad> quad = TextureDrawQuad::Create(); |
110 quad->SetNew(shared_quad_state, | 115 quad->SetNew(shared_quad_state, |
111 quad_rect, | 116 quad_rect, |
112 opaque_rect, | 117 opaque_rect, |
113 external_texture_resource_, | 118 external_texture_resource_, |
114 premultiplied_alpha_, | 119 premultiplied_alpha_, |
115 uv_top_left_, | 120 uv_top_left_, |
116 uv_bottom_right_, | 121 uv_bottom_right_, |
| 122 bg_color, |
117 vertex_opacity_, | 123 vertex_opacity_, |
118 flipped_); | 124 flipped_); |
119 | 125 |
120 // Perform explicit clipping on a quad to avoid setting a scissor later. | 126 // Perform explicit clipping on a quad to avoid setting a scissor later. |
121 if (shared_quad_state->is_clipped && quad->PerformClipping()) | 127 if (shared_quad_state->is_clipped && quad->PerformClipping()) |
122 shared_quad_state->is_clipped = false; | 128 shared_quad_state->is_clipped = false; |
123 if (!quad->rect.IsEmpty()) | 129 if (!quad->rect.IsEmpty()) |
124 quad_sink->Append(quad.PassAs<DrawQuad>(), append_quads_data); | 130 quad_sink->Append(quad.PassAs<DrawQuad>(), append_quads_data); |
125 } | 131 } |
126 | 132 |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
163 } else if (external_texture_resource_) { | 169 } else if (external_texture_resource_) { |
164 DCHECK(!own_mailbox_); | 170 DCHECK(!own_mailbox_); |
165 ResourceProvider* resource_provider = | 171 ResourceProvider* resource_provider = |
166 layer_tree_impl()->resource_provider(); | 172 layer_tree_impl()->resource_provider(); |
167 resource_provider->DeleteResource(external_texture_resource_); | 173 resource_provider->DeleteResource(external_texture_resource_); |
168 external_texture_resource_ = 0; | 174 external_texture_resource_ = 0; |
169 } | 175 } |
170 } | 176 } |
171 | 177 |
172 } // namespace cc | 178 } // namespace cc |
OLD | NEW |