OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 CONTENT_PUBLIC_BROWSER_ANDROID_SYNCHRONOUS_COMPOSITOR_H_ | 5 #ifndef CONTENT_PUBLIC_BROWSER_ANDROID_SYNCHRONOUS_COMPOSITOR_H_ |
6 #define CONTENT_PUBLIC_BROWSER_ANDROID_SYNCHRONOUS_COMPOSITOR_H_ | 6 #define CONTENT_PUBLIC_BROWSER_ANDROID_SYNCHRONOUS_COMPOSITOR_H_ |
7 | 7 |
8 #include "base/memory/ref_counted.h" | 8 #include "base/memory/ref_counted.h" |
9 #include "content/common/content_export.h" | 9 #include "content/common/content_export.h" |
10 #include "gpu/command_buffer/service/in_process_command_buffer.h" | 10 #include "gpu/command_buffer/service/in_process_command_buffer.h" |
11 #include "ui/gfx/rect.h" | 11 #include "ui/gfx/rect.h" |
12 #include "ui/gfx/size.h" | 12 #include "ui/gfx/size.h" |
13 | 13 |
14 class SkCanvas; | 14 class SkCanvas; |
15 | 15 |
| 16 namespace cc { |
| 17 class CompositorFrame; |
| 18 class CompositorFrameAck; |
| 19 } |
| 20 |
16 namespace gfx { | 21 namespace gfx { |
17 class GLSurface; | 22 class GLSurface; |
18 class Transform; | 23 class Transform; |
19 }; | 24 }; |
20 | 25 |
| 26 namespace gpu { |
| 27 class GLInProcessContext; |
| 28 } |
| 29 |
21 namespace content { | 30 namespace content { |
22 | 31 |
| 32 class SynchronousCompositorClient; |
23 class WebContents; | 33 class WebContents; |
24 | 34 |
25 class SynchronousCompositorClient; | |
26 | |
27 struct CONTENT_EXPORT SynchronousCompositorMemoryPolicy { | 35 struct CONTENT_EXPORT SynchronousCompositorMemoryPolicy { |
28 // Memory limit for rendering and pre-rendering. | 36 // Memory limit for rendering and pre-rendering. |
29 size_t bytes_limit; | 37 size_t bytes_limit; |
30 | 38 |
31 // Limit of number of GL resources used for rendering and pre-rendering. | 39 // Limit of number of GL resources used for rendering and pre-rendering. |
32 size_t num_resources_limit; | 40 size_t num_resources_limit; |
33 | 41 |
34 SynchronousCompositorMemoryPolicy(); | 42 SynchronousCompositorMemoryPolicy(); |
35 | 43 |
36 bool operator==(const SynchronousCompositorMemoryPolicy& other) const; | 44 bool operator==(const SynchronousCompositorMemoryPolicy& other) const; |
(...skipping 24 matching lines...) Expand all Loading... |
61 // first created or after ReleaseHwDraw is called. It is invalid to | 69 // first created or after ReleaseHwDraw is called. It is invalid to |
62 // DemandDrawHw before this returns true. |surface| is the GLSurface that | 70 // DemandDrawHw before this returns true. |surface| is the GLSurface that |
63 // should be used to create the underlying hardware context. | 71 // should be used to create the underlying hardware context. |
64 virtual bool InitializeHwDraw(scoped_refptr<gfx::GLSurface> surface) = 0; | 72 virtual bool InitializeHwDraw(scoped_refptr<gfx::GLSurface> surface) = 0; |
65 | 73 |
66 // Reverse of InitializeHwDraw above. Can only be called while hardware draw | 74 // Reverse of InitializeHwDraw above. Can only be called while hardware draw |
67 // is already initialized. Brings compositor back to software only mode and | 75 // is already initialized. Brings compositor back to software only mode and |
68 // releases all hardware resources. | 76 // releases all hardware resources. |
69 virtual void ReleaseHwDraw() = 0; | 77 virtual void ReleaseHwDraw() = 0; |
70 | 78 |
| 79 // Get the share context of the compositor. The returned context is owned |
| 80 // by the compositor and is only valid between InitializeHwDraw and |
| 81 // ReleaseHwDraw. |
| 82 virtual gpu::GLInProcessContext* GetShareContext() = 0; |
| 83 |
71 // "On demand" hardware draw. The content is first clipped to |damage_area|, | 84 // "On demand" hardware draw. The content is first clipped to |damage_area|, |
72 // then transformed through |transform|, and finally clipped to |view_size| | 85 // then transformed through |transform|, and finally clipped to |view_size| |
73 // and by the existing stencil buffer if any. | 86 // and by the existing stencil buffer if any. |
74 virtual bool DemandDrawHw( | 87 virtual bool DemandDrawHw(gfx::Size surface_size, |
75 gfx::Size surface_size, | 88 const gfx::Transform& transform, |
76 const gfx::Transform& transform, | 89 gfx::Rect viewport, |
77 gfx::Rect viewport, | 90 gfx::Rect clip, |
78 gfx::Rect clip, | 91 bool stencil_enabled, |
79 bool stencil_enabled) = 0; | 92 cc::CompositorFrame* frame) = 0; |
| 93 |
| 94 // For delegated rendering, return resources from parent compositor to this. |
| 95 // Note that all resources must be returned before ReleaseHwDraw. |
| 96 virtual void ReturnResources(const cc::CompositorFrameAck& frame_ack) = 0; |
80 | 97 |
81 // "On demand" SW draw, into the supplied canvas (observing the transform | 98 // "On demand" SW draw, into the supplied canvas (observing the transform |
82 // and clip set there-in). | 99 // and clip set there-in). |
83 virtual bool DemandDrawSw(SkCanvas* canvas) = 0; | 100 virtual bool DemandDrawSw(SkCanvas* canvas) = 0; |
84 | 101 |
85 // Set the memory limit policy of this compositor. | 102 // Set the memory limit policy of this compositor. |
86 virtual void SetMemoryPolicy( | 103 virtual void SetMemoryPolicy( |
87 const SynchronousCompositorMemoryPolicy& policy) = 0; | 104 const SynchronousCompositorMemoryPolicy& policy) = 0; |
88 | 105 |
89 // Should be called by the embedder after the embedder had modified the | 106 // Should be called by the embedder after the embedder had modified the |
90 // scroll offset of the root layer (as returned by | 107 // scroll offset of the root layer (as returned by |
91 // SynchronousCompositorClient::GetTotalRootLayerScrollOffset). | 108 // SynchronousCompositorClient::GetTotalRootLayerScrollOffset). |
92 virtual void DidChangeRootLayerScrollOffset() = 0; | 109 virtual void DidChangeRootLayerScrollOffset() = 0; |
93 | 110 |
94 protected: | 111 protected: |
95 virtual ~SynchronousCompositor() {} | 112 virtual ~SynchronousCompositor() {} |
96 }; | 113 }; |
97 | 114 |
98 } // namespace content | 115 } // namespace content |
99 | 116 |
100 #endif // CONTENT_PUBLIC_BROWSER_ANDROID_SYNCHRONOUS_COMPOSITOR_H_ | 117 #endif // CONTENT_PUBLIC_BROWSER_ANDROID_SYNCHRONOUS_COMPOSITOR_H_ |
OLD | NEW |