summaryrefslogtreecommitdiffstats
path: root/content/renderer/gpu/render_widget_compositor_delegate.h
blob: 94ed1e68c5df39396865e0ca44a7c603cf1c2fb3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef CONTENT_RENDERER_GPU_RENDER_WIDGET_COMPOSITOR_DELEGATE_H_
#define CONTENT_RENDERER_GPU_RENDER_WIDGET_COMPOSITOR_DELEGATE_H_

#include "cc/debug/frame_timing_tracker.h"

namespace blink {
class WebWidget;
struct WebScreenInfo;
}

namespace cc {
class BeginFrameSource;
class OutputSurface;
}

namespace content {

// Consumers of RenderWidgetCompositor implement this delegate in order to
// transport compositing information across processes.
class CONTENT_EXPORT RenderWidgetCompositorDelegate {
 public:
  // Report viewport related properties during a commit from the compositor
  // thread.
  virtual void ApplyViewportDeltas(
      const gfx::Vector2dF& inner_delta,
      const gfx::Vector2dF& outer_delta,
      const gfx::Vector2dF& elastic_overscroll_delta,
      float page_scale,
      float top_controls_delta) = 0;

  // Notifies that the compositor has issed a BeginMainFrame.
  virtual void BeginMainFrame(double frame_time_sec) = 0;

  // Requests an OutputSurface to render into.
  virtual scoped_ptr<cc::OutputSurface> CreateOutputSurface(bool fallback) = 0;

  // Requests an external BeginFrameSource from the delegate.
  virtual scoped_ptr<cc::BeginFrameSource> CreateExternalBeginFrameSource() = 0;

  // Notifies that the draw commands for a committed frame have been issued.
  virtual void DidCommitAndDrawCompositorFrame() = 0;

  // Notifies about a compositor frame commit operation having finished.
  virtual void DidCommitCompositorFrame() = 0;

  // Called by the compositor when page scale animation completed.
  virtual void DidCompletePageScaleAnimation() = 0;

  // Notifies that the compositor has posted a swapbuffers operation to the GPU
  // process.
  virtual void DidCompleteSwapBuffers() = 0;

  // TODO(simonhong, fsamuel): Remove this once crbug.com/471411 is resolved.
  // Indicates whether this RenderWidgetCompositor is for an out-of-process
  // iframe or not.
  virtual bool ForOOPIF() const = 0;

  // Called by the compositor to forward a proto that represents serialized
  // compositor state.
  virtual void ForwardCompositorProto(const std::vector<uint8_t>& proto) = 0;

  // Indicates whether the RenderWidgetCompositor is about to close.
  virtual bool IsClosing() const = 0;

  // Called by the compositor in single-threaded mode when a swap is aborted.
  virtual void OnSwapBuffersAborted() = 0;

  // Called by the compositor in single-threaded mode when a swap completes.
  virtual void OnSwapBuffersComplete() = 0;

  // Called by the compositor in single-threaded mode when a swap is posted.
  virtual void OnSwapBuffersPosted() = 0;

  // Called by the compositor to request the delegate to record frame timing.
  virtual void RecordFrameTimingEvents(
      scoped_ptr<cc::FrameTimingTracker::CompositeTimingSet> composite_events,
      scoped_ptr<cc::FrameTimingTracker::MainFrameTimingSet>
          main_frame_events) = 0;

  // Requests that the client schedule a composite now, and calculate
  // appropriate delay for potential future frame.
  virtual void ScheduleAnimation() = 0;

  // Requests a visual frame-based update to the state of the delegate if there
  // an update available.
  virtual void UpdateVisualState() = 0;

  // Indicates that the compositor is about to begin a frame. This is primarily
  // to signal to flow control mechanisms that a frame is beginning, not to
  // perform actual painting work.
  virtual void WillBeginCompositorFrame() = 0;

 protected:
  virtual ~RenderWidgetCompositorDelegate() {}
};

}  // namespace content

#endif  // CONTENT_RENDERER_GPU_RENDER_WIDGET_COMPOSITOR_DELEGATE_H_