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 <memory> | 8 #include <memory> |
9 | 9 |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
11 #include "cc/base/cc_export.h" | 11 #include "cc/base/cc_export.h" |
12 #include "cc/output/compositor_frame_metadata.h" | 12 #include "cc/output/compositor_frame_metadata.h" |
13 #include "cc/output/renderer_capabilities.h" | 13 #include "cc/output/renderer_capabilities.h" |
14 #include "cc/output/renderer_settings.h" | 14 #include "cc/output/renderer_settings.h" |
15 #include "cc/resources/returned_resource.h" | 15 #include "cc/resources/returned_resource.h" |
16 #include "ui/gfx/color_space.h" | 16 #include "ui/gfx/color_space.h" |
17 #include "ui/gfx/geometry/rect.h" | 17 #include "ui/gfx/geometry/rect.h" |
18 | 18 |
19 namespace cc { | 19 namespace cc { |
20 | 20 |
21 class RenderPass; | 21 class RenderPass; |
22 class RenderPassId; | 22 class RenderPassId; |
23 class ScopedResource; | 23 class ScopedResource; |
24 class Task; | 24 class Task; |
25 | 25 |
26 typedef std::vector<std::unique_ptr<RenderPass>> RenderPassList; | |
27 | |
28 struct RendererCapabilitiesImpl { | 26 struct RendererCapabilitiesImpl { |
29 RendererCapabilitiesImpl(); | 27 RendererCapabilitiesImpl(); |
30 ~RendererCapabilitiesImpl(); | 28 ~RendererCapabilitiesImpl(); |
31 | 29 |
32 // Capabilities copied to main thread. | 30 // Capabilities copied to main thread. |
33 ResourceFormat best_texture_format; | 31 ResourceFormat best_texture_format; |
34 bool allow_partial_texture_updates; | 32 bool allow_partial_texture_updates; |
35 int max_texture_size; | 33 int max_texture_size; |
36 bool using_shared_memory_resources; | 34 bool using_shared_memory_resources; |
37 | 35 |
38 // Capabilities used on compositor thread only. | 36 // Capabilities used on compositor thread only. |
39 bool using_partial_swap; | 37 bool using_partial_swap; |
40 // Whether it's valid to SwapBuffers with an empty rect. Trivially true when | 38 // Whether it's valid to SwapBuffers with an empty rect. Trivially true when |
41 // |using_partial_swap|. | 39 // |using_partial_swap|. |
42 bool allow_empty_swap; | 40 bool allow_empty_swap; |
43 bool using_egl_image; | 41 bool using_egl_image; |
44 bool using_image; | 42 bool using_image; |
45 bool using_discard_framebuffer; | 43 bool using_discard_framebuffer; |
46 bool allow_rasterize_on_demand; | 44 bool allow_rasterize_on_demand; |
47 int max_msaa_samples; | 45 int max_msaa_samples; |
48 | 46 |
49 RendererCapabilities MainThreadCapabilities() const; | 47 RendererCapabilities MainThreadCapabilities() const; |
50 }; | 48 }; |
51 | 49 |
52 class CC_EXPORT RendererClient { | |
53 public: | |
54 virtual void SetFullRootLayerDamage() = 0; | |
55 }; | |
56 | |
57 class CC_EXPORT Renderer { | |
58 public: | |
59 virtual ~Renderer() {} | |
60 | |
61 virtual const RendererCapabilitiesImpl& Capabilities() const = 0; | |
62 | |
63 virtual void DecideRenderPassAllocationsForFrame( | |
64 const RenderPassList& render_passes_in_draw_order) {} | |
65 virtual bool HasAllocatedResourcesForTesting(RenderPassId id) const; | |
66 | |
67 // This passes ownership of the render passes to the renderer. It should | |
68 // consume them, and empty the list. The parameters here may change from frame | |
69 // to frame and should not be cached. | |
70 // The |device_viewport_rect| and |device_clip_rect| are in non-y-flipped | |
71 // window space. | |
72 virtual void DrawFrame(RenderPassList* render_passes_in_draw_order, | |
73 float device_scale_factor, | |
74 const gfx::ColorSpace& device_color_space, | |
75 const gfx::Rect& device_viewport_rect, | |
76 const gfx::Rect& device_clip_rect) = 0; | |
77 | |
78 // Waits for rendering to finish. | |
79 virtual void Finish() = 0; | |
80 | |
81 // Puts backbuffer onscreen. | |
82 virtual void SwapBuffers(CompositorFrameMetadata metadata) = 0; | |
83 virtual void ReclaimResources(const ReturnedResourceArray& resources) {} | |
84 | |
85 bool visible() const { return visible_; } | |
86 void SetVisible(bool visible); | |
87 | |
88 protected: | |
89 Renderer(RendererClient* client, const RendererSettings* settings) | |
90 : client_(client), settings_(settings), visible_(true) {} | |
91 | |
92 virtual void DidChangeVisibility() = 0; | |
93 | |
94 RendererClient* client_; | |
95 const RendererSettings* settings_; | |
96 bool visible_; | |
97 | |
98 private: | |
99 DISALLOW_COPY_AND_ASSIGN(Renderer); | |
100 }; | |
101 | |
102 } // namespace cc | 50 } // namespace cc |
103 | 51 |
104 #endif // CC_OUTPUT_RENDERER_H_ | 52 #endif // CC_OUTPUT_RENDERER_H_ |
OLD | NEW |