| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 #ifndef UI_GFX_COMPOSITOR_COMPOSITOR_H_ | 5 #ifndef UI_GFX_COMPOSITOR_COMPOSITOR_H_ |
| 6 #define UI_GFX_COMPOSITOR_COMPOSITOR_H_ | 6 #define UI_GFX_COMPOSITOR_COMPOSITOR_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
| 10 #include "base/observer_list.h" |
| 10 #include "ui/gfx/compositor/compositor_export.h" | 11 #include "ui/gfx/compositor/compositor_export.h" |
| 11 #include "ui/gfx/transform.h" | 12 #include "ui/gfx/transform.h" |
| 12 #include "ui/gfx/native_widget_types.h" | 13 #include "ui/gfx/native_widget_types.h" |
| 13 #include "ui/gfx/size.h" | 14 #include "ui/gfx/size.h" |
| 14 | 15 |
| 15 class SkCanvas; | 16 class SkCanvas; |
| 16 namespace gfx { | 17 namespace gfx { |
| 17 class Point; | 18 class Point; |
| 18 class Rect; | 19 class Rect; |
| 19 } | 20 } |
| 20 | 21 |
| 21 namespace ui { | 22 namespace ui { |
| 22 | 23 |
| 24 class CompositorObserver; |
| 25 |
| 23 struct TextureDrawParams { | 26 struct TextureDrawParams { |
| 24 TextureDrawParams() : transform(), blend(false), compositor_size() {} | 27 TextureDrawParams() : transform(), blend(false), compositor_size() {} |
| 25 | 28 |
| 26 // The transform to be applied to the texture. | 29 // The transform to be applied to the texture. |
| 27 ui::Transform transform; | 30 ui::Transform transform; |
| 28 | 31 |
| 29 // If this is true, then the texture is blended with the pixels behind it. | 32 // If this is true, then the texture is blended with the pixels behind it. |
| 30 // Otherwise, the drawn pixels clobber the old pixels. | 33 // Otherwise, the drawn pixels clobber the old pixels. |
| 31 bool blend; | 34 bool blend; |
| 32 | 35 |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 class COMPOSITOR_EXPORT Compositor : public base::RefCounted<Compositor> { | 77 class COMPOSITOR_EXPORT Compositor : public base::RefCounted<Compositor> { |
| 75 public: | 78 public: |
| 76 // Create a compositor from the provided handle. | 79 // Create a compositor from the provided handle. |
| 77 static Compositor* Create(gfx::AcceleratedWidget widget, | 80 static Compositor* Create(gfx::AcceleratedWidget widget, |
| 78 const gfx::Size& size); | 81 const gfx::Size& size); |
| 79 | 82 |
| 80 // Creates a new texture. The caller owns the returned object. | 83 // Creates a new texture. The caller owns the returned object. |
| 81 virtual Texture* CreateTexture() = 0; | 84 virtual Texture* CreateTexture() = 0; |
| 82 | 85 |
| 83 // Notifies the compositor that compositing is about to start. | 86 // Notifies the compositor that compositing is about to start. |
| 84 virtual void NotifyStart() = 0; | 87 void NotifyStart(); |
| 85 | 88 |
| 86 // Notifies the compositor that compositing is complete. | 89 // Notifies the compositor that compositing is complete. |
| 87 virtual void NotifyEnd() = 0; | 90 void NotifyEnd(); |
| 88 | 91 |
| 89 // Blurs the specific region in the compositor. | 92 // Blurs the specific region in the compositor. |
| 90 virtual void Blur(const gfx::Rect& bounds) = 0; | 93 virtual void Blur(const gfx::Rect& bounds) = 0; |
| 91 | 94 |
| 92 // Schedules a paint on the widget this Compositor was created for. | 95 // Schedules a paint on the widget this Compositor was created for. |
| 93 virtual void SchedulePaint() = 0; | 96 virtual void SchedulePaint() = 0; |
| 94 | 97 |
| 95 // Notifies the compositor that the size of the widget that it is | 98 // Notifies the compositor that the size of the widget that it is |
| 96 // drawing to has changed. | 99 // drawing to has changed. |
| 97 void WidgetSizeChanged(const gfx::Size& size) { | 100 void WidgetSizeChanged(const gfx::Size& size) { |
| 98 size_ = size; | 101 size_ = size; |
| 99 OnWidgetSizeChanged(); | 102 OnWidgetSizeChanged(); |
| 100 } | 103 } |
| 101 | 104 |
| 102 // Returns the size of the widget that is being drawn to. | 105 // Returns the size of the widget that is being drawn to. |
| 103 const gfx::Size& size() { return size_; } | 106 const gfx::Size& size() { return size_; } |
| 104 | 107 |
| 108 // Layers do not own observers. It is the responsibility of the observer to |
| 109 // remove itself when it is done observing. |
| 110 void AddObserver(CompositorObserver* observer); |
| 111 void RemoveObserver(CompositorObserver* observer); |
| 112 |
| 105 protected: | 113 protected: |
| 106 explicit Compositor(const gfx::Size& size) : size_(size) {} | 114 explicit Compositor(const gfx::Size& size) : size_(size) {} |
| 107 virtual ~Compositor() {} | 115 virtual ~Compositor() {} |
| 108 | 116 |
| 117 // Notifies the compositor that compositing is about to start. |
| 118 virtual void OnNotifyStart() = 0; |
| 119 |
| 120 // Notifies the compositor that compositing is complete. |
| 121 virtual void OnNotifyEnd() = 0; |
| 122 |
| 109 virtual void OnWidgetSizeChanged() = 0; | 123 virtual void OnWidgetSizeChanged() = 0; |
| 110 | 124 |
| 111 private: | 125 private: |
| 112 gfx::Size size_; | 126 gfx::Size size_; |
| 113 | 127 |
| 128 ObserverList<CompositorObserver> observer_list_; |
| 129 |
| 114 friend class base::RefCounted<Compositor>; | 130 friend class base::RefCounted<Compositor>; |
| 115 }; | 131 }; |
| 116 | 132 |
| 117 } // namespace ui | 133 } // namespace ui |
| 118 | 134 |
| 119 #endif // UI_GFX_COMPOSITOR_COMPOSITOR_H_ | 135 #endif // UI_GFX_COMPOSITOR_COMPOSITOR_H_ |
| OLD | NEW |