| 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/transform.h" | 11 #include "ui/gfx/transform.h" |
| 11 #include "ui/gfx/native_widget_types.h" | 12 #include "ui/gfx/native_widget_types.h" |
| 12 | 13 |
| 13 class SkCanvas; | 14 class SkCanvas; |
| 14 namespace gfx { | 15 namespace gfx { |
| 15 class Point; | 16 class Point; |
| 16 class Rect; | 17 class Rect; |
| 17 class Size; | 18 class Size; |
| 18 } | 19 } |
| 19 | 20 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 33 }; | 34 }; |
| 34 | 35 |
| 35 // Textures are created by a Compositor for managing an accelerated view. | 36 // Textures are created by a Compositor for managing an accelerated view. |
| 36 // Any time a View with a texture needs to redraw itself it invokes SetCanvas(). | 37 // Any time a View with a texture needs to redraw itself it invokes SetCanvas(). |
| 37 // When the view is ready to be drawn Draw() is invoked. | 38 // When the view is ready to be drawn Draw() is invoked. |
| 38 // | 39 // |
| 39 // Texture is really a proxy to the gpu. Texture does not itself keep a copy of | 40 // Texture is really a proxy to the gpu. Texture does not itself keep a copy of |
| 40 // the bitmap. | 41 // the bitmap. |
| 41 // | 42 // |
| 42 // Views own the Texture. | 43 // Views own the Texture. |
| 43 class Texture : public base::RefCounted<Texture> { | 44 class COMPOSITOR_EXPORT Texture : public base::RefCounted<Texture> { |
| 44 public: | 45 public: |
| 45 // Sets the canvas of this texture. The origin is at |origin|. | 46 // Sets the canvas of this texture. The origin is at |origin|. |
| 46 // |overall_size| gives the total size of texture. | 47 // |overall_size| gives the total size of texture. |
| 47 virtual void SetCanvas(const SkCanvas& canvas, | 48 virtual void SetCanvas(const SkCanvas& canvas, |
| 48 const gfx::Point& origin, | 49 const gfx::Point& origin, |
| 49 const gfx::Size& overall_size) = 0; | 50 const gfx::Size& overall_size) = 0; |
| 50 | 51 |
| 51 // Draws the texture. | 52 // Draws the texture. |
| 52 virtual void Draw(const ui::TextureDrawParams& params) = 0; | 53 virtual void Draw(const ui::TextureDrawParams& params) = 0; |
| 53 | 54 |
| 54 // Draws the portion of the texture contained within clip_bounds | 55 // Draws the portion of the texture contained within clip_bounds |
| 55 virtual void Draw(const ui::TextureDrawParams& params, | 56 virtual void Draw(const ui::TextureDrawParams& params, |
| 56 const gfx::Rect& clip_bounds_in_texture) = 0; | 57 const gfx::Rect& clip_bounds_in_texture) = 0; |
| 57 | 58 |
| 58 protected: | 59 protected: |
| 59 virtual ~Texture() {} | 60 virtual ~Texture() {} |
| 60 | 61 |
| 61 private: | 62 private: |
| 62 friend class base::RefCounted<Texture>; | 63 friend class base::RefCounted<Texture>; |
| 63 }; | 64 }; |
| 64 | 65 |
| 65 // Compositor object to take care of GPU painting. | 66 // Compositor object to take care of GPU painting. |
| 66 // A Browser compositor object is responsible for generating the final | 67 // A Browser compositor object is responsible for generating the final |
| 67 // displayable form of pixels comprising a single widget's contents. It draws an | 68 // displayable form of pixels comprising a single widget's contents. It draws an |
| 68 // appropriately transformed texture for each transformed view in the widget's | 69 // appropriately transformed texture for each transformed view in the widget's |
| 69 // view hierarchy. | 70 // view hierarchy. |
| 70 class Compositor : public base::RefCounted<Compositor> { | 71 class COMPOSITOR_EXPORT Compositor : public base::RefCounted<Compositor> { |
| 71 public: | 72 public: |
| 72 // Create a compositor from the provided handle. | 73 // Create a compositor from the provided handle. |
| 73 static Compositor* Create(gfx::AcceleratedWidget widget, | 74 static Compositor* Create(gfx::AcceleratedWidget widget, |
| 74 const gfx::Size& size); | 75 const gfx::Size& size); |
| 75 | 76 |
| 76 // Creates a new texture. The caller owns the returned object. | 77 // Creates a new texture. The caller owns the returned object. |
| 77 virtual Texture* CreateTexture() = 0; | 78 virtual Texture* CreateTexture() = 0; |
| 78 | 79 |
| 79 // Notifies the compositor that compositing is about to start. | 80 // Notifies the compositor that compositing is about to start. |
| 80 virtual void NotifyStart() = 0; | 81 virtual void NotifyStart() = 0; |
| (...skipping 14 matching lines...) Expand all Loading... |
| 95 protected: | 96 protected: |
| 96 virtual ~Compositor() {} | 97 virtual ~Compositor() {} |
| 97 | 98 |
| 98 private: | 99 private: |
| 99 friend class base::RefCounted<Compositor>; | 100 friend class base::RefCounted<Compositor>; |
| 100 }; | 101 }; |
| 101 | 102 |
| 102 } // namespace ui | 103 } // namespace ui |
| 103 | 104 |
| 104 #endif // UI_GFX_COMPOSITOR_COMPOSITOR_H_ | 105 #endif // UI_GFX_COMPOSITOR_COMPOSITOR_H_ |
| OLD | NEW |