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

Side by Side Diff: third_party/WebKit/Source/platform/graphics/CanvasSurfaceLayerBridge.cpp

Issue 2036663003: Establish mojo service between Canvas (blink) and SurfaceManager (browser) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix GN build in cast_shell_linux 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
1 // Copyright 2016 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "platform/graphics/CanvasSurfaceLayerBridge.h" 5 #include "platform/graphics/CanvasSurfaceLayerBridge.h"
6 6
7 #include "cc/layers/solid_color_layer.h" 7 #include "cc/layers/surface_layer.h"
8 #include "cc/surfaces/surface_id.h"
9 #include "cc/surfaces/surface_sequence.h"
8 #include "platform/graphics/GraphicsLayer.h" 10 #include "platform/graphics/GraphicsLayer.h"
11 #include "platform/mojo/MojoHelper.h"
9 #include "public/platform/Platform.h" 12 #include "public/platform/Platform.h"
10 #include "public/platform/WebCompositorSupport.h" 13 #include "public/platform/WebCompositorSupport.h"
11 #include "public/platform/WebLayer.h" 14 #include "public/platform/WebLayer.h"
15 #include "ui/gfx/geometry/size.h"
16 #include "wtf/Functional.h"
12 17
13 namespace blink { 18 namespace blink {
14 19
15 CanvasSurfaceLayerBridge::CanvasSurfaceLayerBridge() 20 CanvasSurfaceLayerBridge::CanvasSurfaceLayerBridge(PassOwnPtr<CanvasSurfaceLayer BridgeClient> client)
16 { 21 {
17 m_solidColorLayer = cc::SolidColorLayer::Create(); 22 m_client = std::move(client);
danakj 2016/06/16 18:49:45 fwiw, normally a client would be owned by the thin
18 m_solidColorLayer->SetBackgroundColor(SK_ColorBLUE);
19 m_webLayer = adoptPtr(Platform::current()->compositorSupport()->createLayerF romCCLayer(m_solidColorLayer.get()));
20 GraphicsLayer::registerContentsLayer(m_webLayer.get());
21 } 23 }
22 24
23 CanvasSurfaceLayerBridge::~CanvasSurfaceLayerBridge() 25 CanvasSurfaceLayerBridge::~CanvasSurfaceLayerBridge()
24 { 26 {
27 m_client.reset();
25 } 28 }
26 29
30 bool CanvasSurfaceLayerBridge::createSurfaceLayer(int canvasWidth, int canvasHei ght)
31 {
32 if (!m_client->syncGetSurfaceId(&m_surfaceId))
33 return false;
34
35 m_client->asyncRequestSurfaceCreation(m_surfaceId);
36 cc::SurfaceLayer::SatisfyCallback satisfyCallback = createBaseCallback(bind< cc::SurfaceSequence>(&CanvasSurfaceLayerBridge::satisfyCallback, this));
37 cc::SurfaceLayer::RequireCallback requireCallback = createBaseCallback(bind< cc::SurfaceId, cc::SurfaceSequence>(&CanvasSurfaceLayerBridge::requireCallback, this));
38 m_surfaceLayer = cc::SurfaceLayer::Create(std::move(satisfyCallback), std::m ove(requireCallback));
39 m_surfaceLayer->SetSurfaceId(m_surfaceId, 1.f, gfx::Size(canvasWidth, canvas Height));
40
41 m_webLayer = adoptPtr(Platform::current()->compositorSupport()->createLayerF romCCLayer(m_surfaceLayer.get()));
42 GraphicsLayer::registerContentsLayer(m_webLayer.get());
43 return true;
27 } 44 }
45
46 void CanvasSurfaceLayerBridge::satisfyCallback(cc::SurfaceSequence sequence)
47 {
48 m_client->asyncSatisfy(sequence);
49 }
50
51 void CanvasSurfaceLayerBridge::requireCallback(cc::SurfaceId surfaceId, cc::Surf aceSequence sequence)
52 {
53 m_client->asyncRequire(surfaceId, sequence);
54 }
55
56 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698