OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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 CCDirectRenderer_h | 5 #ifndef CCDirectRenderer_h |
6 #define CCDirectRenderer_h | 6 #define CCDirectRenderer_h |
7 | 7 |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "CCRenderer.h" | 9 #include "CCRenderer.h" |
10 #include "CCResourceProvider.h" | 10 #include "CCResourceProvider.h" |
11 #include "CCScopedTexture.h" | 11 #include "CCScopedTexture.h" |
12 | 12 |
13 namespace cc { | 13 namespace cc { |
14 | 14 |
15 class CCResourceProvider; | 15 class ResourceProvider; |
16 | 16 |
17 // This is the base class for code shared between the GL and software | 17 // This is the base class for code shared between the GL and software |
18 // renderer implementations. "Direct" refers to the fact that it does not | 18 // renderer implementations. "Direct" refers to the fact that it does not |
19 // delegate rendering to another compositor. | 19 // delegate rendering to another compositor. |
20 class CCDirectRenderer : public CCRenderer { | 20 class DirectRenderer : public Renderer { |
21 public: | 21 public: |
22 virtual ~CCDirectRenderer(); | 22 virtual ~DirectRenderer(); |
23 | 23 |
24 CCResourceProvider* resourceProvider() const { return m_resourceProvider; } | 24 ResourceProvider* resourceProvider() const { return m_resourceProvider; } |
25 | 25 |
26 virtual void decideRenderPassAllocationsForFrame(const CCRenderPassList& ren
derPassesInDrawOrder) OVERRIDE; | 26 virtual void decideRenderPassAllocationsForFrame(const RenderPassList& rende
rPassesInDrawOrder) OVERRIDE; |
27 virtual bool haveCachedResourcesForRenderPassId(CCRenderPass::Id) const OVER
RIDE; | 27 virtual bool haveCachedResourcesForRenderPassId(RenderPass::Id) const OVERRI
DE; |
28 virtual void drawFrame(const CCRenderPassList& renderPassesInDrawOrder, cons
t CCRenderPassIdHashMap& renderPassesById) OVERRIDE; | 28 virtual void drawFrame(const RenderPassList& renderPassesInDrawOrder, const
RenderPassIdHashMap& renderPassesById) OVERRIDE; |
29 | 29 |
30 protected: | 30 protected: |
31 CCDirectRenderer(CCRendererClient* client, CCResourceProvider* resourceProvi
der); | 31 DirectRenderer(RendererClient* client, ResourceProvider* resourceProvider); |
32 | 32 |
33 struct DrawingFrame { | 33 struct DrawingFrame { |
34 DrawingFrame(); | 34 DrawingFrame(); |
35 ~DrawingFrame(); | 35 ~DrawingFrame(); |
36 | 36 |
37 const CCRenderPassIdHashMap* renderPassesById; | 37 const RenderPassIdHashMap* renderPassesById; |
38 const CCRenderPass* rootRenderPass; | 38 const RenderPass* rootRenderPass; |
39 const CCRenderPass* currentRenderPass; | 39 const RenderPass* currentRenderPass; |
40 const CCScopedTexture* currentTexture; | 40 const ScopedTexture* currentTexture; |
41 | 41 |
42 FloatRect rootDamageRect; | 42 FloatRect rootDamageRect; |
43 | 43 |
44 WebKit::WebTransformationMatrix projectionMatrix; | 44 WebKit::WebTransformationMatrix projectionMatrix; |
45 WebKit::WebTransformationMatrix windowMatrix; | 45 WebKit::WebTransformationMatrix windowMatrix; |
46 bool flippedY; | 46 bool flippedY; |
47 FloatRect scissorRectInRenderPassSpace; | 47 FloatRect scissorRectInRenderPassSpace; |
48 }; | 48 }; |
49 | 49 |
50 class CachedTexture : public CCScopedTexture { | 50 class CachedTexture : public ScopedTexture { |
51 public: | 51 public: |
52 static scoped_ptr<CachedTexture> create(CCResourceProvider* resourceProv
ider) { | 52 static scoped_ptr<CachedTexture> create(ResourceProvider* resourceProvid
er) { |
53 return make_scoped_ptr(new CachedTexture(resourceProvider)); | 53 return make_scoped_ptr(new CachedTexture(resourceProvider)); |
54 } | 54 } |
55 virtual ~CachedTexture() {} | 55 virtual ~CachedTexture() {} |
56 | 56 |
57 bool isComplete() const { return m_isComplete; } | 57 bool isComplete() const { return m_isComplete; } |
58 void setIsComplete(bool isComplete) { m_isComplete = isComplete; } | 58 void setIsComplete(bool isComplete) { m_isComplete = isComplete; } |
59 | 59 |
60 protected: | 60 protected: |
61 explicit CachedTexture(CCResourceProvider* resourceProvider) | 61 explicit CachedTexture(ResourceProvider* resourceProvider) |
62 : CCScopedTexture(resourceProvider) | 62 : ScopedTexture(resourceProvider) |
63 , m_isComplete(false) | 63 , m_isComplete(false) |
64 { | 64 { |
65 } | 65 } |
66 | 66 |
67 private: | 67 private: |
68 bool m_isComplete; | 68 bool m_isComplete; |
69 | 69 |
70 DISALLOW_COPY_AND_ASSIGN(CachedTexture); | 70 DISALLOW_COPY_AND_ASSIGN(CachedTexture); |
71 }; | 71 }; |
72 | 72 |
73 static FloatRect quadVertexRect(); | 73 static FloatRect quadVertexRect(); |
74 static void quadRectTransform(WebKit::WebTransformationMatrix* quadRectTrans
form, const WebKit::WebTransformationMatrix& quadTransform, const FloatRect& qua
dRect); | 74 static void quadRectTransform(WebKit::WebTransformationMatrix* quadRectTrans
form, const WebKit::WebTransformationMatrix& quadTransform, const FloatRect& qua
dRect); |
75 static void initializeMatrices(DrawingFrame&, const IntRect& drawRect, bool
flipY); | 75 static void initializeMatrices(DrawingFrame&, const IntRect& drawRect, bool
flipY); |
76 static IntRect moveScissorToWindowSpace(const DrawingFrame&, FloatRect sciss
orRect); | 76 static IntRect moveScissorToWindowSpace(const DrawingFrame&, FloatRect sciss
orRect); |
77 | 77 |
78 bool haveCachedResources(CCRenderPass::Id) const; | 78 bool haveCachedResources(RenderPass::Id) const; |
79 static IntSize renderPassTextureSize(const CCRenderPass*); | 79 static IntSize renderPassTextureSize(const RenderPass*); |
80 static GC3Denum renderPassTextureFormat(const CCRenderPass*); | 80 static GC3Denum renderPassTextureFormat(const RenderPass*); |
81 | 81 |
82 void drawRenderPass(DrawingFrame&, const CCRenderPass*); | 82 void drawRenderPass(DrawingFrame&, const RenderPass*); |
83 bool useRenderPass(DrawingFrame&, const CCRenderPass*); | 83 bool useRenderPass(DrawingFrame&, const RenderPass*); |
84 | 84 |
85 virtual void bindFramebufferToOutputSurface(DrawingFrame&) = 0; | 85 virtual void bindFramebufferToOutputSurface(DrawingFrame&) = 0; |
86 virtual bool bindFramebufferToTexture(DrawingFrame&, const CCScopedTexture*,
const IntRect& framebufferRect) = 0; | 86 virtual bool bindFramebufferToTexture(DrawingFrame&, const ScopedTexture*, c
onst IntRect& framebufferRect) = 0; |
87 virtual void setDrawViewportSize(const IntSize&) = 0; | 87 virtual void setDrawViewportSize(const IntSize&) = 0; |
88 virtual void enableScissorTestRect(const IntRect& scissorRect) = 0; | 88 virtual void enableScissorTestRect(const IntRect& scissorRect) = 0; |
89 virtual void disableScissorTest() = 0; | 89 virtual void disableScissorTest() = 0; |
90 virtual void clearFramebuffer(DrawingFrame&) = 0; | 90 virtual void clearFramebuffer(DrawingFrame&) = 0; |
91 virtual void drawQuad(DrawingFrame&, const CCDrawQuad*) = 0; | 91 virtual void drawQuad(DrawingFrame&, const DrawQuad*) = 0; |
92 virtual void beginDrawingFrame(DrawingFrame&) = 0; | 92 virtual void beginDrawingFrame(DrawingFrame&) = 0; |
93 virtual void finishDrawingFrame(DrawingFrame&) = 0; | 93 virtual void finishDrawingFrame(DrawingFrame&) = 0; |
94 virtual bool flippedFramebuffer() const = 0; | 94 virtual bool flippedFramebuffer() const = 0; |
95 | 95 |
96 ScopedPtrHashMap<CCRenderPass::Id, CachedTexture> m_renderPassTextures; | 96 ScopedPtrHashMap<RenderPass::Id, CachedTexture> m_renderPassTextures; |
97 CCResourceProvider* m_resourceProvider; | 97 ResourceProvider* m_resourceProvider; |
98 | 98 |
99 private: | 99 private: |
100 DISALLOW_COPY_AND_ASSIGN(CCDirectRenderer); | 100 DISALLOW_COPY_AND_ASSIGN(DirectRenderer); |
101 }; | 101 }; |
102 | 102 |
103 } // namespace cc | 103 } // namespace cc |
104 | 104 |
105 #endif // CCDirectRenderer_h | 105 #endif // CCDirectRenderer_h |
OLD | NEW |