Clear webapp storage when site data is cleared
[chromium-blink-merge.git] / cc / output / software_renderer.h
blob339bf6fb64a23d1407a8bd6714656c9d9031c4a3
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 DiscardBackbuffer() override;
41 void EnsureBackbuffer() override;
43 protected:
44 void BindFramebufferToOutputSurface(DrawingFrame* frame) override;
45 bool BindFramebufferToTexture(DrawingFrame* frame,
46 const ScopedResource* texture,
47 const gfx::Rect& target_rect) override;
48 void SetScissorTestRect(const gfx::Rect& scissor_rect) override;
49 void PrepareSurfaceForPass(DrawingFrame* frame,
50 SurfaceInitializationMode initialization_mode,
51 const gfx::Rect& render_pass_scissor) override;
53 void DoDrawQuad(DrawingFrame* frame,
54 const DrawQuad* quad,
55 const gfx::QuadF* draw_region) 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 ClearFramebuffer(DrawingFrame* frame);
75 void SetClipRect(const gfx::Rect& rect);
76 bool IsSoftwareResource(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);
94 bool ShouldApplyBackgroundFilters(const RenderPassDrawQuad* quad) const;
95 SkBitmap ApplyImageFilter(SkImageFilter* filter,
96 const RenderPassDrawQuad* quad,
97 const SkBitmap* to_filter) const;
98 gfx::Rect GetBackdropBoundingBoxForRenderPassQuad(
99 const DrawingFrame* frame,
100 const RenderPassDrawQuad* quad,
101 const gfx::Transform& contents_device_transform) const;
102 SkBitmap GetBackdropBitmap(const gfx::Rect& bounding_rect) const;
103 skia::RefPtr<SkShader> GetBackgroundFilterShader(
104 const DrawingFrame* frame,
105 const RenderPassDrawQuad* quad,
106 SkShader::TileMode content_tile_mode) const;
108 RendererCapabilitiesImpl capabilities_;
109 bool is_scissor_enabled_;
110 bool is_backbuffer_discarded_;
111 gfx::Rect scissor_rect_;
113 SoftwareOutputDevice* output_device_;
114 SkCanvas* root_canvas_;
115 SkCanvas* current_canvas_;
116 SkPaint current_paint_;
117 scoped_ptr<ResourceProvider::ScopedWriteLockSoftware>
118 current_framebuffer_lock_;
119 skia::RefPtr<SkCanvas> current_framebuffer_canvas_;
121 DISALLOW_COPY_AND_ASSIGN(SoftwareRenderer);
124 } // namespace cc
126 #endif // CC_OUTPUT_SOFTWARE_RENDERER_H_