API migration: picture.draw -> picture.playback
[chromium-blink-merge.git] / cc / output / software_renderer.h
blob99868c33fd5f7ab617bcdf9fa8e7b16b9b8f2c49
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 RendererClient;
17 class ResourceProvider;
18 class SoftwareOutputDevice;
20 class CheckerboardDrawQuad;
21 class DebugBorderDrawQuad;
22 class PictureDrawQuad;
23 class RenderPassDrawQuad;
24 class SolidColorDrawQuad;
25 class TextureDrawQuad;
26 class TileDrawQuad;
28 class CC_EXPORT SoftwareRenderer : public DirectRenderer {
29 public:
30 static scoped_ptr<SoftwareRenderer> Create(
31 RendererClient* client,
32 const RendererSettings* settings,
33 OutputSurface* output_surface,
34 ResourceProvider* resource_provider);
36 ~SoftwareRenderer() override;
37 const RendererCapabilitiesImpl& Capabilities() const override;
38 void Finish() override;
39 void SwapBuffers(const CompositorFrameMetadata& metadata) override;
40 void ReceiveSwapBuffersAck(const CompositorFrameAck& ack) override;
41 void DiscardBackbuffer() override;
42 void EnsureBackbuffer() override;
44 protected:
45 void BindFramebufferToOutputSurface(DrawingFrame* frame) override;
46 bool BindFramebufferToTexture(DrawingFrame* frame,
47 const ScopedResource* texture,
48 const gfx::Rect& target_rect) override;
49 void SetDrawViewport(const gfx::Rect& window_space_viewport) override;
50 void SetScissorTestRect(const gfx::Rect& scissor_rect) override;
51 void DiscardPixels(bool has_external_stencil_test,
52 bool draw_rect_covers_full_surface) override;
53 void ClearFramebuffer(DrawingFrame* frame,
54 bool has_external_stencil_test) override;
55 void DoDrawQuad(DrawingFrame* frame, const DrawQuad* quad) override;
56 void BeginDrawingFrame(DrawingFrame* frame) override;
57 void FinishDrawingFrame(DrawingFrame* frame) override;
58 bool FlippedFramebuffer(const DrawingFrame* frame) const override;
59 void EnsureScissorTestEnabled() override;
60 void EnsureScissorTestDisabled() override;
61 void CopyCurrentRenderPassToBitmap(
62 DrawingFrame* frame,
63 scoped_ptr<CopyOutputRequest> request) override;
65 SoftwareRenderer(RendererClient* client,
66 const RendererSettings* settings,
67 OutputSurface* output_surface,
68 ResourceProvider* resource_provider);
70 void DidChangeVisibility() override;
72 private:
73 void ClearCanvas(SkColor color);
74 void SetClipRect(const gfx::Rect& rect);
75 bool IsSoftwareResource(ResourceProvider::ResourceId resource_id) const;
77 void DrawCheckerboardQuad(const DrawingFrame* frame,
78 const CheckerboardDrawQuad* quad);
79 void DrawDebugBorderQuad(const DrawingFrame* frame,
80 const DebugBorderDrawQuad* quad);
81 void DrawPictureQuad(const DrawingFrame* frame,
82 const PictureDrawQuad* quad);
83 void DrawRenderPassQuad(const DrawingFrame* frame,
84 const RenderPassDrawQuad* quad);
85 void DrawSolidColorQuad(const DrawingFrame* frame,
86 const SolidColorDrawQuad* quad);
87 void DrawTextureQuad(const DrawingFrame* frame,
88 const TextureDrawQuad* quad);
89 void DrawTileQuad(const DrawingFrame* frame,
90 const TileDrawQuad* quad);
91 void DrawUnsupportedQuad(const DrawingFrame* frame,
92 const DrawQuad* quad);
94 RendererCapabilitiesImpl capabilities_;
95 bool is_scissor_enabled_;
96 bool is_backbuffer_discarded_;
97 gfx::Rect scissor_rect_;
99 SoftwareOutputDevice* output_device_;
100 SkCanvas* root_canvas_;
101 SkCanvas* current_canvas_;
102 SkPaint current_paint_;
103 scoped_ptr<ResourceProvider::ScopedWriteLockSoftware>
104 current_framebuffer_lock_;
105 skia::RefPtr<SkCanvas> current_framebuffer_canvas_;
106 scoped_ptr<SoftwareFrameData> current_frame_data_;
108 DISALLOW_COPY_AND_ASSIGN(SoftwareRenderer);
111 } // namespace cc
113 #endif // CC_OUTPUT_SOFTWARE_RENDERER_H_