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/layers/quad_sink.h" | 10 #include "cc/layers/quad_sink.h" |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
165 SharedQuadState* shared_quad_state = | 165 SharedQuadState* shared_quad_state = |
166 quad_sink->UseSharedQuadState(CreateSharedQuadState()); | 166 quad_sink->UseSharedQuadState(CreateSharedQuadState()); |
167 AppendDebugBorderQuad(quad_sink, shared_quad_state, append_quads_data); | 167 AppendDebugBorderQuad(quad_sink, shared_quad_state, append_quads_data); |
168 | 168 |
169 SkColor bg_color = blend_background_color_ ? | 169 SkColor bg_color = blend_background_color_ ? |
170 background_color() : SK_ColorTRANSPARENT; | 170 background_color() : SK_ColorTRANSPARENT; |
171 bool opaque = contents_opaque() || (SkColorGetA(bg_color) == 0xFF); | 171 bool opaque = contents_opaque() || (SkColorGetA(bg_color) == 0xFF); |
172 | 172 |
173 gfx::Rect quad_rect(content_bounds()); | 173 gfx::Rect quad_rect(content_bounds()); |
174 gfx::Rect opaque_rect = opaque ? quad_rect : gfx::Rect(); | 174 gfx::Rect opaque_rect = opaque ? quad_rect : gfx::Rect(); |
175 gfx::Rect visible_quad_rect(quad_rect); | 175 gfx::Rect visible_quad_rect = quad_sink->UnoccludedContentRect( |
| 176 quad_rect, draw_properties().target_space_transform); |
| 177 if (visible_quad_rect.IsEmpty()) |
| 178 return; |
| 179 |
176 scoped_ptr<TextureDrawQuad> quad = TextureDrawQuad::Create(); | 180 scoped_ptr<TextureDrawQuad> quad = TextureDrawQuad::Create(); |
177 ResourceProvider::ResourceId id = | 181 ResourceProvider::ResourceId id = |
178 valid_texture_copy_ ? texture_copy_->id() : external_texture_resource_; | 182 valid_texture_copy_ ? texture_copy_->id() : external_texture_resource_; |
179 quad->SetNew(shared_quad_state, | 183 quad->SetNew(shared_quad_state, |
180 quad_rect, | 184 quad_rect, |
181 opaque_rect, | 185 opaque_rect, |
182 visible_quad_rect, | 186 visible_quad_rect, |
183 id, | 187 id, |
184 premultiplied_alpha_, | 188 premultiplied_alpha_, |
185 uv_top_left_, | 189 uv_top_left_, |
186 uv_bottom_right_, | 190 uv_bottom_right_, |
187 bg_color, | 191 bg_color, |
188 vertex_opacity_, | 192 vertex_opacity_, |
189 flipped_); | 193 flipped_); |
190 quad_sink->MaybeAppend(quad.PassAs<DrawQuad>()); | 194 quad_sink->Append(quad.PassAs<DrawQuad>()); |
191 } | 195 } |
192 | 196 |
193 void TextureLayerImpl::DidDraw(ResourceProvider* resource_provider) { | 197 void TextureLayerImpl::DidDraw(ResourceProvider* resource_provider) { |
194 LayerImpl::DidDraw(resource_provider); | 198 LayerImpl::DidDraw(resource_provider); |
195 if (uses_mailbox_ || !external_texture_resource_) | 199 if (uses_mailbox_ || !external_texture_resource_) |
196 return; | 200 return; |
197 // TODO(danakj): the following assert will not be true when sending resources | 201 // TODO(danakj): the following assert will not be true when sending resources |
198 // to a parent compositor. A synchronization scheme (double-buffering or | 202 // to a parent compositor. A synchronization scheme (double-buffering or |
199 // pipelining of updates) for the client will need to exist to solve this. | 203 // pipelining of updates) for the client will need to exist to solve this. |
200 DCHECK(!resource_provider->InUseByConsumer(external_texture_resource_)); | 204 DCHECK(!resource_provider->InUseByConsumer(external_texture_resource_)); |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
283 } else if (external_texture_resource_) { | 287 } else if (external_texture_resource_) { |
284 DCHECK(!own_mailbox_); | 288 DCHECK(!own_mailbox_); |
285 ResourceProvider* resource_provider = | 289 ResourceProvider* resource_provider = |
286 layer_tree_impl()->resource_provider(); | 290 layer_tree_impl()->resource_provider(); |
287 resource_provider->DeleteResource(external_texture_resource_); | 291 resource_provider->DeleteResource(external_texture_resource_); |
288 external_texture_resource_ = 0; | 292 external_texture_resource_ = 0; |
289 } | 293 } |
290 } | 294 } |
291 | 295 |
292 } // namespace cc | 296 } // namespace cc |
OLD | NEW |