synchronous_compositor.h revision 7d4cd473f85ac64c3747c96c277f9e506a0d2246
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.
4
5#ifndef CONTENT_PUBLIC_BROWSER_ANDROID_SYNCHRONOUS_COMPOSITOR_H_
6#define CONTENT_PUBLIC_BROWSER_ANDROID_SYNCHRONOUS_COMPOSITOR_H_
7
8#include "content/common/content_export.h"
9#include "ui/gfx/rect.h"
10#include "ui/gfx/size.h"
11
12class SkCanvas;
13
14namespace gfx {
15class Transform;
16};
17
18namespace content {
19
20class WebContents;
21
22class SynchronousCompositorClient;
23
24// Interface for embedders that wish to direct compositing operations
25// synchronously under their own control. Only meaningful when the
26// kEnableSyncrhonousRendererCompositor flag is specified.
27class CONTENT_EXPORT SynchronousCompositor {
28 public:
29  // Must be called once per WebContents instance. Will create the compositor
30  // instance as needed, but only if |client| is non-NULL.
31  static void SetClientForWebContents(WebContents* contents,
32                                      SynchronousCompositorClient* client);
33
34  // Allows changing or resetting the client to NULL (this must be used if
35  // the client is being deleted prior to the DidDestroyCompositor() call
36  // being received by the client). Ownership of |client| remains with
37  // the caller.
38  virtual void SetClient(SynchronousCompositorClient* client) = 0;
39
40  // One-time synchronously initialize compositor for hardware draw.
41  // It is invalid to DemandDrawHw before this returns true.
42  virtual bool InitializeHwDraw() = 0;
43
44  // "On demand" hardware draw. The content is first clipped to |damage_area|,
45  // then transformed through |transform|, and finally clipped to |view_size|.
46  virtual bool DemandDrawHw(
47      gfx::Size view_size,
48      const gfx::Transform& transform,
49      gfx::Rect damage_area) = 0;
50
51  // "On demand" SW draw, into the supplied canvas (observing the transform
52  // and clip set there-in).
53  virtual bool DemandDrawSw(SkCanvas* canvas) = 0;
54
55  // Should be called by the embedder after the embedder had modified the
56  // scroll offset of the root layer (as returned by
57  // SynchronousCompositorClient::GetTotalRootLayerScrollOffset).
58  virtual void DidChangeRootLayerScrollOffset() = 0;
59
60 protected:
61  virtual ~SynchronousCompositor() {}
62};
63
64}  // namespace content
65
66#endif  // CONTENT_PUBLIC_BROWSER_ANDROID_SYNCHRONOUS_COMPOSITOR_H_
67