| 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/painted_scrollbar_layer_impl.h" | 5 #include "cc/layers/painted_scrollbar_layer_impl.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "cc/animation/scrollbar_animation_controller.h" | 9 #include "cc/animation/scrollbar_animation_controller.h" |
| 10 #include "cc/layers/layer.h" | 10 #include "cc/layers/layer.h" |
| 11 #include "cc/quads/solid_color_draw_quad.h" | 11 #include "cc/quads/solid_color_draw_quad.h" |
| 12 #include "cc/quads/texture_draw_quad.h" | 12 #include "cc/quads/texture_draw_quad.h" |
| 13 #include "cc/trees/layer_tree_impl.h" | 13 #include "cc/trees/layer_tree_impl.h" |
| 14 #include "cc/trees/layer_tree_settings.h" | 14 #include "cc/trees/layer_tree_settings.h" |
| 15 #include "cc/trees/occlusion_tracker.h" | 15 #include "cc/trees/occlusion.h" |
| 16 #include "ui/gfx/rect_conversions.h" | 16 #include "ui/gfx/rect_conversions.h" |
| 17 | 17 |
| 18 namespace cc { | 18 namespace cc { |
| 19 | 19 |
| 20 scoped_ptr<PaintedScrollbarLayerImpl> PaintedScrollbarLayerImpl::Create( | 20 scoped_ptr<PaintedScrollbarLayerImpl> PaintedScrollbarLayerImpl::Create( |
| 21 LayerTreeImpl* tree_impl, | 21 LayerTreeImpl* tree_impl, |
| 22 int id, | 22 int id, |
| 23 ScrollbarOrientation orientation) { | 23 ScrollbarOrientation orientation) { |
| 24 return make_scoped_ptr( | 24 return make_scoped_ptr( |
| 25 new PaintedScrollbarLayerImpl(tree_impl, id, orientation)); | 25 new PaintedScrollbarLayerImpl(tree_impl, id, orientation)); |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 62 } | 62 } |
| 63 | 63 |
| 64 bool PaintedScrollbarLayerImpl::WillDraw(DrawMode draw_mode, | 64 bool PaintedScrollbarLayerImpl::WillDraw(DrawMode draw_mode, |
| 65 ResourceProvider* resource_provider) { | 65 ResourceProvider* resource_provider) { |
| 66 DCHECK(draw_mode != DRAW_MODE_RESOURCELESS_SOFTWARE); | 66 DCHECK(draw_mode != DRAW_MODE_RESOURCELESS_SOFTWARE); |
| 67 return LayerImpl::WillDraw(draw_mode, resource_provider); | 67 return LayerImpl::WillDraw(draw_mode, resource_provider); |
| 68 } | 68 } |
| 69 | 69 |
| 70 void PaintedScrollbarLayerImpl::AppendQuads( | 70 void PaintedScrollbarLayerImpl::AppendQuads( |
| 71 RenderPass* render_pass, | 71 RenderPass* render_pass, |
| 72 const OcclusionTracker<LayerImpl>& occlusion_tracker, | 72 const Occlusion& occlusion_in_content_space, |
| 73 AppendQuadsData* append_quads_data) { | 73 AppendQuadsData* append_quads_data) { |
| 74 bool premultipled_alpha = true; | 74 bool premultipled_alpha = true; |
| 75 bool flipped = false; | 75 bool flipped = false; |
| 76 gfx::PointF uv_top_left(0.f, 0.f); | 76 gfx::PointF uv_top_left(0.f, 0.f); |
| 77 gfx::PointF uv_bottom_right(1.f, 1.f); | 77 gfx::PointF uv_bottom_right(1.f, 1.f); |
| 78 gfx::Rect content_bounds_rect(content_bounds()); | 78 gfx::Rect content_bounds_rect(content_bounds()); |
| 79 | 79 |
| 80 SharedQuadState* shared_quad_state = | 80 SharedQuadState* shared_quad_state = |
| 81 render_pass->CreateAndAppendSharedQuadState(); | 81 render_pass->CreateAndAppendSharedQuadState(); |
| 82 PopulateSharedQuadState(shared_quad_state); | 82 PopulateSharedQuadState(shared_quad_state); |
| 83 | 83 |
| 84 AppendDebugBorderQuad( | 84 AppendDebugBorderQuad( |
| 85 render_pass, content_bounds(), shared_quad_state, append_quads_data); | 85 render_pass, content_bounds(), shared_quad_state, append_quads_data); |
| 86 | 86 |
| 87 gfx::Rect thumb_quad_rect = ComputeThumbQuadRect(); | 87 gfx::Rect thumb_quad_rect = ComputeThumbQuadRect(); |
| 88 Occlusion occlusion = | |
| 89 occlusion_tracker.GetCurrentOcclusionForLayer(draw_transform()); | |
| 90 gfx::Rect visible_thumb_quad_rect = | 88 gfx::Rect visible_thumb_quad_rect = |
| 91 occlusion.GetUnoccludedContentRect(thumb_quad_rect); | 89 occlusion_in_content_space.GetUnoccludedContentRect(thumb_quad_rect); |
| 92 | 90 |
| 93 ResourceProvider::ResourceId thumb_resource_id = | 91 ResourceProvider::ResourceId thumb_resource_id = |
| 94 layer_tree_impl()->ResourceIdForUIResource(thumb_ui_resource_id_); | 92 layer_tree_impl()->ResourceIdForUIResource(thumb_ui_resource_id_); |
| 95 ResourceProvider::ResourceId track_resource_id = | 93 ResourceProvider::ResourceId track_resource_id = |
| 96 layer_tree_impl()->ResourceIdForUIResource(track_ui_resource_id_); | 94 layer_tree_impl()->ResourceIdForUIResource(track_ui_resource_id_); |
| 97 | 95 |
| 98 if (thumb_resource_id && !visible_thumb_quad_rect.IsEmpty()) { | 96 if (thumb_resource_id && !visible_thumb_quad_rect.IsEmpty()) { |
| 99 gfx::Rect opaque_rect; | 97 gfx::Rect opaque_rect; |
| 100 const float opacity[] = {1.0f, 1.0f, 1.0f, 1.0f}; | 98 const float opacity[] = {1.0f, 1.0f, 1.0f, 1.0f}; |
| 101 TextureDrawQuad* quad = | 99 TextureDrawQuad* quad = |
| 102 render_pass->CreateAndAppendDrawQuad<TextureDrawQuad>(); | 100 render_pass->CreateAndAppendDrawQuad<TextureDrawQuad>(); |
| 103 quad->SetNew(shared_quad_state, | 101 quad->SetNew(shared_quad_state, |
| 104 thumb_quad_rect, | 102 thumb_quad_rect, |
| 105 opaque_rect, | 103 opaque_rect, |
| 106 visible_thumb_quad_rect, | 104 visible_thumb_quad_rect, |
| 107 thumb_resource_id, | 105 thumb_resource_id, |
| 108 premultipled_alpha, | 106 premultipled_alpha, |
| 109 uv_top_left, | 107 uv_top_left, |
| 110 uv_bottom_right, | 108 uv_bottom_right, |
| 111 SK_ColorTRANSPARENT, | 109 SK_ColorTRANSPARENT, |
| 112 opacity, | 110 opacity, |
| 113 flipped); | 111 flipped); |
| 114 } | 112 } |
| 115 | 113 |
| 116 gfx::Rect track_quad_rect = content_bounds_rect; | 114 gfx::Rect track_quad_rect = content_bounds_rect; |
| 117 gfx::Rect visible_track_quad_rect = | 115 gfx::Rect visible_track_quad_rect = |
| 118 occlusion.GetUnoccludedContentRect(track_quad_rect); | 116 occlusion_in_content_space.GetUnoccludedContentRect(track_quad_rect); |
| 119 if (track_resource_id && !visible_track_quad_rect.IsEmpty()) { | 117 if (track_resource_id && !visible_track_quad_rect.IsEmpty()) { |
| 120 gfx::Rect opaque_rect(contents_opaque() ? track_quad_rect : gfx::Rect()); | 118 gfx::Rect opaque_rect(contents_opaque() ? track_quad_rect : gfx::Rect()); |
| 121 const float opacity[] = {1.0f, 1.0f, 1.0f, 1.0f}; | 119 const float opacity[] = {1.0f, 1.0f, 1.0f, 1.0f}; |
| 122 TextureDrawQuad* quad = | 120 TextureDrawQuad* quad = |
| 123 render_pass->CreateAndAppendDrawQuad<TextureDrawQuad>(); | 121 render_pass->CreateAndAppendDrawQuad<TextureDrawQuad>(); |
| 124 quad->SetNew(shared_quad_state, | 122 quad->SetNew(shared_quad_state, |
| 125 track_quad_rect, | 123 track_quad_rect, |
| 126 opaque_rect, | 124 opaque_rect, |
| 127 visible_track_quad_rect, | 125 visible_track_quad_rect, |
| 128 track_resource_id, | 126 track_resource_id, |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 181 | 179 |
| 182 bool PaintedScrollbarLayerImpl::IsThumbResizable() const { | 180 bool PaintedScrollbarLayerImpl::IsThumbResizable() const { |
| 183 return false; | 181 return false; |
| 184 } | 182 } |
| 185 | 183 |
| 186 const char* PaintedScrollbarLayerImpl::LayerTypeAsString() const { | 184 const char* PaintedScrollbarLayerImpl::LayerTypeAsString() const { |
| 187 return "cc::PaintedScrollbarLayerImpl"; | 185 return "cc::PaintedScrollbarLayerImpl"; |
| 188 } | 186 } |
| 189 | 187 |
| 190 } // namespace cc | 188 } // namespace cc |
| OLD | NEW |