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/native_widget_types.h" | 10 #include "ui/gfx/native_widget_types.h" |
11 | 11 |
12 class SkBitmap; | 12 class SkBitmap; |
13 namespace gfx { | 13 namespace gfx { |
14 class Point; | 14 class Point; |
15 class Rect; | 15 class Rect; |
16 class Size; | 16 class Size; |
17 } | 17 } |
18 | 18 |
19 namespace ui { | 19 namespace ui { |
20 class Transform; | 20 class Transform; |
21 | 21 |
22 #if !defined(COMPOSITOR_2) | |
23 typedef unsigned int TextureID; | |
24 | |
25 // NOTE: all coordinates passed to Texture/Compositor have 0x0 as the upper left | |
26 // corner. | |
27 | |
28 // Compositor object to take care of GPU painting. | |
29 // A Browser compositor object is responsible for generating the final | |
30 // displayable form of pixels comprising a single widget's contents. It draws an | |
31 // appropriately transformed texture for each transformed view in the widget's | |
32 // view hierarchy. The initial implementation uses GL for this purpose. | |
33 // Future CLs will adapt this to ongoing Skia development. | |
34 class Compositor : public base::RefCounted<Compositor> { | |
35 public: | |
36 // Create a compositor from the provided handle. | |
37 static Compositor* Create(gfx::AcceleratedWidget widget); | |
38 | |
39 // Notifies the compositor that compositing is about to start. | |
40 virtual void NotifyStart() = 0; | |
41 | |
42 // Notifies the compositor that compositing is complete. | |
43 virtual void NotifyEnd() = 0; | |
44 | |
45 // Draws the given texture with the given transform. | |
46 virtual void DrawTextureWithTransform(TextureID txt, | |
47 const ui::Transform& transform) = 0; | |
48 | |
49 // Save the current transformation that can be restored with RestoreTransform. | |
50 virtual void SaveTransform() = 0; | |
51 | |
52 // Restore a previously saved transformation using SaveTransform. | |
53 virtual void RestoreTransform() = 0; | |
54 | |
55 protected: | |
56 virtual ~Compositor() {} | |
57 | |
58 private: | |
59 friend class base::RefCounted<Compositor>; | |
60 }; | |
61 | |
62 #else | |
63 // Textures are created by a Compositor for managing an accelerated view. | 22 // Textures are created by a Compositor for managing an accelerated view. |
64 // Any time a View with a texture needs to redraw itself it invokes SetBitmap(). | 23 // Any time a View with a texture needs to redraw itself it invokes SetBitmap(). |
65 // When the view is ready to be drawn Draw() is invoked. | 24 // When the view is ready to be drawn Draw() is invoked. |
66 // | 25 // |
67 // Texture is really a proxy to the gpu. Texture does not itself keep a copy of | 26 // Texture is really a proxy to the gpu. Texture does not itself keep a copy of |
68 // the bitmap. | 27 // the bitmap. |
69 // | 28 // |
70 // Views own the Texture. | 29 // Views own the Texture. |
71 class Texture { | 30 class Texture { |
72 public: | 31 public: |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
104 // Blurs the specific region in the compositor. | 63 // Blurs the specific region in the compositor. |
105 virtual void Blur(const gfx::Rect& bounds) = 0; | 64 virtual void Blur(const gfx::Rect& bounds) = 0; |
106 | 65 |
107 protected: | 66 protected: |
108 virtual ~Compositor() {} | 67 virtual ~Compositor() {} |
109 | 68 |
110 private: | 69 private: |
111 friend class base::RefCounted<Compositor>; | 70 friend class base::RefCounted<Compositor>; |
112 }; | 71 }; |
113 | 72 |
114 #endif // COMPOSITOR_2 | |
115 } // namespace ui | 73 } // namespace ui |
116 | 74 |
117 #endif // UI_GFX_COMPOSITOR_COMPOSITOR_H_ | 75 #endif // UI_GFX_COMPOSITOR_COMPOSITOR_H_ |
OLD | NEW |