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_SOFTWARE_RENDERER_H_
6 #define CC_SOFTWARE_RENDERER_H_
8 #include "base/basictypes.h"
9 #include "cc/cc_export.h"
10 #include "cc/direct_renderer.h"
14 class DebugBorderDrawQuad
;
16 class RenderPassDrawQuad
;
17 class ResourceProvider
;
18 class SoftwareOutputDevice
;
19 class SolidColorDrawQuad
;
20 class TextureDrawQuad
;
23 class CC_EXPORT SoftwareRenderer
: public DirectRenderer
{
25 static scoped_ptr
<SoftwareRenderer
> create(RendererClient
*, ResourceProvider
*, SoftwareOutputDevice
*);
26 virtual ~SoftwareRenderer();
28 virtual const RendererCapabilities
& capabilities() const OVERRIDE
;
30 virtual void viewportChanged() OVERRIDE
;
32 virtual void finish() OVERRIDE
;
34 virtual bool swapBuffers() OVERRIDE
;
36 virtual void getFramebufferPixels(void *pixels
, const gfx::Rect
&) OVERRIDE
;
38 virtual void setVisible(bool) OVERRIDE
;
40 virtual void sendManagedMemoryStats(size_t bytesVisible
, size_t bytesVisibleAndNearby
, size_t bytesAllocated
) OVERRIDE
{ }
43 virtual void bindFramebufferToOutputSurface(DrawingFrame
&) OVERRIDE
;
44 virtual bool bindFramebufferToTexture(DrawingFrame
&, const ScopedResource
*, const gfx::Rect
& framebufferRect
) OVERRIDE
;
45 virtual void setDrawViewportSize(const gfx::Size
&) OVERRIDE
;
46 virtual void setScissorTestRect(const gfx::Rect
& scissorRect
) OVERRIDE
;
47 virtual void clearFramebuffer(DrawingFrame
&) OVERRIDE
;
48 virtual void drawQuad(DrawingFrame
&, const DrawQuad
*) OVERRIDE
;
49 virtual void beginDrawingFrame(DrawingFrame
&) OVERRIDE
;
50 virtual void finishDrawingFrame(DrawingFrame
&) OVERRIDE
;
51 virtual bool flippedFramebuffer() const OVERRIDE
;
52 virtual void ensureScissorTestEnabled() OVERRIDE
;
53 virtual void ensureScissorTestDisabled() OVERRIDE
;
56 SoftwareRenderer(RendererClient
*, ResourceProvider
*, SoftwareOutputDevice
*);
58 bool isSoftwareResource(ResourceProvider::ResourceId
) const;
60 void drawDebugBorderQuad(const DrawingFrame
&, const DebugBorderDrawQuad
*);
61 void drawSolidColorQuad(const DrawingFrame
&, const SolidColorDrawQuad
*);
62 void drawTextureQuad(const DrawingFrame
&, const TextureDrawQuad
*);
63 void drawTileQuad(const DrawingFrame
&, const TileDrawQuad
*);
64 void drawRenderPassQuad(const DrawingFrame
& frame
, const RenderPassDrawQuad
*);
65 void drawUnsupportedQuad(const DrawingFrame
&, const DrawQuad
*);
67 RendererCapabilities m_capabilities
;
70 SoftwareOutputDevice
* m_outputDevice
;
71 scoped_ptr
<SkCanvas
> m_skRootCanvas
;
72 SkCanvas
* m_skCurrentCanvas
;
73 SkPaint m_skCurrentPaint
;
74 scoped_ptr
<ResourceProvider::ScopedWriteLockSoftware
> m_currentFramebufferLock
;
76 DISALLOW_COPY_AND_ASSIGN(SoftwareRenderer
);
81 #endif // CC_SOFTWARE_RENDERER_H_