Fix build break
[chromium-blink-merge.git] / cc / output / software_renderer.h
blob84e73769cec2d19bc15dc1693fa29c69d166684c
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_OUTPUT_SOFTWARE_RENDERER_H_
6 #define CC_OUTPUT_SOFTWARE_RENDERER_H_
8 #include "base/basictypes.h"
9 #include "cc/base/cc_export.h"
10 #include "cc/output/compositor_frame.h"
11 #include "cc/output/direct_renderer.h"
13 namespace cc {
15 class OutputSurface;
16 class SoftwareOutputDevice;
17 class DebugBorderDrawQuad;
18 class RendererClient;
19 class RenderPassDrawQuad;
20 class ResourceProvider;
21 class SolidColorDrawQuad;
22 class TextureDrawQuad;
23 class TileDrawQuad;
25 class CC_EXPORT SoftwareRenderer : public DirectRenderer {
26 public:
27 static scoped_ptr<SoftwareRenderer> Create(
28 RendererClient* client,
29 OutputSurface* output_surface,
30 ResourceProvider* resource_provider);
32 virtual ~SoftwareRenderer();
33 virtual const RendererCapabilities& Capabilities() const OVERRIDE;
34 virtual void ViewportChanged() OVERRIDE;
35 virtual void Finish() OVERRIDE;
36 virtual bool SwapBuffers() OVERRIDE;
37 virtual void GetFramebufferPixels(void* pixels, gfx::Rect rect) OVERRIDE;
38 virtual void SetVisible(bool visible) OVERRIDE;
39 virtual void SendManagedMemoryStats(
40 size_t bytes_visible,
41 size_t bytes_visible_and_nearby,
42 size_t bytes_allocated) OVERRIDE {}
43 virtual void ReceiveCompositorFrameAck(
44 const CompositorFrameAck& ack) OVERRIDE;
46 protected:
47 virtual void BindFramebufferToOutputSurface(DrawingFrame* frame) OVERRIDE;
48 virtual bool BindFramebufferToTexture(
49 DrawingFrame* frame,
50 const ScopedResource* texture,
51 gfx::Rect framebuffer_rect) OVERRIDE;
52 virtual void SetDrawViewportSize(gfx::Size viewport_size) OVERRIDE;
53 virtual void SetScissorTestRect(gfx::Rect scissor_rect) OVERRIDE;
54 virtual void ClearFramebuffer(DrawingFrame* frame) OVERRIDE;
55 virtual void DoDrawQuad(DrawingFrame* frame, const DrawQuad* quad) OVERRIDE;
56 virtual void BeginDrawingFrame(DrawingFrame* frame) OVERRIDE;
57 virtual void FinishDrawingFrame(DrawingFrame* frame) OVERRIDE;
58 virtual bool FlippedFramebuffer() const OVERRIDE;
59 virtual void EnsureScissorTestEnabled() OVERRIDE;
60 virtual void EnsureScissorTestDisabled() OVERRIDE;
62 private:
63 SoftwareRenderer(
64 RendererClient* client,
65 OutputSurface* output_surface,
66 ResourceProvider* resource_provider);
68 void ClearCanvas(SkColor color);
69 void SetClipRect(gfx::Rect rect);
70 bool IsSoftwareResource(ResourceProvider::ResourceId resource_id) const;
72 void DrawDebugBorderQuad(const DrawingFrame* frame,
73 const DebugBorderDrawQuad* quad);
74 void DrawSolidColorQuad(const DrawingFrame* frame,
75 const SolidColorDrawQuad* quad);
76 void DrawTextureQuad(const DrawingFrame* frame,
77 const TextureDrawQuad* quad);
78 void DrawTileQuad(const DrawingFrame* frame,
79 const TileDrawQuad* quad);
80 void DrawRenderPassQuad(const DrawingFrame* frame,
81 const RenderPassDrawQuad* quad);
82 void DrawUnsupportedQuad(const DrawingFrame* frame,
83 const DrawQuad* quad);
85 RendererCapabilities capabilities_;
86 bool visible_;
87 bool is_scissor_enabled_;
88 bool is_viewport_changed_;
89 gfx::Rect scissor_rect_;
91 OutputSurface* output_surface_;
92 SoftwareOutputDevice* output_device_;
93 SkCanvas* root_canvas_;
94 SkCanvas* current_canvas_;
95 SkPaint current_paint_;
96 scoped_ptr<ResourceProvider::ScopedWriteLockSoftware>
97 current_framebuffer_lock_;
98 CompositorFrame compositor_frame_;
100 DISALLOW_COPY_AND_ASSIGN(SoftwareRenderer);
103 } // namespace cc
105 #endif // CC_OUTPUT_SOFTWARE_RENDERER_H_