blob: cf7d1d6b06c693a072af5e1138ee0ec85fd47d98 [file] [log] [blame]
// Copyright 2016 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.
#include <map>
#include "android_webview/browser/child_frame.h"
#include "android_webview/browser/compositor_id.h"
#include "android_webview/browser/parent_compositor_draw_constraints.h"
#include "cc/resources/returned_resource.h"
#include "content/public/browser/android/synchronous_compositor.h"
#include "ui/gfx/geometry/vector2d.h"
namespace android_webview {
class ChildFrame;
class CompositorFrameProducer;
class CompositorFrameConsumer {
struct ReturnedResources {
uint32_t compositor_frame_sink_id;
cc::ReturnedResourceArray resources;
using ReturnedResourcesMap =
std::map<CompositorID, ReturnedResources, CompositorIDComparator>;
// A CompositorFrameConsumer may be registered with at most one
// CompositorFrameProducer.
// The producer is responsible for managing the relationship with its
// consumers. The only exception to this is when a consumer is explicitly
// destroyed, at which point it needs to inform its producer.
// In order to register a consumer with a new producer, the current producer
// must unregister the consumer, and call SetCompositorProducer(nullptr).
virtual void SetCompositorFrameProducer(
CompositorFrameProducer* compositor_frame_producer) = 0;
virtual void SetScrollOffsetOnUI(gfx::Vector2d scroll_offset) = 0;
// Returns uncommitted frame to be returned, if any.
virtual std::unique_ptr<ChildFrame> SetFrameOnUI(
std::unique_ptr<ChildFrame> frame) = 0;
virtual void InitializeHardwareDrawIfNeededOnUI() = 0;
virtual ParentCompositorDrawConstraints GetParentDrawConstraintsOnUI()
const = 0;
virtual void SwapReturnedResourcesOnUI(
ReturnedResourcesMap* returned_resource_map) = 0;
virtual bool ReturnedResourcesEmptyOnUI() const = 0;
virtual ChildFrameQueue PassUncommittedFrameOnUI() = 0;
virtual bool HasFrameOnUI() const = 0;
virtual void DeleteHardwareRendererOnUI() = 0;
virtual ~CompositorFrameConsumer() {}
} // namespace android_webview