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

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

Issue 2036663003: Establish mojo service between Canvas (blink) and SurfaceManager (browser) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Throw away typemaps in Blink Created 4 years, 6 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_surface_service_impl.cc
diff --git a/content/browser/renderer_host/offscreen_canvas_surface_service_impl.cc b/content/browser/renderer_host/offscreen_canvas_surface_service_impl.cc
new file mode 100644
index 0000000000000000000000000000000000000000..e46046ba6b557b30c0095af47c7738e4482f0bc3
--- /dev/null
+++ b/content/browser/renderer_host/offscreen_canvas_surface_service_impl.cc
@@ -0,0 +1,85 @@
+// 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_surface_service_impl.h"
+
+#include "base/bind_helpers.h"
+#include "cc/surfaces/surface.h"
+#include "cc/surfaces/surface_manager.h"
+#include "content/browser/compositor/surface_utils.h"
+#include "content/public/browser/browser_thread.h"
+
+namespace content {
+
+// static
+void OffscreenCanvasSurfaceServiceImpl::Create(
+ mojo::InterfaceRequest<blink::mojom::OffscreenCanvasSurfaceService>
+ request) {
+ // |binding_| will take ownership of OffscreenCanvasSurfaceServiceImpl
+ new OffscreenCanvasSurfaceServiceImpl(std::move(request));
+}
+
+OffscreenCanvasSurfaceServiceImpl::OffscreenCanvasSurfaceServiceImpl(
+ mojo::InterfaceRequest<blink::mojom::OffscreenCanvasSurfaceService> request)
+ : binding_(this, std::move(request)) {
+ id_allocator_ = CreateSurfaceIdAllocator();
dcheng 2016/06/14 09:56:44 Nit: Put this in the init list for consistency?
xlai (Olivia) 2016/06/14 21:10:17 Done.
+}
+
+OffscreenCanvasSurfaceServiceImpl::~OffscreenCanvasSurfaceServiceImpl() {
+ if (surface_factory_) {
+ surface_factory_->DestroyAll();
+ }
+}
+
+void OffscreenCanvasSurfaceServiceImpl::GetSurfaceId(
+ const GetSurfaceIdCallback& callback) {
+ DCHECK_CURRENTLY_ON(BrowserThread::UI);
+
+ cc::SurfaceId surface_id = id_allocator_->GenerateId();
+
+ callback.Run(std::move(surface_id));
dcheng 2016/06/14 09:56:44 I don't think std::move() here has any effect, unl
xlai (Olivia) 2016/06/14 21:10:17 Done.
+}
+
+void OffscreenCanvasSurfaceServiceImpl::RequestSurfaceCreation(
+ const cc::SurfaceId& surface_id) {
+ cc::SurfaceManager* manager = GetSurfaceManager();
+ if (!surface_factory_) {
+ surface_factory_ = base::WrapUnique(new cc::SurfaceFactory(manager, this));
dcheng 2016/06/14 09:56:44 Nit: base::MakeUnique<cc::SurfaceFactory>(manager,
xlai (Olivia) 2016/06/14 21:10:17 Done.
+ }
+ surface_factory_->Create(surface_id);
+}
+
+void OffscreenCanvasSurfaceServiceImpl::Require(
+ const cc::SurfaceId& surface_id,
+ const cc::SurfaceSequence& sequence) {
+ cc::SurfaceManager* manager = GetSurfaceManager();
+ cc::Surface* surface = manager->GetSurfaceForId(surface_id);
+ if (!surface) {
+ LOG(ERROR) << "Attempting to require callback on nonexistent surface";
piman 2016/06/14 00:28:58 nit: DLOG
xlai (Olivia) 2016/06/14 21:10:17 Done.
+ return;
+ }
+ surface->AddDestructionDependency(sequence);
+}
+
+void OffscreenCanvasSurfaceServiceImpl::Satisfy(
+ const cc::SurfaceSequence& sequence) {
+ std::vector<uint32_t> sequences;
+ sequences.push_back(sequence.sequence);
+ cc::SurfaceManager* manager = GetSurfaceManager();
+ manager->DidSatisfySequences(sequence.id_namespace, &sequences);
+}
+
+// TODO(619136): Implement cc::SurfaceFactoryClient functions for resources
+// return.
+void OffscreenCanvasSurfaceServiceImpl::ReturnResources(
+ const cc::ReturnedResourceArray& resources) {}
+
+void OffscreenCanvasSurfaceServiceImpl::WillDrawSurface(
+ cc::SurfaceId id,
+ const gfx::Rect& damage_rect) {}
+
+void OffscreenCanvasSurfaceServiceImpl::SetBeginFrameSource(
+ cc::BeginFrameSource* begin_frame_source) {}
+
+} // namespace content

Powered by Google App Engine
This is Rietveld 408576698