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
3 // found in the LICENSE file.
5 #ifndef CONTENT_PUBLIC_BROWSER_ANDROID_SYNCHRONOUS_COMPOSITOR_H_
6 #define CONTENT_PUBLIC_BROWSER_ANDROID_SYNCHRONOUS_COMPOSITOR_H_
8 #include "base/memory/ref_counted.h"
9 #include "content/common/content_export.h"
10 #include "gpu/command_buffer/service/in_process_command_buffer.h"
11 #include "ui/gfx/geometry/rect.h"
12 #include "ui/gfx/geometry/size.h"
17 class CompositorFrame
;
18 class CompositorFrameAck
;
26 class GLInProcessContext
;
31 class SynchronousCompositorClient
;
34 // Interface for embedders that wish to direct compositing operations
35 // synchronously under their own control. Only meaningful when the
36 // kEnableSyncrhonousRendererCompositor flag is specified.
37 class CONTENT_EXPORT SynchronousCompositor
{
39 // Must be called once per WebContents instance. Will create the compositor
40 // instance as needed, but only if |client| is non-nullptr.
41 static void SetClientForWebContents(WebContents
* contents
,
42 SynchronousCompositorClient
* client
);
44 static void SetGpuService(
45 scoped_refptr
<gpu::InProcessCommandBuffer::Service
> service
);
47 // Turn on using ipc-based command buffer at run time. This should be removed
48 // once this feature is fully launched.
49 static void SetUseIpcCommandBuffer();
51 // "On demand" hardware draw. The content is first clipped to |damage_area|,
52 // then transformed through |transform|, and finally clipped to |view_size|.
53 virtual scoped_ptr
<cc::CompositorFrame
> DemandDrawHw(
54 gfx::Size surface_size
,
55 const gfx::Transform
& transform
,
58 gfx::Rect viewport_rect_for_tile_priority
,
59 const gfx::Transform
& transform_for_tile_priority
) = 0;
61 // For delegated rendering, return resources from parent compositor to this.
62 // Note that all resources must be returned before ReleaseHwDraw.
63 virtual void ReturnResources(const cc::CompositorFrameAck
& frame_ack
) = 0;
65 // "On demand" SW draw, into the supplied canvas (observing the transform
66 // and clip set there-in).
67 virtual bool DemandDrawSw(SkCanvas
* canvas
) = 0;
69 // Set the memory limit policy of this compositor.
70 virtual void SetMemoryPolicy(size_t bytes_limit
) = 0;
72 // Should be called by the embedder after the embedder had modified the
73 // scroll offset of the root layer (as returned by
74 // SynchronousCompositorClient::GetTotalRootLayerScrollOffset).
75 virtual void DidChangeRootLayerScrollOffset() = 0;
77 // Called by the embedder to notify that the compositor is active. The
78 // compositor won't ask for vsyncs when it's inactive. NOTE: The compositor
79 // starts off as inactive and needs a SetActive(true) call to begin.
80 virtual void SetIsActive(bool is_active
) = 0;
82 // Called by the embedder to notify that the OnComputeScroll step is happening
83 // and if any input animation is active, it should tick now.
84 virtual void OnComputeScroll(base::TimeTicks animation_time
) = 0;
87 virtual ~SynchronousCompositor() {}
90 } // namespace content
92 #endif // CONTENT_PUBLIC_BROWSER_ANDROID_SYNCHRONOUS_COMPOSITOR_H_