blob: fa4020ff2c1f85c520c5206a0e7f151f19f3c578 [file] [log] [blame]
[email protected]0fb25002012-10-12 07:20:021// 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.
[email protected]cd57cc5a2012-10-12 22:43:414
[email protected]8fcbaa372012-11-05 04:12:415#ifndef CC_RENDERER_H_
6#define CC_RENDERER_H_
[email protected]cd57cc5a2012-10-12 22:43:417
[email protected]55a124d02012-10-22 03:07:138#include "base/basictypes.h"
[email protected]52347c842012-11-02 21:06:209#include "cc/cc_export.h"
[email protected]d50c6862012-10-23 02:08:3110#include "cc/layer_tree_host.h"
11#include "cc/managed_memory_policy.h"
[email protected]55a124d02012-10-22 03:07:1312#include "cc/render_pass.h"
[email protected]cd57cc5a2012-10-12 22:43:4113
14namespace cc {
15
[email protected]b6f3d7e2012-12-08 00:11:2116class CompositorFrameAck;
[email protected]bf189f62012-12-18 03:42:1117class CompositorFrameMetadata;
[email protected]f7685bc2012-11-08 17:32:3318class ScopedResource;
[email protected]cd57cc5a2012-10-12 22:43:4119
[email protected]52347c842012-11-02 21:06:2020class CC_EXPORT RendererClient {
[email protected]cd57cc5a2012-10-12 22:43:4121public:
[email protected]aad0a0072012-11-01 18:15:5822 virtual const gfx::Size& deviceViewportSize() const = 0;
[email protected]96baf3e2012-10-22 23:09:5523 virtual const LayerTreeSettings& settings() const = 0;
[email protected]3be2171d2012-12-06 06:13:2024 virtual void didLoseOutputSurface() = 0;
[email protected]cd57cc5a2012-10-12 22:43:4125 virtual void onSwapBuffersComplete() = 0;
[email protected]cd57cc5a2012-10-12 22:43:4126 virtual void setFullRootLayerDamage() = 0;
[email protected]a0a00842012-10-22 22:50:2827 virtual void setManagedMemoryPolicy(const ManagedMemoryPolicy& policy) = 0;
28 virtual void enforceManagedMemoryPolicy(const ManagedMemoryPolicy& policy) = 0;
[email protected]61de5812012-11-08 07:03:4429 virtual bool hasImplThread() const = 0;
[email protected]f35e2322012-12-15 21:45:5230 virtual bool shouldClearRootRenderPass() const = 0;
[email protected]bf189f62012-12-18 03:42:1131 virtual CompositorFrameMetadata makeCompositorFrameMetadata() const = 0;
[email protected]cd57cc5a2012-10-12 22:43:4132protected:
[email protected]96baf3e2012-10-22 23:09:5533 virtual ~RendererClient() { }
[email protected]cd57cc5a2012-10-12 22:43:4134};
35
[email protected]52347c842012-11-02 21:06:2036class CC_EXPORT Renderer {
[email protected]cd57cc5a2012-10-12 22:43:4137public:
[email protected]96baf3e2012-10-22 23:09:5538 virtual ~Renderer() { }
[email protected]cd57cc5a2012-10-12 22:43:4139
40 virtual const RendererCapabilities& capabilities() const = 0;
41
[email protected]96baf3e2012-10-22 23:09:5542 const LayerTreeSettings& settings() const { return m_client->settings(); }
[email protected]cd57cc5a2012-10-12 22:43:4143
[email protected]f35e2322012-12-15 21:45:5244 gfx::Size viewportSize() const { return m_client->deviceViewportSize(); }
45 int viewportWidth() const { return viewportSize().width(); }
46 int viewportHeight() const { return viewportSize().height(); }
[email protected]cd57cc5a2012-10-12 22:43:4147
48 virtual void viewportChanged() { }
[email protected]b6f3d7e2012-12-08 00:11:2149 virtual void receiveCompositorFrameAck(const CompositorFrameAck&) { }
[email protected]cd57cc5a2012-10-12 22:43:4150
[email protected]96baf3e2012-10-22 23:09:5551 virtual void decideRenderPassAllocationsForFrame(const RenderPassList&) { }
52 virtual bool haveCachedResourcesForRenderPassId(RenderPass::Id) const;
[email protected]cd57cc5a2012-10-12 22:43:4153
[email protected]85167c72012-12-04 03:56:0754 // This passes ownership of the render passes to the renderer. It should
[email protected]20062042012-12-21 22:16:3655 // consume them, and empty the list.
56 virtual void drawFrame(RenderPassList&) = 0;
[email protected]cd57cc5a2012-10-12 22:43:4157
58 // waits for rendering to finish
59 virtual void finish() = 0;
60
61 virtual void doNoOp() { }
62 // puts backbuffer onscreen
63 virtual bool swapBuffers() = 0;
64
[email protected]aad0a0072012-11-01 18:15:5865 virtual void getFramebufferPixels(void *pixels, const gfx::Rect&) = 0;
[email protected]cd57cc5a2012-10-12 22:43:4166
67 virtual bool isContextLost();
68
69 virtual void setVisible(bool) = 0;
70
[email protected]3d21e022012-10-25 20:03:0871 virtual void sendManagedMemoryStats(size_t bytesVisible, size_t bytesVisibleAndNearby, size_t bytesAllocated) = 0;
72
[email protected]cd57cc5a2012-10-12 22:43:4173protected:
[email protected]96baf3e2012-10-22 23:09:5574 explicit Renderer(RendererClient* client)
[email protected]cd57cc5a2012-10-12 22:43:4175 : m_client(client)
76 {
77 }
78
[email protected]96baf3e2012-10-22 23:09:5579 RendererClient* m_client;
[email protected]cd57cc5a2012-10-12 22:43:4180
[email protected]96baf3e2012-10-22 23:09:5581 DISALLOW_COPY_AND_ASSIGN(Renderer);
[email protected]cd57cc5a2012-10-12 22:43:4182};
83
84}
85
[email protected]8fcbaa372012-11-05 04:12:4186#endif // CC_RENDERER_H_