[email protected] | 0fb2500 | 2012-10-12 07:20:02 | [diff] [blame] | 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. | ||||
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 4 | |
[email protected] | 8fcbaa37 | 2012-11-05 04:12:41 | [diff] [blame] | 5 | #ifndef CC_RENDERER_H_ |
6 | #define CC_RENDERER_H_ | ||||
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 7 | |
[email protected] | 55a124d0 | 2012-10-22 03:07:13 | [diff] [blame] | 8 | #include "base/basictypes.h" |
[email protected] | 52347c84 | 2012-11-02 21:06:20 | [diff] [blame] | 9 | #include "cc/cc_export.h" |
[email protected] | d50c686 | 2012-10-23 02:08:31 | [diff] [blame] | 10 | #include "cc/layer_tree_host.h" |
11 | #include "cc/managed_memory_policy.h" | ||||
[email protected] | 55a124d0 | 2012-10-22 03:07:13 | [diff] [blame] | 12 | #include "cc/render_pass.h" |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 13 | |
14 | namespace cc { | ||||
15 | |||||
[email protected] | b6f3d7e | 2012-12-08 00:11:21 | [diff] [blame] | 16 | class CompositorFrameAck; |
[email protected] | bf189f6 | 2012-12-18 03:42:11 | [diff] [blame] | 17 | class CompositorFrameMetadata; |
[email protected] | f7685bc | 2012-11-08 17:32:33 | [diff] [blame] | 18 | class ScopedResource; |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 19 | |
[email protected] | 52347c84 | 2012-11-02 21:06:20 | [diff] [blame] | 20 | class CC_EXPORT RendererClient { |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 21 | public: |
[email protected] | aad0a007 | 2012-11-01 18:15:58 | [diff] [blame] | 22 | virtual const gfx::Size& deviceViewportSize() const = 0; |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame] | 23 | virtual const LayerTreeSettings& settings() const = 0; |
[email protected] | 3be2171d | 2012-12-06 06:13:20 | [diff] [blame] | 24 | virtual void didLoseOutputSurface() = 0; |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 25 | virtual void onSwapBuffersComplete() = 0; |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 26 | virtual void setFullRootLayerDamage() = 0; |
[email protected] | a0a0084 | 2012-10-22 22:50:28 | [diff] [blame] | 27 | virtual void setManagedMemoryPolicy(const ManagedMemoryPolicy& policy) = 0; |
28 | virtual void enforceManagedMemoryPolicy(const ManagedMemoryPolicy& policy) = 0; | ||||
[email protected] | 61de581 | 2012-11-08 07:03:44 | [diff] [blame] | 29 | virtual bool hasImplThread() const = 0; |
[email protected] | f35e232 | 2012-12-15 21:45:52 | [diff] [blame] | 30 | virtual bool shouldClearRootRenderPass() const = 0; |
[email protected] | bf189f6 | 2012-12-18 03:42:11 | [diff] [blame] | 31 | virtual CompositorFrameMetadata makeCompositorFrameMetadata() const = 0; |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 32 | protected: |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame] | 33 | virtual ~RendererClient() { } |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 34 | }; |
35 | |||||
[email protected] | 52347c84 | 2012-11-02 21:06:20 | [diff] [blame] | 36 | class CC_EXPORT Renderer { |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 37 | public: |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame] | 38 | virtual ~Renderer() { } |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 39 | |
40 | virtual const RendererCapabilities& capabilities() const = 0; | ||||
41 | |||||
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame] | 42 | const LayerTreeSettings& settings() const { return m_client->settings(); } |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 43 | |
[email protected] | f35e232 | 2012-12-15 21:45:52 | [diff] [blame] | 44 | gfx::Size viewportSize() const { return m_client->deviceViewportSize(); } |
45 | int viewportWidth() const { return viewportSize().width(); } | ||||
46 | int viewportHeight() const { return viewportSize().height(); } | ||||
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 47 | |
48 | virtual void viewportChanged() { } | ||||
[email protected] | b6f3d7e | 2012-12-08 00:11:21 | [diff] [blame] | 49 | virtual void receiveCompositorFrameAck(const CompositorFrameAck&) { } |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 50 | |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame] | 51 | virtual void decideRenderPassAllocationsForFrame(const RenderPassList&) { } |
52 | virtual bool haveCachedResourcesForRenderPassId(RenderPass::Id) const; | ||||
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 53 | |
[email protected] | 85167c7 | 2012-12-04 03:56:07 | [diff] [blame] | 54 | // This passes ownership of the render passes to the renderer. It should |
[email protected] | 2006204 | 2012-12-21 22:16:36 | [diff] [blame] | 55 | // consume them, and empty the list. |
56 | virtual void drawFrame(RenderPassList&) = 0; | ||||
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 57 | |
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] | aad0a007 | 2012-11-01 18:15:58 | [diff] [blame] | 65 | virtual void getFramebufferPixels(void *pixels, const gfx::Rect&) = 0; |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 66 | |
67 | virtual bool isContextLost(); | ||||
68 | |||||
69 | virtual void setVisible(bool) = 0; | ||||
70 | |||||
[email protected] | 3d21e02 | 2012-10-25 20:03:08 | [diff] [blame] | 71 | virtual void sendManagedMemoryStats(size_t bytesVisible, size_t bytesVisibleAndNearby, size_t bytesAllocated) = 0; |
72 | |||||
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 73 | protected: |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame] | 74 | explicit Renderer(RendererClient* client) |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 75 | : m_client(client) |
76 | { | ||||
77 | } | ||||
78 | |||||
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame] | 79 | RendererClient* m_client; |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 80 | |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame] | 81 | DISALLOW_COPY_AND_ASSIGN(Renderer); |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 82 | }; |
83 | |||||
84 | } | ||||
85 | |||||
[email protected] | 8fcbaa37 | 2012-11-05 04:12:41 | [diff] [blame] | 86 | #endif // CC_RENDERER_H_ |