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 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
81 m_CCLayer->SetBackgroundColor(SK_ColorTRANSPARENT); | 81 m_CCLayer->SetBackgroundColor(SK_ColorTRANSPARENT); |
82 m_webLayer = Platform::current()->compositorSupport()->createLayerFromCCLayer( | 82 m_webLayer = Platform::current()->compositorSupport()->createLayerFromCCLayer( |
83 m_CCLayer.get()); | 83 m_CCLayer.get()); |
84 GraphicsLayer::registerContentsLayer(m_webLayer.get()); | 84 GraphicsLayer::registerContentsLayer(m_webLayer.get()); |
85 } | 85 } |
86 | 86 |
87 void CanvasSurfaceLayerBridge::OnSurfaceCreated(const cc::SurfaceId& surfaceId, | 87 void CanvasSurfaceLayerBridge::OnSurfaceCreated(const cc::SurfaceId& surfaceId, |
88 int32_t width, | 88 int32_t width, |
89 int32_t height, | 89 int32_t height, |
90 float deviceScaleFactor) { | 90 float deviceScaleFactor) { |
91 if (!m_currentSurfaceId.is_valid() && surfaceId.is_valid()) { | 91 if (surfaceId.is_valid() && !m_currentSurfaceId.is_valid()) { |
92 m_currentSurfaceId = surfaceId; | 92 m_currentSurfaceId = surfaceId; |
93 GraphicsLayer::unregisterContentsLayer(m_webLayer.get()); | 93 GraphicsLayer::unregisterContentsLayer(m_webLayer.get()); |
94 m_webLayer->removeFromParent(); | 94 m_webLayer->removeFromParent(); |
95 | 95 |
96 scoped_refptr<cc::SurfaceLayer> surfaceLayer = | 96 scoped_refptr<cc::SurfaceLayer> surfaceLayer = |
97 cc::SurfaceLayer::Create(m_refFactory); | 97 cc::SurfaceLayer::Create(m_refFactory); |
98 // TODO(xlai): Update this on resize. | |
99 cc::SurfaceInfo info(surfaceId, deviceScaleFactor, | 98 cc::SurfaceInfo info(surfaceId, deviceScaleFactor, |
100 gfx::Size(width, height)); | 99 gfx::Size(width, height)); |
101 surfaceLayer->SetSurfaceInfo( | 100 surfaceLayer->SetSurfaceInfo( |
102 info, true /* scale layer bounds with surface size */); | 101 info, true /* scale layer bounds with surface size */); |
103 m_CCLayer = surfaceLayer; | 102 m_CCLayer = surfaceLayer; |
104 | 103 |
105 m_webLayer = | 104 m_webLayer = |
106 Platform::current()->compositorSupport()->createLayerFromCCLayer( | 105 Platform::current()->compositorSupport()->createLayerFromCCLayer( |
107 m_CCLayer.get()); | 106 m_CCLayer.get()); |
108 GraphicsLayer::registerContentsLayer(m_webLayer.get()); | 107 GraphicsLayer::registerContentsLayer(m_webLayer.get()); |
109 | 108 |
110 m_observer->OnWebLayerReplaced(); | 109 m_observer->OnWebLayerReplaced(); |
110 } else if (m_currentSurfaceId != surfaceId) { | |
111 m_currentSurfaceId = surfaceId; | |
112 cc::SurfaceInfo info(m_currentSurfaceId, deviceScaleFactor, | |
113 gfx::Size(width, height)); | |
114 cc::SurfaceLayer* surfaceLayer = | |
115 static_cast<cc::SurfaceLayer*>(m_CCLayer.get()); | |
116 surfaceLayer->SetSurfaceInfo(info, true); | |
Fady Samuel
2016/12/19 20:12:40
I think you also need to update the layer bounds?
xlai (Olivia)
2016/12/19 22:30:15
Although there is no visible effect seen at the mo
| |
117 | |
118 m_observer->OnWebLayerReplaced(); | |
111 } | 119 } |
112 } | 120 } |
113 | 121 |
114 void CanvasSurfaceLayerBridge::satisfyCallback( | 122 void CanvasSurfaceLayerBridge::satisfyCallback( |
115 const cc::SurfaceSequence& sequence) { | 123 const cc::SurfaceSequence& sequence) { |
116 m_service->Satisfy(sequence); | 124 m_service->Satisfy(sequence); |
117 } | 125 } |
118 | 126 |
119 void CanvasSurfaceLayerBridge::requireCallback( | 127 void CanvasSurfaceLayerBridge::requireCallback( |
120 const cc::SurfaceId& surfaceId, | 128 const cc::SurfaceId& surfaceId, |
121 const cc::SurfaceSequence& sequence) { | 129 const cc::SurfaceSequence& sequence) { |
122 m_service->Require(surfaceId, sequence); | 130 m_service->Require(surfaceId, sequence); |
123 } | 131 } |
124 | 132 |
125 } // namespace blink | 133 } // namespace blink |
OLD | NEW |