| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/ui_resource_layer_impl.h" | 5 #include "cc/layers/ui_resource_layer_impl.h" |
| 6 | 6 |
| 7 #include "base/strings/stringprintf.h" | 7 #include "base/strings/stringprintf.h" |
| 8 #include "base/values.h" | 8 #include "base/values.h" |
| 9 #include "cc/base/math_util.h" | 9 #include "cc/base/math_util.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 #include "cc/trees/occlusion_tracker.h" | 12 #include "cc/trees/occlusion.h" |
| 13 #include "ui/gfx/geometry/size_conversions.h" | 13 #include "ui/gfx/geometry/size_conversions.h" |
| 14 #include "ui/gfx/rect_f.h" | 14 #include "ui/gfx/rect_f.h" |
| 15 | 15 |
| 16 namespace cc { | 16 namespace cc { |
| 17 | 17 |
| 18 UIResourceLayerImpl::UIResourceLayerImpl(LayerTreeImpl* tree_impl, int id) | 18 UIResourceLayerImpl::UIResourceLayerImpl(LayerTreeImpl* tree_impl, int id) |
| 19 : LayerImpl(tree_impl, id), | 19 : LayerImpl(tree_impl, id), |
| 20 ui_resource_id_(0), | 20 ui_resource_id_(0), |
| 21 uv_top_left_(0.f, 0.f), | 21 uv_top_left_(0.f, 0.f), |
| 22 uv_bottom_right_(1.f, 1.f) { | 22 uv_bottom_right_(1.f, 1.f) { |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 | 87 |
| 88 bool UIResourceLayerImpl::WillDraw(DrawMode draw_mode, | 88 bool UIResourceLayerImpl::WillDraw(DrawMode draw_mode, |
| 89 ResourceProvider* resource_provider) { | 89 ResourceProvider* resource_provider) { |
| 90 if (!ui_resource_id_ || draw_mode == DRAW_MODE_RESOURCELESS_SOFTWARE) | 90 if (!ui_resource_id_ || draw_mode == DRAW_MODE_RESOURCELESS_SOFTWARE) |
| 91 return false; | 91 return false; |
| 92 return LayerImpl::WillDraw(draw_mode, resource_provider); | 92 return LayerImpl::WillDraw(draw_mode, resource_provider); |
| 93 } | 93 } |
| 94 | 94 |
| 95 void UIResourceLayerImpl::AppendQuads( | 95 void UIResourceLayerImpl::AppendQuads( |
| 96 RenderPass* render_pass, | 96 RenderPass* render_pass, |
| 97 const OcclusionTracker<LayerImpl>& occlusion_tracker, | 97 const Occlusion& occlusion_in_content_space, |
| 98 AppendQuadsData* append_quads_data) { | 98 AppendQuadsData* append_quads_data) { |
| 99 SharedQuadState* shared_quad_state = | 99 SharedQuadState* shared_quad_state = |
| 100 render_pass->CreateAndAppendSharedQuadState(); | 100 render_pass->CreateAndAppendSharedQuadState(); |
| 101 PopulateSharedQuadState(shared_quad_state); | 101 PopulateSharedQuadState(shared_quad_state); |
| 102 | 102 |
| 103 AppendDebugBorderQuad( | 103 AppendDebugBorderQuad( |
| 104 render_pass, content_bounds(), shared_quad_state, append_quads_data); | 104 render_pass, content_bounds(), shared_quad_state, append_quads_data); |
| 105 | 105 |
| 106 if (!ui_resource_id_) | 106 if (!ui_resource_id_) |
| 107 return; | 107 return; |
| 108 | 108 |
| 109 ResourceProvider::ResourceId resource = | 109 ResourceProvider::ResourceId resource = |
| 110 layer_tree_impl()->ResourceIdForUIResource(ui_resource_id_); | 110 layer_tree_impl()->ResourceIdForUIResource(ui_resource_id_); |
| 111 | 111 |
| 112 if (!resource) | 112 if (!resource) |
| 113 return; | 113 return; |
| 114 | 114 |
| 115 static const bool flipped = false; | 115 static const bool flipped = false; |
| 116 static const bool premultiplied_alpha = true; | 116 static const bool premultiplied_alpha = true; |
| 117 | 117 |
| 118 DCHECK(!bounds().IsEmpty()); | 118 DCHECK(!bounds().IsEmpty()); |
| 119 | 119 |
| 120 bool opaque = layer_tree_impl()->IsUIResourceOpaque(ui_resource_id_) || | 120 bool opaque = layer_tree_impl()->IsUIResourceOpaque(ui_resource_id_) || |
| 121 contents_opaque(); | 121 contents_opaque(); |
| 122 | 122 |
| 123 gfx::Rect quad_rect(gfx::ToCeiledSize(bounds())); | 123 gfx::Rect quad_rect(gfx::ToCeiledSize(bounds())); |
| 124 gfx::Rect opaque_rect(opaque ? quad_rect : gfx::Rect()); | 124 gfx::Rect opaque_rect(opaque ? quad_rect : gfx::Rect()); |
| 125 gfx::Rect visible_quad_rect = | 125 gfx::Rect visible_quad_rect = |
| 126 occlusion_tracker.GetCurrentOcclusionForLayer( | 126 occlusion_in_content_space.GetUnoccludedContentRect(quad_rect); |
| 127 draw_properties().target_space_transform) | |
| 128 .GetUnoccludedContentRect(quad_rect); | |
| 129 if (visible_quad_rect.IsEmpty()) | 127 if (visible_quad_rect.IsEmpty()) |
| 130 return; | 128 return; |
| 131 | 129 |
| 132 TextureDrawQuad* quad = | 130 TextureDrawQuad* quad = |
| 133 render_pass->CreateAndAppendDrawQuad<TextureDrawQuad>(); | 131 render_pass->CreateAndAppendDrawQuad<TextureDrawQuad>(); |
| 134 quad->SetNew(shared_quad_state, | 132 quad->SetNew(shared_quad_state, |
| 135 quad_rect, | 133 quad_rect, |
| 136 opaque_rect, | 134 opaque_rect, |
| 137 visible_quad_rect, | 135 visible_quad_rect, |
| 138 resource, | 136 resource, |
| (...skipping 21 matching lines...) Expand all Loading... |
| 160 list->AppendDouble(vertex_opacity_[3]); | 158 list->AppendDouble(vertex_opacity_[3]); |
| 161 result->Set("VertexOpacity", list); | 159 result->Set("VertexOpacity", list); |
| 162 | 160 |
| 163 result->Set("UVTopLeft", MathUtil::AsValue(uv_top_left_).release()); | 161 result->Set("UVTopLeft", MathUtil::AsValue(uv_top_left_).release()); |
| 164 result->Set("UVBottomRight", MathUtil::AsValue(uv_bottom_right_).release()); | 162 result->Set("UVBottomRight", MathUtil::AsValue(uv_bottom_right_).release()); |
| 165 | 163 |
| 166 return result; | 164 return result; |
| 167 } | 165 } |
| 168 | 166 |
| 169 } // namespace cc | 167 } // namespace cc |
| OLD | NEW |