Reenable NullOpenerRedirectForksProcess, as the offending patch has been reverted
[chromium-blink-merge.git] / cc / direct_renderer.h
blob716f85824e846de7ec2f80fda86292b7653939b2
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
3 // found in the LICENSE file.
5 #ifndef CC_DIRECT_RENDERER_H_
6 #define CC_DIRECT_RENDERER_H_
8 #include "base/basictypes.h"
9 #include "cc/cc_export.h"
10 #include "cc/renderer.h"
11 #include "cc/resource_provider.h"
12 #include "cc/scoped_resource.h"
14 namespace cc {
16 class ResourceProvider;
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
20 // delegate rendering to another compositor.
21 class CC_EXPORT DirectRenderer : public Renderer {
22 public:
23 virtual ~DirectRenderer();
25 ResourceProvider* resourceProvider() const { return m_resourceProvider; }
27 virtual void decideRenderPassAllocationsForFrame(const RenderPassList& renderPassesInDrawOrder) OVERRIDE;
28 virtual bool haveCachedResourcesForRenderPassId(RenderPass::Id) const OVERRIDE;
29 virtual void drawFrame(const RenderPassList& renderPassesInDrawOrder, const RenderPassIdHashMap& renderPassesById) OVERRIDE;
31 struct CC_EXPORT DrawingFrame {
32 DrawingFrame();
33 ~DrawingFrame();
35 const RenderPassIdHashMap* renderPassesById;
36 const RenderPass* rootRenderPass;
37 const RenderPass* currentRenderPass;
38 const ScopedResource* currentTexture;
40 gfx::RectF rootDamageRect;
42 WebKit::WebTransformationMatrix projectionMatrix;
43 WebKit::WebTransformationMatrix windowMatrix;
44 bool flippedY;
45 gfx::RectF scissorRectInRenderPassSpace;
48 protected:
49 DirectRenderer(RendererClient* client, ResourceProvider* resourceProvider);
51 class CachedResource : public ScopedResource {
52 public:
53 static scoped_ptr<CachedResource> create(ResourceProvider* resourceProvider) {
54 return make_scoped_ptr(new CachedResource(resourceProvider));
56 virtual ~CachedResource() {}
58 bool isComplete() const { return m_isComplete; }
59 void setIsComplete(bool isComplete) { m_isComplete = isComplete; }
61 protected:
62 explicit CachedResource(ResourceProvider* resourceProvider)
63 : ScopedResource(resourceProvider)
64 , m_isComplete(false)
68 private:
69 bool m_isComplete;
71 DISALLOW_COPY_AND_ASSIGN(CachedResource);
74 static gfx::RectF quadVertexRect();
75 static void quadRectTransform(WebKit::WebTransformationMatrix* quadRectTransform, const WebKit::WebTransformationMatrix& quadTransform, const gfx::RectF& quadRect);
76 static void initializeMatrices(DrawingFrame&, const gfx::Rect& drawRect, bool flipY);
77 static gfx::Rect moveScissorToWindowSpace(const DrawingFrame&, gfx::RectF scissorRect);
79 bool haveCachedResources(RenderPass::Id) const;
80 static gfx::Size renderPassTextureSize(const RenderPass*);
81 static GLenum renderPassTextureFormat(const RenderPass*);
83 void drawRenderPass(DrawingFrame&, const RenderPass*);
84 bool useRenderPass(DrawingFrame&, const RenderPass*);
86 virtual void bindFramebufferToOutputSurface(DrawingFrame&) = 0;
87 virtual bool bindFramebufferToTexture(DrawingFrame&, const ScopedResource*, const gfx::Rect& framebufferRect) = 0;
88 virtual void setDrawViewportSize(const gfx::Size&) = 0;
89 virtual void setScissorTestRect(const gfx::Rect& scissorRect) = 0;
90 virtual void clearFramebuffer(DrawingFrame&) = 0;
91 virtual void drawQuad(DrawingFrame&, const DrawQuad*) = 0;
92 virtual void beginDrawingFrame(DrawingFrame&) = 0;
93 virtual void finishDrawingFrame(DrawingFrame&) = 0;
94 virtual bool flippedFramebuffer() const = 0;
96 ScopedPtrHashMap<RenderPass::Id, CachedResource> m_renderPassTextures;
97 ResourceProvider* m_resourceProvider;
99 private:
100 DISALLOW_COPY_AND_ASSIGN(DirectRenderer);
103 } // namespace cc
105 #endif // CC_DIRECT_RENDERER_H_