Use multiline attribute to check for IA2_STATE_MULTILINE.
[chromium-blink-merge.git] / cc / output / software_renderer.h
blob74f328edc0112cdb9aef0432d414a1f907d4d389
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 SetScissorTestRect(const gfx::Rect& scissor_rect) override;
50 void PrepareSurfaceForPass(DrawingFrame* frame,
51 SurfaceInitializationMode initialization_mode,
52 const gfx::Rect& render_pass_scissor) override;
54 void DoDrawQuad(DrawingFrame* frame,
55 const DrawQuad* quad,
56 const gfx::QuadF* draw_region) override;
57 void BeginDrawingFrame(DrawingFrame* frame) override;
58 void FinishDrawingFrame(DrawingFrame* frame) override;
59 bool FlippedFramebuffer(const DrawingFrame* frame) const override;
60 void EnsureScissorTestEnabled() override;
61 void EnsureScissorTestDisabled() override;
62 void CopyCurrentRenderPassToBitmap(
63 DrawingFrame* frame,
64 scoped_ptr<CopyOutputRequest> request) override;
66 SoftwareRenderer(RendererClient* client,
67 const RendererSettings* settings,
68 OutputSurface* output_surface,
69 ResourceProvider* resource_provider);
71 void DidChangeVisibility() override;
73 private:
74 void ClearCanvas(SkColor color);
75 void ClearFramebuffer(DrawingFrame* frame);
76 void SetClipRect(const gfx::Rect& rect);
77 bool IsSoftwareResource(ResourceProvider::ResourceId resource_id) const;
79 void DrawCheckerboardQuad(const DrawingFrame* frame,
80 const CheckerboardDrawQuad* quad);
81 void DrawDebugBorderQuad(const DrawingFrame* frame,
82 const DebugBorderDrawQuad* quad);
83 void DrawPictureQuad(const DrawingFrame* frame,
84 const PictureDrawQuad* quad);
85 void DrawRenderPassQuad(const DrawingFrame* frame,
86 const RenderPassDrawQuad* quad);
87 void DrawSolidColorQuad(const DrawingFrame* frame,
88 const SolidColorDrawQuad* quad);
89 void DrawTextureQuad(const DrawingFrame* frame,
90 const TextureDrawQuad* quad);
91 void DrawTileQuad(const DrawingFrame* frame,
92 const TileDrawQuad* quad);
93 void DrawUnsupportedQuad(const DrawingFrame* frame,
94 const DrawQuad* quad);
96 RendererCapabilitiesImpl capabilities_;
97 bool is_scissor_enabled_;
98 bool is_backbuffer_discarded_;
99 gfx::Rect scissor_rect_;
101 SoftwareOutputDevice* output_device_;
102 SkCanvas* root_canvas_;
103 SkCanvas* current_canvas_;
104 SkPaint current_paint_;
105 scoped_ptr<ResourceProvider::ScopedWriteLockSoftware>
106 current_framebuffer_lock_;
107 skia::RefPtr<SkCanvas> current_framebuffer_canvas_;
108 scoped_ptr<SoftwareFrameData> current_frame_data_;
110 DISALLOW_COPY_AND_ASSIGN(SoftwareRenderer);
113 } // namespace cc
115 #endif // CC_OUTPUT_SOFTWARE_RENDERER_H_