blob: 5d4ac51bae8f7f2f59f51eaa8ce968f11a87f140 [file] [log] [blame]
// 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 SERVICES_UI_SURFACES_GPU_COMPOSITOR_FRAME_SINK_H_
#define SERVICES_UI_SURFACES_GPU_COMPOSITOR_FRAME_SINK_H_
#include <memory>
#include <vector>
#include "base/macros.h"
#include "base/memory/weak_ptr.h"
#include "cc/ipc/mojo_compositor_frame_sink.mojom.h"
#include "cc/surfaces/compositor_frame_sink_support.h"
#include "cc/surfaces/compositor_frame_sink_support_client.h"
#include "mojo/public/cpp/bindings/binding.h"
namespace cc {
class Display;
}
namespace ui {
class DisplayCompositor;
// Server side representation of a WindowSurface.
class GpuCompositorFrameSink
: public cc::CompositorFrameSinkSupportClient,
public cc::mojom::MojoCompositorFrameSink,
public cc::mojom::MojoCompositorFrameSinkPrivate {
public:
GpuCompositorFrameSink(
DisplayCompositor* display_compositor,
const cc::FrameSinkId& frame_sink_id,
std::unique_ptr<cc::Display> display,
cc::mojom::MojoCompositorFrameSinkRequest request,
cc::mojom::MojoCompositorFrameSinkPrivateRequest private_request,
cc::mojom::MojoCompositorFrameSinkClientPtr client);
~GpuCompositorFrameSink() override;
// cc::mojom::MojoCompositorFrameSink:
void EvictFrame() override;
void SetNeedsBeginFrame(bool needs_begin_frame) override;
void SubmitCompositorFrame(const cc::LocalFrameId& local_frame_id,
cc::CompositorFrame frame) override;
void AddSurfaceReferences(
const std::vector<cc::SurfaceReference>& references) override;
void RemoveSurfaceReferences(
const std::vector<cc::SurfaceReference>& references) override;
void Require(const cc::LocalFrameId& local_frame_id,
const cc::SurfaceSequence& sequence) override;
void Satisfy(const cc::SurfaceSequence& sequence) override;
// cc::mojom::MojoCompositorFrameSinkPrivate:
void AddChildFrameSink(const cc::FrameSinkId& child_frame_sink_id) override;
void RemoveChildFrameSink(
const cc::FrameSinkId& child_frame_sink_id) override;
private:
// cc::CompositorFrameSinkSupportClient implementation:
void DidReceiveCompositorFrameAck() override;
void OnBeginFrame(const cc::BeginFrameArgs& args) override;
void ReclaimResources(const cc::ReturnedResourceArray& resources) override;
void WillDrawSurface() override;
void OnClientConnectionLost();
void OnPrivateConnectionLost();
DisplayCompositor* const display_compositor_;
cc::CompositorFrameSinkSupport support_;
bool client_connection_lost_ = false;
bool private_connection_lost_ = false;
cc::mojom::MojoCompositorFrameSinkClientPtr client_;
mojo::Binding<cc::mojom::MojoCompositorFrameSink> binding_;
mojo::Binding<cc::mojom::MojoCompositorFrameSinkPrivate> private_binding_;
DISALLOW_COPY_AND_ASSIGN(GpuCompositorFrameSink);
};
} // namespace ui
#endif // SERVICES_UI_SURFACES_GPU_COMPOSITOR_FRAME_SINK_H_