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