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

Unified Diff: third_party/WebKit/Source/platform/graphics/CanvasSurfaceLayerBridge.cpp

Issue 2588053003: Make OffscreenCanvas resizable (Closed)
Patch Set: rebase Created 4 years 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 036fc0411927af6f370b3f6bd188e9df12fbde74..028055ba6af67633e01f76b89b384e9825257b4f 100644
--- a/third_party/WebKit/Source/platform/graphics/CanvasSurfaceLayerBridge.cpp
+++ b/third_party/WebKit/Source/platform/graphics/CanvasSurfaceLayerBridge.cpp
@@ -89,13 +89,13 @@ void CanvasSurfaceLayerBridge::OnSurfaceCreated(const cc::SurfaceId& surfaceId,
int32_t height,
float deviceScaleFactor) {
if (!m_currentSurfaceId.is_valid() && surfaceId.is_valid()) {
+ // First time a SurfaceId is received
m_currentSurfaceId = surfaceId;
GraphicsLayer::unregisterContentsLayer(m_webLayer.get());
m_webLayer->removeFromParent();
scoped_refptr<cc::SurfaceLayer> surfaceLayer =
cc::SurfaceLayer::Create(m_refFactory);
- // TODO(xlai): Update this on resize.
cc::SurfaceInfo info(surfaceId, deviceScaleFactor,
gfx::Size(width, height));
surfaceLayer->SetSurfaceInfo(
@@ -106,9 +106,20 @@ void CanvasSurfaceLayerBridge::OnSurfaceCreated(const cc::SurfaceId& surfaceId,
Platform::current()->compositorSupport()->createLayerFromCCLayer(
m_CCLayer.get());
GraphicsLayer::registerContentsLayer(m_webLayer.get());
-
- m_observer->OnWebLayerReplaced();
+ } else if (m_currentSurfaceId != surfaceId) {
+ // A different SurfaceId is received, prompting change to existing
+ // SurfaceLayer
+ m_currentSurfaceId = surfaceId;
+ cc::SurfaceInfo info(m_currentSurfaceId, deviceScaleFactor,
+ gfx::Size(width, height));
+ cc::SurfaceLayer* surfaceLayer =
+ static_cast<cc::SurfaceLayer*>(m_CCLayer.get());
+ surfaceLayer->SetSurfaceInfo(
+ info, true /* scale layer bounds with surface size */);
}
+
+ m_observer->OnWebLayerReplaced();
+ m_CCLayer->SetBounds(gfx::Size(width, height));
}
void CanvasSurfaceLayerBridge::satisfyCallback(

Powered by Google App Engine
This is Rietveld 408576698