Roll src/third_party/skia de7665a:76033be
[chromium-blink-merge.git] / cc / output / software_renderer.h
blobdc8e2fb0f52399aab8ae6d2a25c794ae9d1dfbb9
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;
56 void DoDrawQuad(DrawingFrame* frame,
57 const DrawQuad* quad,
58 const gfx::QuadF* draw_region) override;
59 void BeginDrawingFrame(DrawingFrame* frame) override;
60 void FinishDrawingFrame(DrawingFrame* frame) override;
61 bool FlippedFramebuffer(const DrawingFrame* frame) const override;
62 void EnsureScissorTestEnabled() override;
63 void EnsureScissorTestDisabled() override;
64 void CopyCurrentRenderPassToBitmap(
65 DrawingFrame* frame,
66 scoped_ptr<CopyOutputRequest> request) override;
68 SoftwareRenderer(RendererClient* client,
69 const RendererSettings* settings,
70 OutputSurface* output_surface,
71 ResourceProvider* resource_provider);
73 void DidChangeVisibility() override;
75 private:
76 void ClearCanvas(SkColor color);
77 void SetClipRect(const gfx::Rect& rect);
78 bool IsSoftwareResource(ResourceProvider::ResourceId resource_id) const;
80 void DrawCheckerboardQuad(const DrawingFrame* frame,
81 const CheckerboardDrawQuad* quad);
82 void DrawDebugBorderQuad(const DrawingFrame* frame,
83 const DebugBorderDrawQuad* quad);
84 void DrawPictureQuad(const DrawingFrame* frame,
85 const PictureDrawQuad* quad);
86 void DrawRenderPassQuad(const DrawingFrame* frame,
87 const RenderPassDrawQuad* quad);
88 void DrawSolidColorQuad(const DrawingFrame* frame,
89 const SolidColorDrawQuad* quad);
90 void DrawTextureQuad(const DrawingFrame* frame,
91 const TextureDrawQuad* quad);
92 void DrawTileQuad(const DrawingFrame* frame,
93 const TileDrawQuad* quad);
94 void DrawUnsupportedQuad(const DrawingFrame* frame,
95 const DrawQuad* quad);
97 RendererCapabilitiesImpl capabilities_;
98 bool is_scissor_enabled_;
99 bool is_backbuffer_discarded_;
100 gfx::Rect scissor_rect_;
102 SoftwareOutputDevice* output_device_;
103 SkCanvas* root_canvas_;
104 SkCanvas* current_canvas_;
105 SkPaint current_paint_;
106 scoped_ptr<ResourceProvider::ScopedWriteLockSoftware>
107 current_framebuffer_lock_;
108 skia::RefPtr<SkCanvas> current_framebuffer_canvas_;
109 scoped_ptr<SoftwareFrameData> current_frame_data_;
111 DISALLOW_COPY_AND_ASSIGN(SoftwareRenderer);
114 } // namespace cc
116 #endif // CC_OUTPUT_SOFTWARE_RENDERER_H_