OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CC_OUTPUT_RENDERER_H_ | 5 #ifndef CC_OUTPUT_RENDERER_H_ |
6 #define CC_OUTPUT_RENDERER_H_ | 6 #define CC_OUTPUT_RENDERER_H_ |
7 | 7 |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "cc/base/cc_export.h" | 9 #include "cc/base/cc_export.h" |
10 #include "cc/quads/render_pass.h" | 10 #include "cc/quads/render_pass.h" |
11 #include "cc/trees/layer_tree_host.h" | 11 #include "cc/trees/layer_tree_host.h" |
12 | 12 |
13 namespace cc { | 13 namespace cc { |
14 | 14 |
15 class CompositorFrameAck; | 15 class CompositorFrameAck; |
16 class CompositorFrameMetadata; | 16 class CompositorFrameMetadata; |
17 class ScopedResource; | 17 class ScopedResource; |
18 | 18 |
19 class CC_EXPORT RendererClient { | 19 class CC_EXPORT RendererClient { |
20 public: | 20 public: |
21 // These return the draw viewport and clip in non-y-flipped window space. | 21 // These return the draw viewport and clip in non-y-flipped window space. |
22 // Note that while a draw is in progress, these are guaranteed to be | 22 // Note that while a draw is in progress, these are guaranteed to be |
23 // contained within the output surface size. | 23 // contained within the output surface size. |
24 virtual gfx::Rect DeviceViewport() const = 0; | 24 virtual gfx::Rect DeviceViewport() const = 0; |
25 virtual gfx::Rect DeviceClip() const = 0; | 25 virtual gfx::Rect DeviceClip() const = 0; |
26 | |
27 virtual float DeviceScaleFactor() const = 0; | |
28 virtual const LayerTreeSettings& Settings() const = 0; | |
29 virtual void SetFullRootLayerDamage() = 0; | 26 virtual void SetFullRootLayerDamage() = 0; |
30 virtual bool HasImplThread() const = 0; | |
31 virtual bool ShouldClearRootRenderPass() const = 0; | |
32 virtual CompositorFrameMetadata MakeCompositorFrameMetadata() const = 0; | 27 virtual CompositorFrameMetadata MakeCompositorFrameMetadata() const = 0; |
33 virtual bool AllowPartialSwap() const = 0; | |
34 virtual bool ExternalStencilTestEnabled() const = 0; | |
35 | 28 |
36 protected: | 29 protected: |
37 virtual ~RendererClient() {} | 30 virtual ~RendererClient() {} |
38 }; | 31 }; |
39 | 32 |
40 class CC_EXPORT Renderer { | 33 class CC_EXPORT Renderer { |
41 public: | 34 public: |
42 virtual ~Renderer() {} | 35 virtual ~Renderer() {} |
43 | 36 |
44 virtual const RendererCapabilities& Capabilities() const = 0; | 37 virtual const RendererCapabilities& Capabilities() const = 0; |
45 | 38 |
46 const LayerTreeSettings& Settings() const { return client_->Settings(); } | |
47 | |
48 virtual void ViewportChanged() {} | 39 virtual void ViewportChanged() {} |
49 | 40 |
50 virtual bool CanReadPixels() const = 0; | 41 virtual bool CanReadPixels() const = 0; |
51 | 42 |
52 virtual void DecideRenderPassAllocationsForFrame( | 43 virtual void DecideRenderPassAllocationsForFrame( |
53 const RenderPassList& render_passes_in_draw_order) {} | 44 const RenderPassList& render_passes_in_draw_order) {} |
54 virtual bool HaveCachedResourcesForRenderPassId(RenderPass::Id id) const; | 45 virtual bool HaveCachedResourcesForRenderPassId(RenderPass::Id id) const; |
55 | 46 |
56 // This passes ownership of the render passes to the renderer. It should | 47 // This passes ownership of the render passes to the renderer. It should |
57 // consume them, and empty the list. | 48 // consume them, and empty the list. The parameters here may change from frame |
58 // The |offscreen_context_provider| may change from frame to frame and should | 49 // to frame and should not be cached. |
59 // not be cached. | |
60 virtual void DrawFrame(RenderPassList* render_passes_in_draw_order, | 50 virtual void DrawFrame(RenderPassList* render_passes_in_draw_order, |
61 ContextProvider* offscreen_context_provider) = 0; | 51 ContextProvider* offscreen_context_provider, |
| 52 float device_scale_factor, |
| 53 bool allow_partial_swap) = 0; |
62 | 54 |
63 // Waits for rendering to finish. | 55 // Waits for rendering to finish. |
64 virtual void Finish() = 0; | 56 virtual void Finish() = 0; |
65 | 57 |
66 virtual void DoNoOp() {} | 58 virtual void DoNoOp() {} |
67 | 59 |
68 // Puts backbuffer onscreen. | 60 // Puts backbuffer onscreen. |
69 virtual void SwapBuffers() = 0; | 61 virtual void SwapBuffers() = 0; |
70 virtual void ReceiveSwapBuffersAck(const CompositorFrameAck& ack) {} | 62 virtual void ReceiveSwapBuffersAck(const CompositorFrameAck& ack) {} |
71 | 63 |
72 virtual void GetFramebufferPixels(void* pixels, gfx::Rect rect) = 0; | 64 virtual void GetFramebufferPixels(void* pixels, gfx::Rect rect) = 0; |
73 | 65 |
74 virtual bool IsContextLost(); | 66 virtual bool IsContextLost(); |
75 | 67 |
76 virtual void SetVisible(bool visible) = 0; | 68 virtual void SetVisible(bool visible) = 0; |
77 | 69 |
78 virtual void SendManagedMemoryStats(size_t bytes_visible, | 70 virtual void SendManagedMemoryStats(size_t bytes_visible, |
79 size_t bytes_visible_and_nearby, | 71 size_t bytes_visible_and_nearby, |
80 size_t bytes_allocated) = 0; | 72 size_t bytes_allocated) = 0; |
81 | 73 |
82 virtual void SetDiscardBackBufferWhenNotVisible(bool discard) = 0; | 74 virtual void SetDiscardBackBufferWhenNotVisible(bool discard) = 0; |
83 | 75 |
84 protected: | 76 protected: |
85 explicit Renderer(RendererClient* client) | 77 explicit Renderer(RendererClient* client, const LayerTreeSettings* settings) |
86 : client_(client) {} | 78 : client_(client), settings_(settings) {} |
87 | 79 |
88 RendererClient* client_; | 80 RendererClient* client_; |
| 81 const LayerTreeSettings* settings_; |
89 | 82 |
90 private: | 83 private: |
91 DISALLOW_COPY_AND_ASSIGN(Renderer); | 84 DISALLOW_COPY_AND_ASSIGN(Renderer); |
92 }; | 85 }; |
93 | 86 |
94 } // namespace cc | 87 } // namespace cc |
95 | 88 |
96 #endif // CC_OUTPUT_RENDERER_H_ | 89 #endif // CC_OUTPUT_RENDERER_H_ |
OLD | NEW |