Cast: Stop logging kVideoFrameSentToEncoder and rename a couple events.
[chromium-blink-merge.git] / cc / output / software_renderer.h
blob7583bd84536b02ff4032dcf38739772d8f77df5f
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 LayerTreeSettings* settings,
33 OutputSurface* output_surface,
34 ResourceProvider* resource_provider);
36 virtual ~SoftwareRenderer();
37 virtual const RendererCapabilitiesImpl& Capabilities() const OVERRIDE;
38 virtual void Finish() OVERRIDE;
39 virtual void SwapBuffers(const CompositorFrameMetadata& metadata) OVERRIDE;
40 virtual void GetFramebufferPixels(void* pixels,
41 const gfx::Rect& rect) OVERRIDE;
42 virtual void SendManagedMemoryStats(
43 size_t bytes_visible,
44 size_t bytes_visible_and_nearby,
45 size_t bytes_allocated) OVERRIDE {}
46 virtual void ReceiveSwapBuffersAck(
47 const CompositorFrameAck& ack) OVERRIDE;
48 virtual void DiscardBackbuffer() OVERRIDE;
49 virtual void EnsureBackbuffer() OVERRIDE;
51 protected:
52 virtual void BindFramebufferToOutputSurface(DrawingFrame* frame) OVERRIDE;
53 virtual bool BindFramebufferToTexture(
54 DrawingFrame* frame,
55 const ScopedResource* texture,
56 const gfx::Rect& target_rect) OVERRIDE;
57 virtual void SetDrawViewport(const gfx::Rect& window_space_viewport) OVERRIDE;
58 virtual void SetScissorTestRect(const gfx::Rect& scissor_rect) OVERRIDE;
59 virtual void DiscardPixels(bool has_external_stencil_test,
60 bool draw_rect_covers_full_surface) OVERRIDE;
61 virtual void ClearFramebuffer(DrawingFrame* frame,
62 bool has_external_stencil_test) OVERRIDE;
63 virtual void DoDrawQuad(DrawingFrame* frame, const DrawQuad* quad) OVERRIDE;
64 virtual void BeginDrawingFrame(DrawingFrame* frame) OVERRIDE;
65 virtual void FinishDrawingFrame(DrawingFrame* frame) OVERRIDE;
66 virtual bool FlippedFramebuffer() const OVERRIDE;
67 virtual void EnsureScissorTestEnabled() OVERRIDE;
68 virtual void EnsureScissorTestDisabled() OVERRIDE;
69 virtual void CopyCurrentRenderPassToBitmap(
70 DrawingFrame* frame,
71 scoped_ptr<CopyOutputRequest> request) OVERRIDE;
73 SoftwareRenderer(RendererClient* client,
74 const LayerTreeSettings* settings,
75 OutputSurface* output_surface,
76 ResourceProvider* resource_provider);
78 virtual void DidChangeVisibility() OVERRIDE;
80 private:
81 void ClearCanvas(SkColor color);
82 void SetClipRect(const gfx::Rect& rect);
83 bool IsSoftwareResource(ResourceProvider::ResourceId resource_id) const;
85 void DrawCheckerboardQuad(const DrawingFrame* frame,
86 const CheckerboardDrawQuad* quad);
87 void DrawDebugBorderQuad(const DrawingFrame* frame,
88 const DebugBorderDrawQuad* quad);
89 void DrawPictureQuad(const DrawingFrame* frame,
90 const PictureDrawQuad* quad);
91 void DrawRenderPassQuad(const DrawingFrame* frame,
92 const RenderPassDrawQuad* quad);
93 void DrawSolidColorQuad(const DrawingFrame* frame,
94 const SolidColorDrawQuad* quad);
95 void DrawTextureQuad(const DrawingFrame* frame,
96 const TextureDrawQuad* quad);
97 void DrawTileQuad(const DrawingFrame* frame,
98 const TileDrawQuad* quad);
99 void DrawUnsupportedQuad(const DrawingFrame* frame,
100 const DrawQuad* quad);
102 RendererCapabilitiesImpl capabilities_;
103 bool is_scissor_enabled_;
104 bool is_backbuffer_discarded_;
105 gfx::Rect scissor_rect_;
107 SoftwareOutputDevice* output_device_;
108 SkCanvas* root_canvas_;
109 SkCanvas* current_canvas_;
110 SkPaint current_paint_;
111 scoped_ptr<ResourceProvider::ScopedWriteLockSoftware>
112 current_framebuffer_lock_;
113 scoped_ptr<SoftwareFrameData> current_frame_data_;
115 DISALLOW_COPY_AND_ASSIGN(SoftwareRenderer);
118 } // namespace cc
120 #endif // CC_OUTPUT_SOFTWARE_RENDERER_H_