Roll src/third_party/skia 280a9c8:ecb8e3e
[chromium-blink-merge.git] / cc / output / renderer.h
blobb775285bfb34e5a2917eb43d2bb937164c3144bf
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_RENDERER_H_
6 #define CC_OUTPUT_RENDERER_H_
8 #include "base/basictypes.h"
9 #include "cc/base/cc_export.h"
10 #include "cc/base/scoped_ptr_vector.h"
11 #include "cc/output/renderer_capabilities.h"
12 #include "cc/output/renderer_settings.h"
13 #include "ui/gfx/geometry/rect.h"
15 namespace cc {
17 class CompositorFrameAck;
18 class CompositorFrameMetadata;
19 class RenderPass;
20 class RenderPassId;
21 class ScopedResource;
22 class Task;
24 typedef ScopedPtrVector<RenderPass> RenderPassList;
26 struct RendererCapabilitiesImpl {
27 RendererCapabilitiesImpl();
28 ~RendererCapabilitiesImpl();
30 // Capabilities copied to main thread.
31 ResourceFormat best_texture_format;
32 bool allow_partial_texture_updates;
33 int max_texture_size;
34 bool using_shared_memory_resources;
36 // Capabilities used on compositor thread only.
37 bool using_partial_swap;
38 bool using_egl_image;
39 bool using_image;
40 bool using_discard_framebuffer;
41 bool allow_rasterize_on_demand;
43 RendererCapabilities MainThreadCapabilities() const;
46 class CC_EXPORT RendererClient {
47 public:
48 virtual void SetFullRootLayerDamage() = 0;
51 class CC_EXPORT Renderer {
52 public:
53 virtual ~Renderer() {}
55 virtual const RendererCapabilitiesImpl& Capabilities() const = 0;
57 virtual void DecideRenderPassAllocationsForFrame(
58 const RenderPassList& render_passes_in_draw_order) {}
59 virtual bool HasAllocatedResourcesForTesting(RenderPassId id) const;
61 // This passes ownership of the render passes to the renderer. It should
62 // consume them, and empty the list. The parameters here may change from frame
63 // to frame and should not be cached.
64 // The |device_viewport_rect| and |device_clip_rect| are in non-y-flipped
65 // window space.
66 virtual void DrawFrame(RenderPassList* render_passes_in_draw_order,
67 float device_scale_factor,
68 const gfx::Rect& device_viewport_rect,
69 const gfx::Rect& device_clip_rect,
70 bool disable_picture_quad_image_filtering) = 0;
72 // Waits for rendering to finish.
73 virtual void Finish() = 0;
75 virtual void DoNoOp() {}
77 // Puts backbuffer onscreen.
78 virtual void SwapBuffers(const CompositorFrameMetadata& metadata) = 0;
79 virtual void ReceiveSwapBuffersAck(const CompositorFrameAck& ack) {}
81 bool visible() const { return visible_; }
82 void SetVisible(bool visible);
84 protected:
85 Renderer(RendererClient* client, const RendererSettings* settings)
86 : client_(client), settings_(settings), visible_(true) {}
88 virtual void DidChangeVisibility() = 0;
90 RendererClient* client_;
91 const RendererSettings* settings_;
92 bool visible_;
94 private:
95 DISALLOW_COPY_AND_ASSIGN(Renderer);
98 } // namespace cc
100 #endif // CC_OUTPUT_RENDERER_H_