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

Unified 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: OWNERS change on offscreencanvas folder 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: third_party/WebKit/Source/platform/graphics/CanvasSurfaceLayerBridge.cpp
diff --git a/third_party/WebKit/Source/platform/graphics/CanvasSurfaceLayerBridge.cpp b/third_party/WebKit/Source/platform/graphics/CanvasSurfaceLayerBridge.cpp
index 03926147fbe145186792c2cc665dd285f81227be..222cbb6c999dacfdb3b7278153644a7e9782de3f 100644
--- a/third_party/WebKit/Source/platform/graphics/CanvasSurfaceLayerBridge.cpp
+++ b/third_party/WebKit/Source/platform/graphics/CanvasSurfaceLayerBridge.cpp
@@ -4,25 +4,53 @@
#include "platform/graphics/CanvasSurfaceLayerBridge.h"
-#include "cc/layers/solid_color_layer.h"
+#include "cc/layers/surface_layer.h"
+#include "cc/surfaces/surface_id.h"
+#include "cc/surfaces/surface_sequence.h"
#include "platform/graphics/GraphicsLayer.h"
+#include "platform/mojo/MojoHelper.h"
#include "public/platform/Platform.h"
#include "public/platform/WebCompositorSupport.h"
#include "public/platform/WebLayer.h"
+#include "ui/gfx/geometry/size.h"
+#include "wtf/Functional.h"
#include "wtf/PtrUtil.h"
namespace blink {
-CanvasSurfaceLayerBridge::CanvasSurfaceLayerBridge()
+CanvasSurfaceLayerBridge::CanvasSurfaceLayerBridge(std::unique_ptr<CanvasSurfaceLayerBridgeClient> client)
{
- m_solidColorLayer = cc::SolidColorLayer::Create();
- m_solidColorLayer->SetBackgroundColor(SK_ColorBLUE);
- m_webLayer = wrapUnique(Platform::current()->compositorSupport()->createLayerFromCCLayer(m_solidColorLayer.get()));
- GraphicsLayer::registerContentsLayer(m_webLayer.get());
+ m_client = std::move(client);
}
CanvasSurfaceLayerBridge::~CanvasSurfaceLayerBridge()
{
}
+bool CanvasSurfaceLayerBridge::createSurfaceLayer(int canvasWidth, int canvasHeight)
+{
+ if (!m_client->syncGetSurfaceId(&m_surfaceId))
+ return false;
+
+ m_client->asyncRequestSurfaceCreation(m_surfaceId);
+ cc::SurfaceLayer::SatisfyCallback satisfyCallback = createBaseCallback(bind<cc::SurfaceSequence>(&CanvasSurfaceLayerBridge::satisfyCallback, this));
+ cc::SurfaceLayer::RequireCallback requireCallback = createBaseCallback(bind<cc::SurfaceId, cc::SurfaceSequence>(&CanvasSurfaceLayerBridge::requireCallback, this));
+ m_surfaceLayer = cc::SurfaceLayer::Create(std::move(satisfyCallback), std::move(requireCallback));
+ m_surfaceLayer->SetSurfaceId(m_surfaceId, 1.f, gfx::Size(canvasWidth, canvasHeight));
+
+ m_webLayer = wrapUnique(Platform::current()->compositorSupport()->createLayerFromCCLayer(m_surfaceLayer.get()));
+ GraphicsLayer::registerContentsLayer(m_webLayer.get());
+ return true;
+}
+
+void CanvasSurfaceLayerBridge::satisfyCallback(cc::SurfaceSequence sequence)
+{
+ m_client->asyncSatisfy(sequence);
+}
+
+void CanvasSurfaceLayerBridge::requireCallback(cc::SurfaceId surfaceId, cc::SurfaceSequence sequence)
+{
+ m_client->asyncRequire(surfaceId, sequence);
}
+
+} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698