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_GL_H_ | 5 #ifndef UI_GFX_COMPOSITOR_COMPOSITOR_GL_H_ |
6 #define UI_GFX_COMPOSITOR_COMPOSITOR_GL_H_ | 6 #define UI_GFX_COMPOSITOR_COMPOSITOR_GL_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
11 #include "base/memory/singleton.h" | 11 #include "base/memory/singleton.h" |
12 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
13 #include "ui/gfx/compositor/compositor.h" | 13 #include "ui/gfx/compositor/compositor.h" |
14 #include "ui/gfx/size.h" | 14 #include "ui/gfx/size.h" |
15 | 15 |
16 namespace gfx { | 16 namespace gfx { |
17 class GLContext; | 17 class GLContext; |
18 class GLSurface; | 18 class GLSurface; |
19 class Rect; | 19 class Rect; |
20 } | 20 } |
21 | 21 |
22 namespace ui { | 22 namespace ui { |
23 | 23 |
24 class CompositorGL; | 24 class CompositorGL; |
25 class TextureProgramGL; | 25 class TextureProgramGL; |
26 | 26 |
27 // We share resources (such as shaders) between different Compositors via | 27 // We share resources (such as shaders) between different Compositors via |
28 // GLContext sharing so that we only have to create/destroy them once. | 28 // GLContext sharing so that we only have to create/destroy them once. |
29 class COMPOSITOR_EXPORT SharedResources { | 29 class COMPOSITOR_EXPORT SharedResourcesGL : public SharedResources { |
30 public: | 30 public: |
31 static SharedResources* GetInstance(); | 31 static SharedResourcesGL* GetInstance(); |
32 | 32 |
33 bool MakeSharedContextCurrent(); | 33 virtual bool MakeSharedContextCurrent(); |
34 | 34 |
35 // Creates a context that shares the resources hosted by this singleton. | 35 // Creates a context that shares the resources hosted by this singleton. |
36 scoped_refptr<gfx::GLContext> CreateContext(gfx::GLSurface* surface); | 36 scoped_refptr<gfx::GLContext> CreateContext(gfx::GLSurface* surface); |
37 | 37 |
38 ui::TextureProgramGL* program_no_swizzle() { | 38 ui::TextureProgramGL* program_no_swizzle() { |
39 return program_no_swizzle_.get(); | 39 return program_no_swizzle_.get(); |
40 } | 40 } |
41 | 41 |
42 ui::TextureProgramGL* program_swizzle() { | 42 ui::TextureProgramGL* program_swizzle() { |
43 return program_swizzle_.get(); | 43 return program_swizzle_.get(); |
44 } | 44 } |
45 | 45 |
46 private: | 46 private: |
47 friend struct DefaultSingletonTraits<SharedResources>; | 47 friend struct DefaultSingletonTraits<SharedResourcesGL>; |
48 | 48 |
49 SharedResources(); | 49 SharedResourcesGL(); |
50 virtual ~SharedResources(); | 50 virtual ~SharedResourcesGL(); |
51 | 51 |
52 bool Initialize(); | 52 bool Initialize(); |
53 void Destroy(); | 53 void Destroy(); |
54 | 54 |
55 bool initialized_; | 55 bool initialized_; |
56 | 56 |
57 scoped_refptr<gfx::GLContext> context_; | 57 scoped_refptr<gfx::GLContext> context_; |
58 scoped_refptr<gfx::GLSurface> surface_; | 58 scoped_refptr<gfx::GLSurface> surface_; |
59 | 59 |
60 scoped_ptr<ui::TextureProgramGL> program_swizzle_; | 60 scoped_ptr<ui::TextureProgramGL> program_swizzle_; |
61 scoped_ptr<ui::TextureProgramGL> program_no_swizzle_; | 61 scoped_ptr<ui::TextureProgramGL> program_no_swizzle_; |
62 | 62 |
63 DISALLOW_COPY_AND_ASSIGN(SharedResources); | 63 DISALLOW_COPY_AND_ASSIGN(SharedResourcesGL); |
64 }; | 64 }; |
65 | 65 |
66 class COMPOSITOR_EXPORT TextureGL : public Texture { | 66 class COMPOSITOR_EXPORT TextureGL : public Texture { |
67 public: | 67 public: |
68 TextureGL(); | 68 TextureGL(); |
69 | 69 |
70 virtual void SetCanvas(const SkCanvas& canvas, | 70 virtual void SetCanvas(const SkCanvas& canvas, |
71 const gfx::Point& origin, | 71 const gfx::Point& origin, |
72 const gfx::Size& overall_size) OVERRIDE; | 72 const gfx::Size& overall_size) OVERRIDE; |
73 | 73 |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
117 | 117 |
118 // Keep track of whether compositing has started or not. | 118 // Keep track of whether compositing has started or not. |
119 bool started_; | 119 bool started_; |
120 | 120 |
121 DISALLOW_COPY_AND_ASSIGN(CompositorGL); | 121 DISALLOW_COPY_AND_ASSIGN(CompositorGL); |
122 }; | 122 }; |
123 | 123 |
124 } // namespace ui | 124 } // namespace ui |
125 | 125 |
126 #endif // UI_GFX_COMPOSITOR_COMPOSITOR_GL_H_ | 126 #endif // UI_GFX_COMPOSITOR_COMPOSITOR_GL_H_ |
OLD | NEW |