OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/compositing/PaintArtifactCompositor.h" | 5 #include "platform/graphics/compositing/PaintArtifactCompositor.h" |
6 | 6 |
7 #include "cc/layers/content_layer_client.h" | 7 #include "cc/layers/content_layer_client.h" |
8 #include "cc/layers/layer.h" | 8 #include "cc/layers/layer.h" |
9 #include "cc/layers/picture_layer.h" | 9 #include "cc/layers/picture_layer.h" |
10 #include "cc/playback/display_item_list.h" | 10 #include "cc/playback/display_item_list.h" |
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
211 PropertyTreeManager(cc::PropertyTrees& propertyTrees, cc::Layer* rootLayer) | 211 PropertyTreeManager(cc::PropertyTrees& propertyTrees, cc::Layer* rootLayer) |
212 : m_propertyTrees(propertyTrees) | 212 : m_propertyTrees(propertyTrees) |
213 , m_rootLayer(rootLayer) | 213 , m_rootLayer(rootLayer) |
214 #if DCHECK_IS_ON() | 214 #if DCHECK_IS_ON() |
215 , m_isFirstEffectEver(true) | 215 , m_isFirstEffectEver(true) |
216 #endif | 216 #endif |
217 { | 217 { |
218 m_effectStack.append(BlinkEffectAndCcIdPair{nullptr, kSecondaryRootNodeI
d}); | 218 m_effectStack.append(BlinkEffectAndCcIdPair{nullptr, kSecondaryRootNodeI
d}); |
219 } | 219 } |
220 | 220 |
| 221 // TODO(pdr): This will need to be unified with how viewport scale works. |
| 222 void setDeviceScaleFactor(float); |
| 223 |
221 int compositorIdForTransformNode(const TransformPaintPropertyNode*); | 224 int compositorIdForTransformNode(const TransformPaintPropertyNode*); |
222 int compositorIdForClipNode(const ClipPaintPropertyNode*); | 225 int compositorIdForClipNode(const ClipPaintPropertyNode*); |
223 int switchToEffectNode(const EffectPaintPropertyNode& nextEffect); | 226 int switchToEffectNode(const EffectPaintPropertyNode& nextEffect); |
224 int compositorIdForCurrentEffectNode() const { return m_effectStack.last().i
d; } | 227 int compositorIdForCurrentEffectNode() const { return m_effectStack.last().i
d; } |
225 | 228 |
226 private: | 229 private: |
227 void buildEffectNodesRecursively(const EffectPaintPropertyNode* nextEffect); | 230 void buildEffectNodesRecursively(const EffectPaintPropertyNode* nextEffect); |
228 | 231 |
229 cc::TransformTree& transformTree() { return m_propertyTrees.transform_tree;
} | 232 cc::TransformTree& transformTree() { return m_propertyTrees.transform_tree;
} |
230 cc::ClipTree& clipTree() { return m_propertyTrees.clip_tree; } | 233 cc::ClipTree& clipTree() { return m_propertyTrees.clip_tree; } |
(...skipping 17 matching lines...) Expand all Loading... |
248 int id; | 251 int id; |
249 }; | 252 }; |
250 Vector<BlinkEffectAndCcIdPair> m_effectStack; | 253 Vector<BlinkEffectAndCcIdPair> m_effectStack; |
251 | 254 |
252 #if DCHECK_IS_ON() | 255 #if DCHECK_IS_ON() |
253 HashSet<const EffectPaintPropertyNode*> m_effectNodesConverted; | 256 HashSet<const EffectPaintPropertyNode*> m_effectNodesConverted; |
254 bool m_isFirstEffectEver; | 257 bool m_isFirstEffectEver; |
255 #endif | 258 #endif |
256 }; | 259 }; |
257 | 260 |
| 261 void PropertyTreeManager::setDeviceScaleFactor(float deviceScaleFactor) |
| 262 { |
| 263 auto& rootTransformNode = *transformTree().Node(kSecondaryRootNodeId); |
| 264 rootTransformNode.local.Scale(deviceScaleFactor, deviceScaleFactor); |
| 265 } |
| 266 |
258 int PropertyTreeManager::compositorIdForTransformNode(const TransformPaintProper
tyNode* transformNode) | 267 int PropertyTreeManager::compositorIdForTransformNode(const TransformPaintProper
tyNode* transformNode) |
259 { | 268 { |
260 if (!transformNode) | 269 if (!transformNode) |
261 return kSecondaryRootNodeId; | 270 return kSecondaryRootNodeId; |
262 | 271 |
263 auto it = m_transformNodeMap.find(transformNode); | 272 auto it = m_transformNodeMap.find(transformNode); |
264 if (it != m_transformNodeMap.end()) | 273 if (it != m_transformNodeMap.end()) |
265 return it->value; | 274 return it->value; |
266 | 275 |
267 scoped_refptr<cc::Layer> dummyLayer = cc::Layer::Create(); | 276 scoped_refptr<cc::Layer> dummyLayer = cc::Layer::Create(); |
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
427 | 436 |
428 // The host will be null after detaching and this update can be ignored. | 437 // The host will be null after detaching and this update can be ignored. |
429 // See: WebViewImpl::detachPaintArtifactCompositor(). | 438 // See: WebViewImpl::detachPaintArtifactCompositor(). |
430 if (!host) | 439 if (!host) |
431 return; | 440 return; |
432 | 441 |
433 if (m_extraDataForTestingEnabled) | 442 if (m_extraDataForTestingEnabled) |
434 m_extraDataForTesting = wrapUnique(new ExtraDataForTesting); | 443 m_extraDataForTesting = wrapUnique(new ExtraDataForTesting); |
435 | 444 |
436 setMinimalPropertyTrees(host->GetLayerTree()->property_trees(), m_rootLayer-
>id()); | 445 setMinimalPropertyTrees(host->GetLayerTree()->property_trees(), m_rootLayer-
>id()); |
| 446 |
437 m_rootLayer->RemoveAllChildren(); | 447 m_rootLayer->RemoveAllChildren(); |
438 m_rootLayer->set_property_tree_sequence_number(kPropertyTreeSequenceNumber); | 448 m_rootLayer->set_property_tree_sequence_number(kPropertyTreeSequenceNumber); |
439 m_rootLayer->SetTransformTreeIndex(kSecondaryRootNodeId); | 449 m_rootLayer->SetTransformTreeIndex(kSecondaryRootNodeId); |
440 m_rootLayer->SetClipTreeIndex(kSecondaryRootNodeId); | 450 m_rootLayer->SetClipTreeIndex(kSecondaryRootNodeId); |
441 m_rootLayer->SetEffectTreeIndex(kSecondaryRootNodeId); | 451 m_rootLayer->SetEffectTreeIndex(kSecondaryRootNodeId); |
442 m_rootLayer->SetScrollTreeIndex(kRealRootNodeId); | 452 m_rootLayer->SetScrollTreeIndex(kRealRootNodeId); |
443 | 453 |
444 PropertyTreeManager propertyTreeManager(*host->GetLayerTree()->property_tree
s(), m_rootLayer.get()); | 454 PropertyTreeManager propertyTreeManager(*host->GetLayerTree()->property_tree
s(), m_rootLayer.get()); |
| 455 propertyTreeManager.setDeviceScaleFactor(host->GetLayerTree()->device_scale_
factor()); |
| 456 |
445 m_contentLayerClients.clear(); | 457 m_contentLayerClients.clear(); |
446 m_contentLayerClients.reserveCapacity(paintArtifact.paintChunks().size()); | 458 m_contentLayerClients.reserveCapacity(paintArtifact.paintChunks().size()); |
447 for (const PaintChunk& paintChunk : paintArtifact.paintChunks()) { | 459 for (const PaintChunk& paintChunk : paintArtifact.paintChunks()) { |
448 gfx::Vector2dF layerOffset; | 460 gfx::Vector2dF layerOffset; |
449 scoped_refptr<cc::Layer> layer = layerForPaintChunk(paintArtifact, paint
Chunk, layerOffset); | 461 scoped_refptr<cc::Layer> layer = layerForPaintChunk(paintArtifact, paint
Chunk, layerOffset); |
450 | 462 |
451 int transformId = propertyTreeManager.compositorIdForTransformNode(paint
Chunk.properties.transform.get()); | 463 int transformId = propertyTreeManager.compositorIdForTransformNode(paint
Chunk.properties.transform.get()); |
452 int clipId = propertyTreeManager.compositorIdForClipNode(paintChunk.prop
erties.clip.get()); | 464 int clipId = propertyTreeManager.compositorIdForClipNode(paintChunk.prop
erties.clip.get()); |
453 int effectId = propertyTreeManager.switchToEffectNode(*paintChunk.proper
ties.effect.get()); | 465 int effectId = propertyTreeManager.switchToEffectNode(*paintChunk.proper
ties.effect.get()); |
454 | 466 |
(...skipping 15 matching lines...) Expand all Loading... |
470 if (m_extraDataForTestingEnabled) | 482 if (m_extraDataForTestingEnabled) |
471 m_extraDataForTesting->contentLayers.append(layer); | 483 m_extraDataForTesting->contentLayers.append(layer); |
472 } | 484 } |
473 | 485 |
474 // Mark the property trees as having been rebuilt. | 486 // Mark the property trees as having been rebuilt. |
475 host->GetLayerTree()->property_trees()->sequence_number = kPropertyTreeSeque
nceNumber; | 487 host->GetLayerTree()->property_trees()->sequence_number = kPropertyTreeSeque
nceNumber; |
476 host->GetLayerTree()->property_trees()->needs_rebuild = false; | 488 host->GetLayerTree()->property_trees()->needs_rebuild = false; |
477 } | 489 } |
478 | 490 |
479 } // namespace blink | 491 } // namespace blink |
OLD | NEW |