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" |
11 #include "ui/gfx/transform.h" | 11 #include "ui/gfx/transform.h" |
12 #include "ui/gfx/native_widget_types.h" | 12 #include "ui/gfx/native_widget_types.h" |
| 13 #include "ui/gfx/size.h" |
13 | 14 |
14 class SkCanvas; | 15 class SkCanvas; |
15 namespace gfx { | 16 namespace gfx { |
16 class Point; | 17 class Point; |
17 class Rect; | 18 class Rect; |
18 class Size; | |
19 } | 19 } |
20 | 20 |
21 namespace ui { | 21 namespace ui { |
22 | 22 |
23 struct TextureDrawParams { | 23 struct TextureDrawParams { |
24 TextureDrawParams() : transform(), blend(false) {} | 24 TextureDrawParams() : transform(), blend(false), compositor_size() {} |
25 | 25 |
26 // The transform to be applied to the texture. | 26 // The transform to be applied to the texture. |
27 ui::Transform transform; | 27 ui::Transform transform; |
28 | 28 |
29 // If this is true, then the texture is blended with the pixels behind it. | 29 // If this is true, then the texture is blended with the pixels behind it. |
30 // Otherwise, the drawn pixels clobber the old pixels. | 30 // Otherwise, the drawn pixels clobber the old pixels. |
31 bool blend; | 31 bool blend; |
32 | 32 |
| 33 // The size of the surface that the texture is drawn to. |
| 34 gfx::Size compositor_size; |
| 35 |
33 // Copy and assignment are allowed. | 36 // Copy and assignment are allowed. |
34 }; | 37 }; |
35 | 38 |
36 // Textures are created by a Compositor for managing an accelerated view. | 39 // Textures are created by a Compositor for managing an accelerated view. |
37 // Any time a View with a texture needs to redraw itself it invokes SetCanvas(). | 40 // Any time a View with a texture needs to redraw itself it invokes SetCanvas(). |
38 // When the view is ready to be drawn Draw() is invoked. | 41 // When the view is ready to be drawn Draw() is invoked. |
39 // | 42 // |
40 // Texture is really a proxy to the gpu. Texture does not itself keep a copy of | 43 // Texture is really a proxy to the gpu. Texture does not itself keep a copy of |
41 // the bitmap. | 44 // the bitmap. |
42 // | 45 // |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
84 virtual void NotifyEnd() = 0; | 87 virtual void NotifyEnd() = 0; |
85 | 88 |
86 // Blurs the specific region in the compositor. | 89 // Blurs the specific region in the compositor. |
87 virtual void Blur(const gfx::Rect& bounds) = 0; | 90 virtual void Blur(const gfx::Rect& bounds) = 0; |
88 | 91 |
89 // Schedules a paint on the widget this Compositor was created for. | 92 // Schedules a paint on the widget this Compositor was created for. |
90 virtual void SchedulePaint() = 0; | 93 virtual void SchedulePaint() = 0; |
91 | 94 |
92 // Notifies the compositor that the size of the widget that it is | 95 // Notifies the compositor that the size of the widget that it is |
93 // drawing to has changed. | 96 // drawing to has changed. |
94 virtual void OnWidgetSizeChanged(const gfx::Size& size) = 0; | 97 void WidgetSizeChanged(const gfx::Size& size) { |
| 98 size_ = size; |
| 99 OnWidgetSizeChanged(); |
| 100 } |
| 101 |
| 102 // Returns the size of the widget that is being drawn to. |
| 103 const gfx::Size& size() { return size_; } |
95 | 104 |
96 protected: | 105 protected: |
| 106 explicit Compositor(const gfx::Size& size) : size_(size) {} |
97 virtual ~Compositor() {} | 107 virtual ~Compositor() {} |
98 | 108 |
| 109 virtual void OnWidgetSizeChanged() = 0; |
| 110 |
99 private: | 111 private: |
| 112 gfx::Size size_; |
| 113 |
100 friend class base::RefCounted<Compositor>; | 114 friend class base::RefCounted<Compositor>; |
101 }; | 115 }; |
102 | 116 |
103 } // namespace ui | 117 } // namespace ui |
104 | 118 |
105 #endif // UI_GFX_COMPOSITOR_COMPOSITOR_H_ | 119 #endif // UI_GFX_COMPOSITOR_COMPOSITOR_H_ |
OLD | NEW |