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 { | 16 namespace cc { |
17 class CompositorFrame; | 17 class CompositorFrame; |
18 class CompositorFrameAck; | 18 class CompositorFrameAck; |
19 } | 19 } |
20 | 20 |
21 namespace gfx { | 21 namespace gfx { |
22 class GLSurface; | |
23 class Transform; | 22 class Transform; |
24 }; | 23 }; |
25 | 24 |
26 namespace gpu { | 25 namespace gpu { |
27 class GLInProcessContext; | 26 class GLInProcessContext; |
28 } | 27 } |
29 | 28 |
30 namespace content { | 29 namespace content { |
31 | 30 |
32 class SynchronousCompositorClient; | 31 class SynchronousCompositorClient; |
(...skipping 27 matching lines...) Expand all Loading... |
60 // being received by the client). Ownership of |client| remains with | 59 // being received by the client). Ownership of |client| remains with |
61 // the caller. | 60 // the caller. |
62 virtual void SetClient(SynchronousCompositorClient* client) = 0; | 61 virtual void SetClient(SynchronousCompositorClient* client) = 0; |
63 | 62 |
64 static void SetGpuService( | 63 static void SetGpuService( |
65 scoped_refptr<gpu::InProcessCommandBuffer::Service> service); | 64 scoped_refptr<gpu::InProcessCommandBuffer::Service> service); |
66 | 65 |
67 // Synchronously initialize compositor for hardware draw. Can only be called | 66 // Synchronously initialize compositor for hardware draw. Can only be called |
68 // while compositor is in software only mode, either after compositor is | 67 // while compositor is in software only mode, either after compositor is |
69 // first created or after ReleaseHwDraw is called. It is invalid to | 68 // first created or after ReleaseHwDraw is called. It is invalid to |
70 // DemandDrawHw before this returns true. |surface| is the GLSurface that | 69 // DemandDrawHw before this returns true. |
71 // should be used to create the underlying hardware context. | 70 virtual bool InitializeHwDraw() = 0; |
72 virtual bool InitializeHwDraw(scoped_refptr<gfx::GLSurface> surface) = 0; | |
73 | 71 |
74 // Reverse of InitializeHwDraw above. Can only be called while hardware draw | 72 // Reverse of InitializeHwDraw above. Can only be called while hardware draw |
75 // is already initialized. Brings compositor back to software only mode and | 73 // is already initialized. Brings compositor back to software only mode and |
76 // releases all hardware resources. | 74 // releases all hardware resources. |
77 virtual void ReleaseHwDraw() = 0; | 75 virtual void ReleaseHwDraw() = 0; |
78 | 76 |
79 // Get the share context of the compositor. The returned context is owned | 77 // Get the share context of the compositor. The returned context is owned |
80 // by the compositor and is only valid between InitializeHwDraw and | 78 // by the compositor and is only valid between InitializeHwDraw and |
81 // ReleaseHwDraw. | 79 // ReleaseHwDraw. |
82 virtual gpu::GLInProcessContext* GetShareContext() = 0; | 80 virtual gpu::GLInProcessContext* GetShareContext() = 0; |
83 | 81 |
84 // "On demand" hardware draw. The content is first clipped to |damage_area|, | 82 // "On demand" hardware draw. The content is first clipped to |damage_area|, |
85 // then transformed through |transform|, and finally clipped to |view_size| | 83 // then transformed through |transform|, and finally clipped to |view_size|. |
86 // and by the existing stencil buffer if any. | |
87 virtual scoped_ptr<cc::CompositorFrame> DemandDrawHw( | 84 virtual scoped_ptr<cc::CompositorFrame> DemandDrawHw( |
88 gfx::Size surface_size, | 85 gfx::Size surface_size, |
89 const gfx::Transform& transform, | 86 const gfx::Transform& transform, |
90 gfx::Rect viewport, | 87 gfx::Rect viewport, |
91 gfx::Rect clip, | 88 gfx::Rect clip) = 0; |
92 bool stencil_enabled) = 0; | |
93 | 89 |
94 // For delegated rendering, return resources from parent compositor to this. | 90 // For delegated rendering, return resources from parent compositor to this. |
95 // Note that all resources must be returned before ReleaseHwDraw. | 91 // Note that all resources must be returned before ReleaseHwDraw. |
96 virtual void ReturnResources(const cc::CompositorFrameAck& frame_ack) = 0; | 92 virtual void ReturnResources(const cc::CompositorFrameAck& frame_ack) = 0; |
97 | 93 |
98 // "On demand" SW draw, into the supplied canvas (observing the transform | 94 // "On demand" SW draw, into the supplied canvas (observing the transform |
99 // and clip set there-in). | 95 // and clip set there-in). |
100 virtual bool DemandDrawSw(SkCanvas* canvas) = 0; | 96 virtual bool DemandDrawSw(SkCanvas* canvas) = 0; |
101 | 97 |
102 // Set the memory limit policy of this compositor. | 98 // Set the memory limit policy of this compositor. |
103 virtual void SetMemoryPolicy( | 99 virtual void SetMemoryPolicy( |
104 const SynchronousCompositorMemoryPolicy& policy) = 0; | 100 const SynchronousCompositorMemoryPolicy& policy) = 0; |
105 | 101 |
106 // Should be called by the embedder after the embedder had modified the | 102 // Should be called by the embedder after the embedder had modified the |
107 // scroll offset of the root layer (as returned by | 103 // scroll offset of the root layer (as returned by |
108 // SynchronousCompositorClient::GetTotalRootLayerScrollOffset). | 104 // SynchronousCompositorClient::GetTotalRootLayerScrollOffset). |
109 virtual void DidChangeRootLayerScrollOffset() = 0; | 105 virtual void DidChangeRootLayerScrollOffset() = 0; |
110 | 106 |
111 protected: | 107 protected: |
112 virtual ~SynchronousCompositor() {} | 108 virtual ~SynchronousCompositor() {} |
113 }; | 109 }; |
114 | 110 |
115 } // namespace content | 111 } // namespace content |
116 | 112 |
117 #endif // CONTENT_PUBLIC_BROWSER_ANDROID_SYNCHRONOUS_COMPOSITOR_H_ | 113 #endif // CONTENT_PUBLIC_BROWSER_ANDROID_SYNCHRONOUS_COMPOSITOR_H_ |
OLD | NEW |