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

Side by Side 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "content/browser/renderer_host/offscreen_canvas_surface_service_impl.h"
6
7 #include "base/bind_helpers.h"
8 #include "cc/surfaces/surface.h"
9 #include "cc/surfaces/surface_manager.h"
10 #include "content/browser/compositor/surface_utils.h"
11 #include "content/public/browser/browser_thread.h"
12
13 namespace content {
14
15 // static
16 void OffscreenCanvasSurfaceServiceImpl::Create(
17 mojo::InterfaceRequest<blink::mojom::OffscreenCanvasSurfaceService>
18 request) {
19 // |binding_| will take ownership of OffscreenCanvasSurfaceServiceImpl
20 new OffscreenCanvasSurfaceServiceImpl(std::move(request));
21 }
22
23 OffscreenCanvasSurfaceServiceImpl::OffscreenCanvasSurfaceServiceImpl(
24 mojo::InterfaceRequest<blink::mojom::OffscreenCanvasSurfaceService> request)
25 : binding_(this, std::move(request)) {
26 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.
27 }
28
29 OffscreenCanvasSurfaceServiceImpl::~OffscreenCanvasSurfaceServiceImpl() {
30 if (surface_factory_) {
31 surface_factory_->DestroyAll();
32 }
33 }
34
35 void OffscreenCanvasSurfaceServiceImpl::GetSurfaceId(
36 const GetSurfaceIdCallback& callback) {
37 DCHECK_CURRENTLY_ON(BrowserThread::UI);
38
39 cc::SurfaceId surface_id = id_allocator_->GenerateId();
40
41 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.
42 }
43
44 void OffscreenCanvasSurfaceServiceImpl::RequestSurfaceCreation(
45 const cc::SurfaceId& surface_id) {
46 cc::SurfaceManager* manager = GetSurfaceManager();
47 if (!surface_factory_) {
48 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.
49 }
50 surface_factory_->Create(surface_id);
51 }
52
53 void OffscreenCanvasSurfaceServiceImpl::Require(
54 const cc::SurfaceId& surface_id,
55 const cc::SurfaceSequence& sequence) {
56 cc::SurfaceManager* manager = GetSurfaceManager();
57 cc::Surface* surface = manager->GetSurfaceForId(surface_id);
58 if (!surface) {
59 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.
60 return;
61 }
62 surface->AddDestructionDependency(sequence);
63 }
64
65 void OffscreenCanvasSurfaceServiceImpl::Satisfy(
66 const cc::SurfaceSequence& sequence) {
67 std::vector<uint32_t> sequences;
68 sequences.push_back(sequence.sequence);
69 cc::SurfaceManager* manager = GetSurfaceManager();
70 manager->DidSatisfySequences(sequence.id_namespace, &sequences);
71 }
72
73 // TODO(619136): Implement cc::SurfaceFactoryClient functions for resources
74 // return.
75 void OffscreenCanvasSurfaceServiceImpl::ReturnResources(
76 const cc::ReturnedResourceArray& resources) {}
77
78 void OffscreenCanvasSurfaceServiceImpl::WillDrawSurface(
79 cc::SurfaceId id,
80 const gfx::Rect& damage_rect) {}
81
82 void OffscreenCanvasSurfaceServiceImpl::SetBeginFrameSource(
83 cc::BeginFrameSource* begin_frame_source) {}
84
85 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698