| 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" | |
| 11 #include "cc/output/renderer.h" | 10 #include "cc/output/renderer.h" |
| 12 #include "cc/quads/texture_draw_quad.h" | 11 #include "cc/quads/texture_draw_quad.h" |
| 13 #include "cc/resources/platform_color.h" | 12 #include "cc/resources/platform_color.h" |
| 14 #include "cc/resources/scoped_resource.h" | 13 #include "cc/resources/scoped_resource.h" |
| 15 #include "cc/resources/single_release_callback.h" | 14 #include "cc/resources/single_release_callback.h" |
| 16 #include "cc/trees/layer_tree_impl.h" | 15 #include "cc/trees/layer_tree_impl.h" |
| 16 #include "cc/trees/occlusion_tracker.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 uv_top_left_(0.f, 0.f), | 26 uv_top_left_(0.f, 0.f), |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 132 gfx::Rect(texture_mailbox_.shared_memory_size()), | 132 gfx::Rect(texture_mailbox_.shared_memory_size()), |
| 133 gfx::Vector2d()); | 133 gfx::Vector2d()); |
| 134 | 134 |
| 135 valid_texture_copy_ = true; | 135 valid_texture_copy_ = true; |
| 136 } | 136 } |
| 137 } | 137 } |
| 138 return (external_texture_resource_ || valid_texture_copy_) && | 138 return (external_texture_resource_ || valid_texture_copy_) && |
| 139 LayerImpl::WillDraw(draw_mode, resource_provider); | 139 LayerImpl::WillDraw(draw_mode, resource_provider); |
| 140 } | 140 } |
| 141 | 141 |
| 142 void TextureLayerImpl::AppendQuads(QuadSink* quad_sink, | 142 void TextureLayerImpl::AppendQuads( |
| 143 AppendQuadsData* append_quads_data) { | 143 RenderPass* render_pass, |
| 144 const OcclusionTracker<LayerImpl>& occlusion_tracker, |
| 145 AppendQuadsData* append_quads_data) { |
| 144 DCHECK(external_texture_resource_ || valid_texture_copy_); | 146 DCHECK(external_texture_resource_ || valid_texture_copy_); |
| 145 | 147 |
| 146 SharedQuadState* shared_quad_state = quad_sink->CreateSharedQuadState(); | 148 SharedQuadState* shared_quad_state = |
| 149 render_pass->CreateAndAppendSharedQuadState(); |
| 147 PopulateSharedQuadState(shared_quad_state); | 150 PopulateSharedQuadState(shared_quad_state); |
| 148 | 151 |
| 149 AppendDebugBorderQuad(quad_sink, shared_quad_state, append_quads_data); | 152 AppendDebugBorderQuad(render_pass, shared_quad_state, append_quads_data); |
| 150 | 153 |
| 151 SkColor bg_color = blend_background_color_ ? | 154 SkColor bg_color = blend_background_color_ ? |
| 152 background_color() : SK_ColorTRANSPARENT; | 155 background_color() : SK_ColorTRANSPARENT; |
| 153 bool opaque = contents_opaque() || (SkColorGetA(bg_color) == 0xFF); | 156 bool opaque = contents_opaque() || (SkColorGetA(bg_color) == 0xFF); |
| 154 | 157 |
| 155 gfx::Rect quad_rect(content_bounds()); | 158 gfx::Rect quad_rect(content_bounds()); |
| 156 gfx::Rect opaque_rect = opaque ? quad_rect : gfx::Rect(); | 159 gfx::Rect opaque_rect = opaque ? quad_rect : gfx::Rect(); |
| 157 gfx::Rect visible_quad_rect = quad_sink->UnoccludedContentRect( | 160 gfx::Rect visible_quad_rect = occlusion_tracker.UnoccludedContentRect( |
| 158 this, quad_rect, draw_properties().target_space_transform); | 161 this->render_target(), |
| 162 quad_rect, |
| 163 draw_properties().target_space_transform); |
| 159 if (visible_quad_rect.IsEmpty()) | 164 if (visible_quad_rect.IsEmpty()) |
| 160 return; | 165 return; |
| 161 | 166 |
| 162 scoped_ptr<TextureDrawQuad> quad = TextureDrawQuad::Create(); | 167 scoped_ptr<TextureDrawQuad> quad = TextureDrawQuad::Create(); |
| 163 ResourceProvider::ResourceId id = | 168 ResourceProvider::ResourceId id = |
| 164 valid_texture_copy_ ? texture_copy_->id() : external_texture_resource_; | 169 valid_texture_copy_ ? texture_copy_->id() : external_texture_resource_; |
| 165 quad->SetNew(shared_quad_state, | 170 quad->SetNew(shared_quad_state, |
| 166 quad_rect, | 171 quad_rect, |
| 167 opaque_rect, | 172 opaque_rect, |
| 168 visible_quad_rect, | 173 visible_quad_rect, |
| 169 id, | 174 id, |
| 170 premultiplied_alpha_, | 175 premultiplied_alpha_, |
| 171 uv_top_left_, | 176 uv_top_left_, |
| 172 uv_bottom_right_, | 177 uv_bottom_right_, |
| 173 bg_color, | 178 bg_color, |
| 174 vertex_opacity_, | 179 vertex_opacity_, |
| 175 flipped_); | 180 flipped_); |
| 176 quad_sink->Append(quad.PassAs<DrawQuad>()); | 181 render_pass->AppendDrawQuad(quad.PassAs<DrawQuad>()); |
| 177 } | 182 } |
| 178 | 183 |
| 179 Region TextureLayerImpl::VisibleContentOpaqueRegion() const { | 184 Region TextureLayerImpl::VisibleContentOpaqueRegion() const { |
| 180 if (contents_opaque()) | 185 if (contents_opaque()) |
| 181 return visible_content_rect(); | 186 return visible_content_rect(); |
| 182 | 187 |
| 183 if (blend_background_color_ && (SkColorGetA(background_color()) == 0xFF)) | 188 if (blend_background_color_ && (SkColorGetA(background_color()) == 0xFF)) |
| 184 return visible_content_rect(); | 189 return visible_content_rect(); |
| 185 | 190 |
| 186 return Region(); | 191 return Region(); |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 243 } else if (external_texture_resource_) { | 248 } else if (external_texture_resource_) { |
| 244 DCHECK(!own_mailbox_); | 249 DCHECK(!own_mailbox_); |
| 245 ResourceProvider* resource_provider = | 250 ResourceProvider* resource_provider = |
| 246 layer_tree_impl()->resource_provider(); | 251 layer_tree_impl()->resource_provider(); |
| 247 resource_provider->DeleteResource(external_texture_resource_); | 252 resource_provider->DeleteResource(external_texture_resource_); |
| 248 external_texture_resource_ = 0; | 253 external_texture_resource_ = 0; |
| 249 } | 254 } |
| 250 } | 255 } |
| 251 | 256 |
| 252 } // namespace cc | 257 } // namespace cc |
| OLD | NEW |