| 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 bounds_rect(bounds()); | 78 gfx::Rect bounds_rect(bounds()); |
| 79 gfx::Rect content_bounds_rect(content_bounds()); | 79 gfx::Rect content_bounds_rect(content_bounds()); |
| 80 | 80 |
| 81 SharedQuadState* shared_quad_state = | 81 SharedQuadState* shared_quad_state = |
| 82 render_pass->CreateAndAppendSharedQuadState(); | 82 render_pass->CreateAndAppendSharedQuadState(); |
| 83 PopulateSharedQuadState(shared_quad_state); | 83 PopulateSharedQuadState(shared_quad_state); |
| 84 | 84 |
| 85 AppendDebugBorderQuad( | 85 AppendDebugBorderQuad( |
| 86 render_pass, content_bounds(), shared_quad_state, append_quads_data); | 86 render_pass, content_bounds(), shared_quad_state, append_quads_data); |
| 87 | 87 |
| 88 gfx::Rect thumb_quad_rect = ComputeThumbQuadRect(); | 88 gfx::Rect thumb_quad_rect = ComputeThumbQuadRect(); |
| 89 Occlusion occlusion = | |
| 90 occlusion_tracker.GetCurrentOcclusionForLayer(draw_transform()); | |
| 91 gfx::Rect visible_thumb_quad_rect = | 89 gfx::Rect visible_thumb_quad_rect = |
| 92 occlusion.GetUnoccludedContentRect(thumb_quad_rect); | 90 occlusion_in_content_space.GetUnoccludedContentRect(thumb_quad_rect); |
| 93 | 91 |
| 94 ResourceProvider::ResourceId thumb_resource_id = | 92 ResourceProvider::ResourceId thumb_resource_id = |
| 95 layer_tree_impl()->ResourceIdForUIResource(thumb_ui_resource_id_); | 93 layer_tree_impl()->ResourceIdForUIResource(thumb_ui_resource_id_); |
| 96 ResourceProvider::ResourceId track_resource_id = | 94 ResourceProvider::ResourceId track_resource_id = |
| 97 layer_tree_impl()->ResourceIdForUIResource(track_ui_resource_id_); | 95 layer_tree_impl()->ResourceIdForUIResource(track_ui_resource_id_); |
| 98 | 96 |
| 99 if (thumb_resource_id && !visible_thumb_quad_rect.IsEmpty()) { | 97 if (thumb_resource_id && !visible_thumb_quad_rect.IsEmpty()) { |
| 100 gfx::Rect opaque_rect; | 98 gfx::Rect opaque_rect; |
| 101 const float opacity[] = {1.0f, 1.0f, 1.0f, 1.0f}; | 99 const float opacity[] = {1.0f, 1.0f, 1.0f, 1.0f}; |
| 102 TextureDrawQuad* quad = | 100 TextureDrawQuad* quad = |
| 103 render_pass->CreateAndAppendDrawQuad<TextureDrawQuad>(); | 101 render_pass->CreateAndAppendDrawQuad<TextureDrawQuad>(); |
| 104 quad->SetNew(shared_quad_state, | 102 quad->SetNew(shared_quad_state, |
| 105 thumb_quad_rect, | 103 thumb_quad_rect, |
| 106 opaque_rect, | 104 opaque_rect, |
| 107 visible_thumb_quad_rect, | 105 visible_thumb_quad_rect, |
| 108 thumb_resource_id, | 106 thumb_resource_id, |
| 109 premultipled_alpha, | 107 premultipled_alpha, |
| 110 uv_top_left, | 108 uv_top_left, |
| 111 uv_bottom_right, | 109 uv_bottom_right, |
| 112 SK_ColorTRANSPARENT, | 110 SK_ColorTRANSPARENT, |
| 113 opacity, | 111 opacity, |
| 114 flipped); | 112 flipped); |
| 115 } | 113 } |
| 116 | 114 |
| 117 gfx::Rect track_quad_rect = content_bounds_rect; | 115 gfx::Rect track_quad_rect = content_bounds_rect; |
| 118 gfx::Rect visible_track_quad_rect = | 116 gfx::Rect visible_track_quad_rect = |
| 119 occlusion.GetUnoccludedContentRect(track_quad_rect); | 117 occlusion_in_content_space.GetUnoccludedContentRect(track_quad_rect); |
| 120 if (track_resource_id && !visible_track_quad_rect.IsEmpty()) { | 118 if (track_resource_id && !visible_track_quad_rect.IsEmpty()) { |
| 121 gfx::Rect opaque_rect(contents_opaque() ? track_quad_rect : gfx::Rect()); | 119 gfx::Rect opaque_rect(contents_opaque() ? track_quad_rect : gfx::Rect()); |
| 122 const float opacity[] = {1.0f, 1.0f, 1.0f, 1.0f}; | 120 const float opacity[] = {1.0f, 1.0f, 1.0f, 1.0f}; |
| 123 TextureDrawQuad* quad = | 121 TextureDrawQuad* quad = |
| 124 render_pass->CreateAndAppendDrawQuad<TextureDrawQuad>(); | 122 render_pass->CreateAndAppendDrawQuad<TextureDrawQuad>(); |
| 125 quad->SetNew(shared_quad_state, | 123 quad->SetNew(shared_quad_state, |
| 126 track_quad_rect, | 124 track_quad_rect, |
| 127 opaque_rect, | 125 opaque_rect, |
| 128 visible_track_quad_rect, | 126 visible_track_quad_rect, |
| 129 track_resource_id, | 127 track_resource_id, |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 182 | 180 |
| 183 bool PaintedScrollbarLayerImpl::IsThumbResizable() const { | 181 bool PaintedScrollbarLayerImpl::IsThumbResizable() const { |
| 184 return false; | 182 return false; |
| 185 } | 183 } |
| 186 | 184 |
| 187 const char* PaintedScrollbarLayerImpl::LayerTypeAsString() const { | 185 const char* PaintedScrollbarLayerImpl::LayerTypeAsString() const { |
| 188 return "cc::PaintedScrollbarLayerImpl"; | 186 return "cc::PaintedScrollbarLayerImpl"; |
| 189 } | 187 } |
| 190 | 188 |
| 191 } // namespace cc | 189 } // namespace cc |
| OLD | NEW |