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.
8 #include "base/basictypes.h"
9 #include "cc/cc_export.h"
10 #include "cc/layer_tree_host.h"
11 #include "cc/managed_memory_policy.h"
12 #include "cc/render_pass.h"
16 class CompositorFrameAck
;
17 class CompositorFrameMetadata
;
20 class CC_EXPORT RendererClient
{
22 virtual const gfx::Size
& deviceViewportSize() const = 0;
23 virtual const LayerTreeSettings
& settings() const = 0;
24 virtual void didLoseOutputSurface() = 0;
25 virtual void onSwapBuffersComplete() = 0;
26 virtual void setFullRootLayerDamage() = 0;
27 virtual void setManagedMemoryPolicy(const ManagedMemoryPolicy
& policy
) = 0;
28 virtual void enforceManagedMemoryPolicy(const ManagedMemoryPolicy
& policy
) = 0;
29 virtual bool hasImplThread() const = 0;
30 virtual bool shouldClearRootRenderPass() const = 0;
31 virtual CompositorFrameMetadata
makeCompositorFrameMetadata() const = 0;
33 virtual ~RendererClient() { }
36 class CC_EXPORT Renderer
{
38 virtual ~Renderer() { }
40 virtual const RendererCapabilities
& capabilities() const = 0;
42 const LayerTreeSettings
& settings() const { return m_client
->settings(); }
44 gfx::Size
viewportSize() const { return m_client
->deviceViewportSize(); }
45 int viewportWidth() const { return viewportSize().width(); }
46 int viewportHeight() const { return viewportSize().height(); }
48 virtual void viewportChanged() { }
49 virtual void receiveCompositorFrameAck(const CompositorFrameAck
&) { }
51 virtual void decideRenderPassAllocationsForFrame(const RenderPassList
&) { }
52 virtual bool haveCachedResourcesForRenderPassId(RenderPass::Id
) const;
54 // This passes ownership of the render passes to the renderer. It should
55 // consume them, and empty the list.
56 virtual void drawFrame(RenderPassList
&) = 0;
58 // waits for rendering to finish
59 virtual void finish() = 0;
61 virtual void doNoOp() { }
62 // puts backbuffer onscreen
63 virtual bool swapBuffers() = 0;
65 virtual void getFramebufferPixels(void *pixels
, const gfx::Rect
&) = 0;
67 virtual bool isContextLost();
69 virtual void setVisible(bool) = 0;
71 virtual void sendManagedMemoryStats(size_t bytesVisible
, size_t bytesVisibleAndNearby
, size_t bytesAllocated
) = 0;
74 explicit Renderer(RendererClient
* client
)
79 RendererClient
* m_client
;
81 DISALLOW_COPY_AND_ASSIGN(Renderer
);
86 #endif // CC_RENDERER_H_