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"
17 class CompositorFrameAck
;
18 class CompositorFrameMetadata
;
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
;
34 bool using_shared_memory_resources
;
36 // Capabilities used on compositor thread only.
37 bool using_partial_swap
;
40 bool using_discard_framebuffer
;
41 bool allow_rasterize_on_demand
;
43 RendererCapabilities
MainThreadCapabilities() const;
46 class CC_EXPORT RendererClient
{
48 virtual void SetFullRootLayerDamage() = 0;
51 class CC_EXPORT Renderer
{
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
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
);
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_
;
95 DISALLOW_COPY_AND_ASSIGN(Renderer
);
100 #endif // CC_OUTPUT_RENDERER_H_