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 CC_DIRECT_RENDERER_H_ | 5 #ifndef CC_DIRECT_RENDERER_H_ |
6 #define CC_DIRECT_RENDERER_H_ | 6 #define CC_DIRECT_RENDERER_H_ |
7 | 7 |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "cc/cc_export.h" | 9 #include "cc/cc_export.h" |
10 #include "cc/renderer.h" | 10 #include "cc/renderer.h" |
11 #include "cc/resource_provider.h" | 11 #include "cc/resource_provider.h" |
12 #include "cc/scoped_texture.h" | 12 #include "cc/scoped_resource.h" |
13 | 13 |
14 namespace cc { | 14 namespace cc { |
15 | 15 |
16 class ResourceProvider; | 16 class ResourceProvider; |
17 | 17 |
18 // This is the base class for code shared between the GL and software | 18 // This is the base class for code shared between the GL and software |
19 // renderer implementations. "Direct" refers to the fact that it does not | 19 // renderer implementations. "Direct" refers to the fact that it does not |
20 // delegate rendering to another compositor. | 20 // delegate rendering to another compositor. |
21 class CC_EXPORT DirectRenderer : public Renderer { | 21 class CC_EXPORT DirectRenderer : public Renderer { |
22 public: | 22 public: |
23 virtual ~DirectRenderer(); | 23 virtual ~DirectRenderer(); |
24 | 24 |
25 ResourceProvider* resourceProvider() const { return m_resourceProvider; } | 25 ResourceProvider* resourceProvider() const { return m_resourceProvider; } |
26 | 26 |
27 virtual void decideRenderPassAllocationsForFrame(const RenderPassList& rende
rPassesInDrawOrder) OVERRIDE; | 27 virtual void decideRenderPassAllocationsForFrame(const RenderPassList& rende
rPassesInDrawOrder) OVERRIDE; |
28 virtual bool haveCachedResourcesForRenderPassId(RenderPass::Id) const OVERRI
DE; | 28 virtual bool haveCachedResourcesForRenderPassId(RenderPass::Id) const OVERRI
DE; |
29 virtual void drawFrame(const RenderPassList& renderPassesInDrawOrder, const
RenderPassIdHashMap& renderPassesById) OVERRIDE; | 29 virtual void drawFrame(const RenderPassList& renderPassesInDrawOrder, const
RenderPassIdHashMap& renderPassesById) OVERRIDE; |
30 | 30 |
31 protected: | 31 protected: |
32 DirectRenderer(RendererClient* client, ResourceProvider* resourceProvider); | 32 DirectRenderer(RendererClient* client, ResourceProvider* resourceProvider); |
33 | 33 |
34 struct DrawingFrame { | 34 struct DrawingFrame { |
35 DrawingFrame(); | 35 DrawingFrame(); |
36 ~DrawingFrame(); | 36 ~DrawingFrame(); |
37 | 37 |
38 const RenderPassIdHashMap* renderPassesById; | 38 const RenderPassIdHashMap* renderPassesById; |
39 const RenderPass* rootRenderPass; | 39 const RenderPass* rootRenderPass; |
40 const RenderPass* currentRenderPass; | 40 const RenderPass* currentRenderPass; |
41 const ScopedTexture* currentTexture; | 41 const ScopedResource* currentTexture; |
42 | 42 |
43 gfx::RectF rootDamageRect; | 43 gfx::RectF rootDamageRect; |
44 | 44 |
45 WebKit::WebTransformationMatrix projectionMatrix; | 45 WebKit::WebTransformationMatrix projectionMatrix; |
46 WebKit::WebTransformationMatrix windowMatrix; | 46 WebKit::WebTransformationMatrix windowMatrix; |
47 bool flippedY; | 47 bool flippedY; |
48 gfx::RectF scissorRectInRenderPassSpace; | 48 gfx::RectF scissorRectInRenderPassSpace; |
49 }; | 49 }; |
50 | 50 |
51 class CachedTexture : public ScopedTexture { | 51 class CachedResource : public ScopedResource { |
52 public: | 52 public: |
53 static scoped_ptr<CachedTexture> create(ResourceProvider* resourceProvid
er) { | 53 static scoped_ptr<CachedResource> create(ResourceProvider* resourceProvi
der) { |
54 return make_scoped_ptr(new CachedTexture(resourceProvider)); | 54 return make_scoped_ptr(new CachedResource(resourceProvider)); |
55 } | 55 } |
56 virtual ~CachedTexture() {} | 56 virtual ~CachedResource() {} |
57 | 57 |
58 bool isComplete() const { return m_isComplete; } | 58 bool isComplete() const { return m_isComplete; } |
59 void setIsComplete(bool isComplete) { m_isComplete = isComplete; } | 59 void setIsComplete(bool isComplete) { m_isComplete = isComplete; } |
60 | 60 |
61 protected: | 61 protected: |
62 explicit CachedTexture(ResourceProvider* resourceProvider) | 62 explicit CachedResource(ResourceProvider* resourceProvider) |
63 : ScopedTexture(resourceProvider) | 63 : ScopedResource(resourceProvider) |
64 , m_isComplete(false) | 64 , m_isComplete(false) |
65 { | 65 { |
66 } | 66 } |
67 | 67 |
68 private: | 68 private: |
69 bool m_isComplete; | 69 bool m_isComplete; |
70 | 70 |
71 DISALLOW_COPY_AND_ASSIGN(CachedTexture); | 71 DISALLOW_COPY_AND_ASSIGN(CachedResource); |
72 }; | 72 }; |
73 | 73 |
74 static gfx::RectF quadVertexRect(); | 74 static gfx::RectF quadVertexRect(); |
75 static void quadRectTransform(WebKit::WebTransformationMatrix* quadRectTrans
form, const WebKit::WebTransformationMatrix& quadTransform, const gfx::RectF& qu
adRect); | 75 static void quadRectTransform(WebKit::WebTransformationMatrix* quadRectTrans
form, const WebKit::WebTransformationMatrix& quadTransform, const gfx::RectF& qu
adRect); |
76 static void initializeMatrices(DrawingFrame&, const gfx::Rect& drawRect, boo
l flipY); | 76 static void initializeMatrices(DrawingFrame&, const gfx::Rect& drawRect, boo
l flipY); |
77 static gfx::Rect moveScissorToWindowSpace(const DrawingFrame&, gfx::RectF sc
issorRect); | 77 static gfx::Rect moveScissorToWindowSpace(const DrawingFrame&, gfx::RectF sc
issorRect); |
78 | 78 |
79 bool haveCachedResources(RenderPass::Id) const; | 79 bool haveCachedResources(RenderPass::Id) const; |
80 static gfx::Size renderPassTextureSize(const RenderPass*); | 80 static gfx::Size renderPassTextureSize(const RenderPass*); |
81 static GLenum renderPassTextureFormat(const RenderPass*); | 81 static GLenum renderPassTextureFormat(const RenderPass*); |
82 | 82 |
83 void drawRenderPass(DrawingFrame&, const RenderPass*); | 83 void drawRenderPass(DrawingFrame&, const RenderPass*); |
84 bool useRenderPass(DrawingFrame&, const RenderPass*); | 84 bool useRenderPass(DrawingFrame&, const RenderPass*); |
85 | 85 |
86 virtual void bindFramebufferToOutputSurface(DrawingFrame&) = 0; | 86 virtual void bindFramebufferToOutputSurface(DrawingFrame&) = 0; |
87 virtual bool bindFramebufferToTexture(DrawingFrame&, const ScopedTexture*, c
onst gfx::Rect& framebufferRect) = 0; | 87 virtual bool bindFramebufferToTexture(DrawingFrame&, const ScopedResource*,
const gfx::Rect& framebufferRect) = 0; |
88 virtual void setDrawViewportSize(const gfx::Size&) = 0; | 88 virtual void setDrawViewportSize(const gfx::Size&) = 0; |
89 virtual void setScissorTestRect(const gfx::Rect& scissorRect) = 0; | 89 virtual void setScissorTestRect(const gfx::Rect& scissorRect) = 0; |
90 virtual void clearFramebuffer(DrawingFrame&) = 0; | 90 virtual void clearFramebuffer(DrawingFrame&) = 0; |
91 virtual void drawQuad(DrawingFrame&, const DrawQuad*) = 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<RenderPass::Id, CachedTexture> m_renderPassTextures; | 96 ScopedPtrHashMap<RenderPass::Id, CachedResource> m_renderPassTextures; |
97 ResourceProvider* m_resourceProvider; | 97 ResourceProvider* m_resourceProvider; |
98 | 98 |
99 private: | 99 private: |
100 DISALLOW_COPY_AND_ASSIGN(DirectRenderer); | 100 DISALLOW_COPY_AND_ASSIGN(DirectRenderer); |
101 }; | 101 }; |
102 | 102 |
103 } // namespace cc | 103 } // namespace cc |
104 | 104 |
105 #endif // CC_DIRECT_RENDERER_H_ | 105 #endif // CC_DIRECT_RENDERER_H_ |
OLD | NEW |