| Index: content/browser/renderer_host/offscreen_canvas_compositor_frame_sink.cc
|
| diff --git a/content/browser/renderer_host/offscreen_canvas_compositor_frame_sink.cc b/content/browser/renderer_host/offscreen_canvas_compositor_frame_sink.cc
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..96863d42fbb91a76f8a438f6b4a55e1bcad64cd7
|
| --- /dev/null
|
| +++ b/content/browser/renderer_host/offscreen_canvas_compositor_frame_sink.cc
|
| @@ -0,0 +1,73 @@
|
| +// 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 "content/browser/renderer_host/offscreen_canvas_compositor_frame_sink.h"
|
| +
|
| +#include "cc/surfaces/surface.h"
|
| +#include "cc/surfaces/surface_manager.h"
|
| +#include "content/browser/compositor/surface_utils.h"
|
| +#include "mojo/public/cpp/bindings/strong_binding.h"
|
| +
|
| +namespace content {
|
| +
|
| +OffscreenCanvasCompositorFrameSink::OffscreenCanvasCompositorFrameSink(
|
| + const cc::SurfaceId& surface_id,
|
| + cc::mojom::MojoCompositorFrameSinkClientPtr client)
|
| + : surface_id_(surface_id), client_(std::move(client)) {}
|
| +
|
| +OffscreenCanvasCompositorFrameSink::~OffscreenCanvasCompositorFrameSink() {
|
| + if (surface_factory_) {
|
| + if (!GetSurfaceManager()) {
|
| + // Inform SurfaceFactory that SurfaceManager's no longer alive to
|
| + // avoid its destruction error.
|
| + surface_factory_->DidDestroySurfaceManager();
|
| + } else {
|
| + GetSurfaceManager()->InvalidateSurfaceClientId(surface_id_.client_id());
|
| + }
|
| + surface_factory_->Destroy(surface_id_);
|
| + }
|
| +}
|
| +
|
| +// static
|
| +void OffscreenCanvasCompositorFrameSink::Create(
|
| + const cc::SurfaceId& surface_id,
|
| + cc::mojom::MojoCompositorFrameSinkClientPtr client,
|
| + cc::mojom::MojoCompositorFrameSinkRequest request) {
|
| + mojo::MakeStrongBinding(base::MakeUnique<OffscreenCanvasCompositorFrameSink>(
|
| + surface_id, std::move(client)),
|
| + std::move(request));
|
| +}
|
| +
|
| +void OffscreenCanvasCompositorFrameSink::SubmitCompositorFrame(
|
| + cc::CompositorFrame frame,
|
| + const SubmitCompositorFrameCallback& callback) {
|
| + if (!surface_factory_) {
|
| + cc::SurfaceManager* manager = GetSurfaceManager();
|
| + surface_factory_ = base::MakeUnique<cc::SurfaceFactory>(manager, this);
|
| + surface_factory_->Create(surface_id_);
|
| +
|
| + GetSurfaceManager()->RegisterSurfaceClientId(surface_id_.client_id());
|
| + }
|
| + surface_factory_->SubmitCompositorFrame(surface_id_, std::move(frame),
|
| + callback);
|
| +}
|
| +
|
| +void OffscreenCanvasCompositorFrameSink::SetNeedsBeginFrame(
|
| + bool needs_begin_frame) {
|
| + NOTIMPLEMENTED();
|
| +}
|
| +
|
| +void OffscreenCanvasCompositorFrameSink::ReturnResources(
|
| + const cc::ReturnedResourceArray& resources) {
|
| + client_->ReturnResources(resources);
|
| +}
|
| +
|
| +void OffscreenCanvasCompositorFrameSink::WillDrawSurface(
|
| + const cc::SurfaceId& id,
|
| + const gfx::Rect& damage_rect) {}
|
| +
|
| +void OffscreenCanvasCompositorFrameSink::SetBeginFrameSource(
|
| + cc::BeginFrameSource* begin_frame_source) {}
|
| +
|
| +} // namespace content
|
|
|