| OLD | NEW |
| 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/layer.h" | 7 #include "cc/layers/layer.h" |
| 8 #include "cc/layers/solid_color_layer.h" | 8 #include "cc/layers/solid_color_layer.h" |
| 9 #include "cc/layers/surface_layer.h" | 9 #include "cc/layers/surface_layer.h" |
| 10 #include "cc/surfaces/sequence_surface_reference_factory.h" | 10 #include "cc/surfaces/sequence_surface_reference_factory.h" |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 void CanvasSurfaceLayerBridge::OnSurfaceCreated( | 87 void CanvasSurfaceLayerBridge::OnSurfaceCreated( |
| 88 const cc::SurfaceInfo& surfaceInfo) { | 88 const cc::SurfaceInfo& surfaceInfo) { |
| 89 if (!m_currentSurfaceId.is_valid() && surfaceInfo.id().is_valid()) { | 89 if (!m_currentSurfaceId.is_valid() && surfaceInfo.id().is_valid()) { |
| 90 // First time a SurfaceId is received | 90 // First time a SurfaceId is received |
| 91 m_currentSurfaceId = surfaceInfo.id(); | 91 m_currentSurfaceId = surfaceInfo.id(); |
| 92 GraphicsLayer::unregisterContentsLayer(m_webLayer.get()); | 92 GraphicsLayer::unregisterContentsLayer(m_webLayer.get()); |
| 93 m_webLayer->removeFromParent(); | 93 m_webLayer->removeFromParent(); |
| 94 | 94 |
| 95 scoped_refptr<cc::SurfaceLayer> surfaceLayer = | 95 scoped_refptr<cc::SurfaceLayer> surfaceLayer = |
| 96 cc::SurfaceLayer::Create(m_refFactory); | 96 cc::SurfaceLayer::Create(m_refFactory); |
| 97 surfaceLayer->SetSurfaceInfo( | 97 surfaceLayer->SetSurfaceInfo(surfaceInfo); |
| 98 surfaceInfo, true /* scale layer bounds with surface size */); | 98 surfaceLayer->SetStretchContentToFillBounds(true); |
| 99 m_CCLayer = surfaceLayer; | 99 m_CCLayer = surfaceLayer; |
| 100 | 100 |
| 101 m_webLayer = | 101 m_webLayer = |
| 102 Platform::current()->compositorSupport()->createLayerFromCCLayer( | 102 Platform::current()->compositorSupport()->createLayerFromCCLayer( |
| 103 m_CCLayer.get()); | 103 m_CCLayer.get()); |
| 104 GraphicsLayer::registerContentsLayer(m_webLayer.get()); | 104 GraphicsLayer::registerContentsLayer(m_webLayer.get()); |
| 105 } else if (m_currentSurfaceId != surfaceInfo.id()) { | 105 } else if (m_currentSurfaceId != surfaceInfo.id()) { |
| 106 // A different SurfaceId is received, prompting change to existing | 106 // A different SurfaceId is received, prompting change to existing |
| 107 // SurfaceLayer | 107 // SurfaceLayer |
| 108 m_currentSurfaceId = surfaceInfo.id(); | 108 m_currentSurfaceId = surfaceInfo.id(); |
| 109 cc::SurfaceLayer* surfaceLayer = | 109 cc::SurfaceLayer* surfaceLayer = |
| 110 static_cast<cc::SurfaceLayer*>(m_CCLayer.get()); | 110 static_cast<cc::SurfaceLayer*>(m_CCLayer.get()); |
| 111 surfaceLayer->SetSurfaceInfo( | 111 surfaceLayer->SetSurfaceInfo(surfaceInfo); |
| 112 surfaceInfo, true /* scale layer bounds with surface size */); | |
| 113 } | 112 } |
| 114 | 113 |
| 115 m_observer->OnWebLayerReplaced(); | 114 m_observer->OnWebLayerReplaced(); |
| 116 m_CCLayer->SetBounds(surfaceInfo.size_in_pixels()); | 115 m_CCLayer->SetBounds(surfaceInfo.size_in_pixels()); |
| 117 } | 116 } |
| 118 | 117 |
| 119 void CanvasSurfaceLayerBridge::satisfyCallback( | 118 void CanvasSurfaceLayerBridge::satisfyCallback( |
| 120 const cc::SurfaceSequence& sequence) { | 119 const cc::SurfaceSequence& sequence) { |
| 121 m_service->Satisfy(sequence); | 120 m_service->Satisfy(sequence); |
| 122 } | 121 } |
| 123 | 122 |
| 124 void CanvasSurfaceLayerBridge::requireCallback( | 123 void CanvasSurfaceLayerBridge::requireCallback( |
| 125 const cc::SurfaceId& surfaceId, | 124 const cc::SurfaceId& surfaceId, |
| 126 const cc::SurfaceSequence& sequence) { | 125 const cc::SurfaceSequence& sequence) { |
| 127 m_service->Require(surfaceId, sequence); | 126 m_service->Require(surfaceId, sequence); |
| 128 } | 127 } |
| 129 | 128 |
| 130 } // namespace blink | 129 } // namespace blink |
| OLD | NEW |