Windows should animate when they are about to get docked at screen edges.
[chromium-blink-merge.git] / cc / output / software_renderer.h
blobf810b68274d864233720f3ee22b072455837d368
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 OutputSurface* output_surface,
33 ResourceProvider* resource_provider);
35 virtual ~SoftwareRenderer();
36 virtual const RendererCapabilities& Capabilities() const OVERRIDE;
37 virtual void Finish() OVERRIDE;
38 virtual void SwapBuffers() OVERRIDE;
39 virtual void GetFramebufferPixels(void* pixels, gfx::Rect rect) OVERRIDE;
40 virtual void SetVisible(bool visible) OVERRIDE;
41 virtual void SendManagedMemoryStats(
42 size_t bytes_visible,
43 size_t bytes_visible_and_nearby,
44 size_t bytes_allocated) OVERRIDE {}
45 virtual void ReceiveSwapBuffersAck(
46 const CompositorFrameAck& ack) OVERRIDE;
47 virtual void SetDiscardBackBufferWhenNotVisible(bool discard) OVERRIDE;
49 protected:
50 virtual void BindFramebufferToOutputSurface(DrawingFrame* frame) OVERRIDE;
51 virtual bool BindFramebufferToTexture(
52 DrawingFrame* frame,
53 const ScopedResource* texture,
54 gfx::Rect target_rect) OVERRIDE;
55 virtual void SetDrawViewport(gfx::Rect window_space_viewport) OVERRIDE;
56 virtual void SetScissorTestRect(gfx::Rect scissor_rect) OVERRIDE;
57 virtual void ClearFramebuffer(DrawingFrame* frame) OVERRIDE;
58 virtual void DoDrawQuad(DrawingFrame* frame, const DrawQuad* quad) OVERRIDE;
59 virtual void BeginDrawingFrame(DrawingFrame* frame) OVERRIDE;
60 virtual void FinishDrawingFrame(DrawingFrame* frame) OVERRIDE;
61 virtual bool FlippedFramebuffer() const OVERRIDE;
62 virtual void EnsureScissorTestEnabled() OVERRIDE;
63 virtual void EnsureScissorTestDisabled() OVERRIDE;
64 virtual void CopyCurrentRenderPassToBitmap(
65 DrawingFrame* frame,
66 scoped_ptr<CopyOutputRequest> request) OVERRIDE;
68 SoftwareRenderer(
69 RendererClient* client,
70 OutputSurface* output_surface,
71 ResourceProvider* resource_provider);
73 private:
74 void ClearCanvas(SkColor color);
75 void SetClipRect(gfx::Rect rect);
76 bool IsSoftwareResource(ResourceProvider::ResourceId resource_id) const;
78 void DrawCheckerboardQuad(const DrawingFrame* frame,
79 const CheckerboardDrawQuad* quad);
80 void DrawDebugBorderQuad(const DrawingFrame* frame,
81 const DebugBorderDrawQuad* quad);
82 void DrawPictureQuad(const DrawingFrame* frame,
83 const PictureDrawQuad* quad);
84 void DrawRenderPassQuad(const DrawingFrame* frame,
85 const RenderPassDrawQuad* quad);
86 void DrawSolidColorQuad(const DrawingFrame* frame,
87 const SolidColorDrawQuad* quad);
88 void DrawTextureQuad(const DrawingFrame* frame,
89 const TextureDrawQuad* quad);
90 void DrawTileQuad(const DrawingFrame* frame,
91 const TileDrawQuad* quad);
92 void DrawUnsupportedQuad(const DrawingFrame* frame,
93 const DrawQuad* quad);
95 RendererCapabilities capabilities_;
96 bool visible_;
97 bool is_scissor_enabled_;
98 gfx::Rect scissor_rect_;
100 SoftwareOutputDevice* output_device_;
101 SkCanvas* root_canvas_;
102 SkCanvas* current_canvas_;
103 SkPaint current_paint_;
104 scoped_ptr<ResourceProvider::ScopedWriteLockSoftware>
105 current_framebuffer_lock_;
106 scoped_ptr<SoftwareFrameData> current_frame_data_;
108 DISALLOW_COPY_AND_ASSIGN(SoftwareRenderer);
111 } // namespace cc
113 #endif // CC_OUTPUT_SOFTWARE_RENDERER_H_