Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(447)

Unified Diff: content/browser/renderer_host/offscreen_canvas_compositor_frame_sink.cc

Issue 2328463004: Implement WebGL's commit on the main thread (Closed)
Patch Set: fix compile error on win_dbg Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..8225f0c13b36d0cc0b768d765ebcf5b32e2c7f79
--- /dev/null
+++ b/content/browser/renderer_host/offscreen_canvas_compositor_frame_sink.cc
@@ -0,0 +1,74 @@
+// 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_) {
+ cc::SurfaceManager* manager = GetSurfaceManager();
+ if (!manager) {
+ // Inform SurfaceFactory that SurfaceManager's no longer alive to
+ // avoid its destruction error.
+ surface_factory_->DidDestroySurfaceManager();
+ } else {
+ manager->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_);
+
+ manager->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

Powered by Google App Engine
This is Rietveld 408576698