| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 #ifndef CC_LAYERS_PAINTED_OVERLAY_SCROLLBAR_LAYER_H_ | 5 #ifndef CC_LAYERS_PAINTED_OVERLAY_SCROLLBAR_LAYER_H_ |
| 6 #define CC_LAYERS_PAINTED_OVERLAY_SCROLLBAR_LAYER_H_ | 6 #define CC_LAYERS_PAINTED_OVERLAY_SCROLLBAR_LAYER_H_ |
| 7 | 7 |
| 8 #include "base/macros.h" | 8 #include "base/macros.h" |
| 9 #include "cc/cc_export.h" | 9 #include "cc/cc_export.h" |
| 10 #include "cc/input/scrollbar.h" | 10 #include "cc/input/scrollbar.h" |
| 11 #include "cc/layers/layer.h" | 11 #include "cc/layers/layer.h" |
| 12 #include "cc/layers/scrollbar_layer_interface.h" | 12 #include "cc/layers/scrollbar_layer_interface.h" |
| 13 #include "cc/layers/scrollbar_theme_painter.h" | 13 #include "cc/layers/scrollbar_theme_painter.h" |
| 14 #include "cc/resources/scoped_ui_resource.h" | 14 #include "cc/resources/scoped_ui_resource.h" |
| 15 | 15 |
| 16 namespace cc { | 16 namespace cc { |
| 17 | 17 |
| 18 class CC_EXPORT PaintedOverlayScrollbarLayer : public ScrollbarLayerInterface, | 18 class CC_EXPORT PaintedOverlayScrollbarLayer : public ScrollbarLayerInterface, |
| 19 public Layer { | 19 public Layer { |
| 20 public: | 20 public: |
| 21 std::unique_ptr<LayerImpl> CreateLayerImpl(LayerTreeImpl* tree_impl) override; | 21 std::unique_ptr<LayerImpl> CreateLayerImpl(LayerTreeImpl* tree_impl) override; |
| 22 | 22 |
| 23 static scoped_refptr<PaintedOverlayScrollbarLayer> Create( | 23 static scoped_refptr<PaintedOverlayScrollbarLayer> Create( |
| 24 std::unique_ptr<Scrollbar> scrollbar, | 24 std::unique_ptr<Scrollbar> scrollbar, |
| 25 int scroll_layer_id); | 25 int scroll_layer_id, |
| 26 ElementId scroll_element_id = ElementId()); |
| 26 | 27 |
| 27 bool OpacityCanAnimateOnImplThread() const override; | 28 bool OpacityCanAnimateOnImplThread() const override; |
| 28 bool AlwaysUseActiveTreeOpacity() const override; | 29 bool AlwaysUseActiveTreeOpacity() const override; |
| 29 ScrollbarLayerInterface* ToScrollbarLayer() override; | 30 ScrollbarLayerInterface* ToScrollbarLayer() override; |
| 30 | 31 |
| 31 // ScrollbarLayerInterface | 32 // ScrollbarLayerInterface |
| 32 int ScrollLayerId() const override; | 33 ElementId scroll_element_id() const override; |
| 33 void SetScrollLayer(int layer_id) override; | 34 // TODO(pdr): Remove layer_id and refactor scrollbars to just use element ids. |
| 35 void SetScrollInfo(int layer_id, ElementId element_id) override; |
| 34 ScrollbarOrientation orientation() const override; | 36 ScrollbarOrientation orientation() const override; |
| 35 | 37 |
| 36 // Layer interface | 38 // Layer interface |
| 37 bool Update() override; | 39 bool Update() override; |
| 38 void SetLayerTreeHost(LayerTreeHost* host) override; | 40 void SetLayerTreeHost(LayerTreeHost* host) override; |
| 39 void PushPropertiesTo(LayerImpl* layer) override; | 41 void PushPropertiesTo(LayerImpl* layer) override; |
| 40 | 42 |
| 41 protected: | 43 protected: |
| 42 PaintedOverlayScrollbarLayer(std::unique_ptr<Scrollbar> scrollbar, | 44 PaintedOverlayScrollbarLayer(std::unique_ptr<Scrollbar> scrollbar, |
| 43 int scroll_layer_id); | 45 int scroll_layer_id, |
| 46 ElementId scroll_element_id); |
| 44 ~PaintedOverlayScrollbarLayer() override; | 47 ~PaintedOverlayScrollbarLayer() override; |
| 45 | 48 |
| 46 private: | 49 private: |
| 47 gfx::Rect OriginThumbRectForPainting() const; | 50 gfx::Rect OriginThumbRectForPainting() const; |
| 48 | 51 |
| 49 template <typename T> | 52 template <typename T> |
| 50 bool UpdateProperty(T value, T* prop) { | 53 bool UpdateProperty(T value, T* prop) { |
| 51 if (*prop == value) | 54 if (*prop == value) |
| 52 return false; | 55 return false; |
| 53 *prop = value; | 56 *prop = value; |
| 54 SetNeedsPushProperties(); | 57 SetNeedsPushProperties(); |
| 55 return true; | 58 return true; |
| 56 } | 59 } |
| 57 | 60 |
| 58 bool PaintThumbIfNeeded(); | 61 bool PaintThumbIfNeeded(); |
| 59 | 62 |
| 60 std::unique_ptr<Scrollbar> scrollbar_; | 63 std::unique_ptr<Scrollbar> scrollbar_; |
| 61 int scroll_layer_id_; | 64 int scroll_layer_id_; |
| 65 ElementId scroll_element_id_; |
| 62 | 66 |
| 63 int thumb_thickness_; | 67 int thumb_thickness_; |
| 64 int thumb_length_; | 68 int thumb_length_; |
| 65 gfx::Point location_; | 69 gfx::Point location_; |
| 66 gfx::Rect track_rect_; | 70 gfx::Rect track_rect_; |
| 67 | 71 |
| 68 gfx::Rect aperture_; | 72 gfx::Rect aperture_; |
| 69 | 73 |
| 70 std::unique_ptr<ScopedUIResource> thumb_resource_; | 74 std::unique_ptr<ScopedUIResource> thumb_resource_; |
| 71 | 75 |
| 72 DISALLOW_COPY_AND_ASSIGN(PaintedOverlayScrollbarLayer); | 76 DISALLOW_COPY_AND_ASSIGN(PaintedOverlayScrollbarLayer); |
| 73 }; | 77 }; |
| 74 | 78 |
| 75 } // namespace cc | 79 } // namespace cc |
| 76 | 80 |
| 77 #endif // CC_LAYERS_PAINTED_OVERLAY_SCROLLBAR_LAYER_H_ | 81 #endif // CC_LAYERS_PAINTED_OVERLAY_SCROLLBAR_LAYER_H_ |
| OLD | NEW |