Chromium Code Reviews| 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 "ui/gfx/compositor/compositor_export.h" | 10 #include "ui/gfx/compositor/compositor_export.h" |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 56 virtual void Draw(const ui::TextureDrawParams& params, | 56 virtual void Draw(const ui::TextureDrawParams& params, |
| 57 const gfx::Rect& clip_bounds_in_texture) = 0; | 57 const gfx::Rect& clip_bounds_in_texture) = 0; |
| 58 | 58 |
| 59 protected: | 59 protected: |
| 60 virtual ~Texture() {} | 60 virtual ~Texture() {} |
| 61 | 61 |
| 62 private: | 62 private: |
| 63 friend class base::RefCounted<Texture>; | 63 friend class base::RefCounted<Texture>; |
| 64 }; | 64 }; |
| 65 | 65 |
| 66 // An interface to allow the compositor to communicate with its owner. | |
| 67 class COMPOSITOR_EXPORT CompositorOwner { | |
|
sky
2011/09/06 17:39:01
Call this CompositorDelegate
sadrul
2011/09/06 18:13:23
Done.
| |
| 68 public: | |
| 69 // Returns the AcceleratedWidget the compositor should paint onto. | |
| 70 virtual gfx::AcceleratedWidget GetAcceleratedWidget() = 0; | |
|
sky
2011/09/06 17:39:01
I prefer passing this into the constructor rather
sadrul
2011/09/06 18:13:23
Done.
| |
| 71 | |
| 72 // Refreshes the textures. The Compositor calls this after a SchedulePaint. | |
|
sky
2011/09/06 17:39:01
I don't like having yet another paint coalescing c
sadrul
2011/09/06 18:13:23
Sounds like a good plan. Done.
| |
| 73 virtual void PaintNow() = 0; | |
| 74 }; | |
| 75 | |
| 66 // Compositor object to take care of GPU painting. | 76 // Compositor object to take care of GPU painting. |
| 67 // A Browser compositor object is responsible for generating the final | 77 // A Browser compositor object is responsible for generating the final |
| 68 // displayable form of pixels comprising a single widget's contents. It draws an | 78 // displayable form of pixels comprising a single widget's contents. It draws an |
| 69 // appropriately transformed texture for each transformed view in the widget's | 79 // appropriately transformed texture for each transformed view in the widget's |
| 70 // view hierarchy. | 80 // view hierarchy. |
| 71 class COMPOSITOR_EXPORT Compositor : public base::RefCounted<Compositor> { | 81 class COMPOSITOR_EXPORT Compositor : public base::RefCounted<Compositor> { |
| 72 public: | 82 public: |
| 73 // Create a compositor from the provided handle. | 83 // Create a compositor from the provided handle. |
| 74 static Compositor* Create(gfx::AcceleratedWidget widget, | 84 static Compositor* Create(CompositorOwner* owner, |
| 75 const gfx::Size& size); | 85 const gfx::Size& size); |
| 76 | 86 |
| 77 // Creates a new texture. The caller owns the returned object. | 87 // Creates a new texture. The caller owns the returned object. |
| 78 virtual Texture* CreateTexture() = 0; | 88 virtual Texture* CreateTexture() = 0; |
| 79 | 89 |
| 80 // Notifies the compositor that compositing is about to start. | 90 // Notifies the compositor that compositing is about to start. |
| 81 virtual void NotifyStart() = 0; | 91 virtual void NotifyStart() = 0; |
| 82 | 92 |
| 83 // Notifies the compositor that compositing is complete. | 93 // Notifies the compositor that compositing is complete. |
| 84 virtual void NotifyEnd() = 0; | 94 virtual void NotifyEnd() = 0; |
| 85 | 95 |
| 86 // Blurs the specific region in the compositor. | 96 // Blurs the specific region in the compositor. |
| 87 virtual void Blur(const gfx::Rect& bounds) = 0; | 97 virtual void Blur(const gfx::Rect& bounds) = 0; |
| 88 | 98 |
| 89 // Schedules a paint on the widget this Compositor was created for. | 99 // Schedules a paint on the widget this Compositor was created for. |
| 90 virtual void SchedulePaint() = 0; | 100 virtual void SchedulePaint() = 0; |
| 91 | 101 |
| 92 // Notifies the compositor that the size of the widget that it is | 102 // Notifies the compositor that the size of the widget that it is |
| 93 // drawing to has changed. | 103 // drawing to has changed. |
| 94 void WidgetSizeChanged(const gfx::Size& size) { | 104 void WidgetSizeChanged(const gfx::Size& size) { |
| 95 size_ = size; | 105 size_ = size; |
| 96 OnWidgetSizeChanged(); | 106 OnWidgetSizeChanged(); |
| 97 } | 107 } |
| 98 | 108 |
| 99 // Returns the size of the widget that is being drawn to. | 109 // Returns the size of the widget that is being drawn to. |
| 100 const gfx::Size& size() { return size_; } | 110 const gfx::Size& size() { return size_; } |
| 101 | 111 |
| 102 protected: | 112 protected: |
| 103 explicit Compositor(const gfx::Size& size) : size_(size) {} | 113 Compositor(CompositorOwner* owner, const gfx::Size& size) |
| 114 : owner_(owner), | |
| 115 size_(size) {} | |
| 104 virtual ~Compositor() {} | 116 virtual ~Compositor() {} |
| 105 | 117 |
| 106 virtual void OnWidgetSizeChanged() = 0; | 118 virtual void OnWidgetSizeChanged() = 0; |
| 107 | 119 |
| 120 CompositorOwner* owner() { return owner_; } | |
| 121 | |
| 108 private: | 122 private: |
| 123 CompositorOwner* owner_; | |
| 109 gfx::Size size_; | 124 gfx::Size size_; |
| 110 | 125 |
| 111 friend class base::RefCounted<Compositor>; | 126 friend class base::RefCounted<Compositor>; |
| 112 }; | 127 }; |
| 113 | 128 |
| 114 } // namespace ui | 129 } // namespace ui |
| 115 | 130 |
| 116 #endif // UI_GFX_COMPOSITOR_COMPOSITOR_H_ | 131 #endif // UI_GFX_COMPOSITOR_COMPOSITOR_H_ |
| OLD | NEW |