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 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
166 { | 166 { |
167 // TODO(jbroman): Handle rounded-rect clips. | 167 // TODO(jbroman): Handle rounded-rect clips. |
168 // TODO(jbroman): Handle clips of non-integer size. | 168 // TODO(jbroman): Handle clips of non-integer size. |
169 gfx::RectF clipRect = node->clipRect().rect(); | 169 gfx::RectF clipRect = node->clipRect().rect(); |
170 | 170 |
171 // TODO(jbroman): This, and the similar logic in | 171 // TODO(jbroman): This, and the similar logic in |
172 // PaintArtifactCompositor::update, will need to be updated to account for | 172 // PaintArtifactCompositor::update, will need to be updated to account for |
173 // other kinds of intermediate layers, such as those that apply effects. | 173 // other kinds of intermediate layers, such as those that apply effects. |
174 // TODO(jbroman): This assumes that the transform space of this node's | 174 // TODO(jbroman): This assumes that the transform space of this node's |
175 // parent is an ancestor of this node's transform space. That's not | 175 // parent is an ancestor of this node's transform space. That's not |
176 // necessarily true, and this should be fixed. | 176 // necessarily true, and this should be fixed. crbug.com/597156 |
177 gfx::Transform transform = transformToTransformSpace(localTransformSpace(nod
e), localTransformSpace(node->parent())); | 177 gfx::Transform transform = transformToTransformSpace(localTransformSpace(nod
e), localTransformSpace(node->parent())); |
178 gfx::Vector2dF offset = clipRect.OffsetFromOrigin(); | 178 gfx::Vector2dF offset = clipRect.OffsetFromOrigin(); |
179 transform.Translate(offset.x(), offset.y()); | 179 transform.Translate(offset.x(), offset.y()); |
180 if (node->parent()) { | 180 if (node->parent()) { |
181 FloatPoint offsetDueToParentClipOffset = node->parent()->clipRect().rect
().location(); | 181 FloatPoint offsetDueToParentClipOffset = node->parent()->clipRect().rect
().location(); |
182 gfx::Transform undoClipOffset; | 182 gfx::Transform undoClipOffset; |
183 undoClipOffset.Translate(-offsetDueToParentClipOffset.x(), -offsetDueToP
arentClipOffset.y()); | 183 undoClipOffset.Translate(-offsetDueToParentClipOffset.x(), -offsetDueToP
arentClipOffset.y()); |
184 transform.ConcatTransform(undoClipOffset); | 184 transform.ConcatTransform(undoClipOffset); |
185 } | 185 } |
186 | 186 |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
264 ASSERT(m_rootLayer); | 264 ASSERT(m_rootLayer); |
265 | 265 |
266 // TODO(jbroman): This should be incremental. | 266 // TODO(jbroman): This should be incremental. |
267 m_rootLayer->RemoveAllChildren(); | 267 m_rootLayer->RemoveAllChildren(); |
268 m_contentLayerClients.clear(); | 268 m_contentLayerClients.clear(); |
269 | 269 |
270 m_contentLayerClients.reserveCapacity(paintArtifact.paintChunks().size()); | 270 m_contentLayerClients.reserveCapacity(paintArtifact.paintChunks().size()); |
271 ClipLayerManager clipLayerManager(m_rootLayer.get()); | 271 ClipLayerManager clipLayerManager(m_rootLayer.get()); |
272 for (const PaintChunk& paintChunk : paintArtifact.paintChunks()) { | 272 for (const PaintChunk& paintChunk : paintArtifact.paintChunks()) { |
273 cc::Layer* parent = clipLayerManager.switchToNewClipLayer(paintChunk.pro
perties.clip.get()); | 273 cc::Layer* parent = clipLayerManager.switchToNewClipLayer(paintChunk.pro
perties.clip.get()); |
| 274 // TODO(jbroman): Same as above. This assumes the transform space of the
current clip is |
| 275 // an ancestor of the chunk. It is not necessarily true. crbug.com/59715
6 |
274 gfx::Transform transform = transformToTransformSpace(paintChunk.properti
es.transform.get(), localTransformSpace(paintChunk.properties.clip.get())); | 276 gfx::Transform transform = transformToTransformSpace(paintChunk.properti
es.transform.get(), localTransformSpace(paintChunk.properties.clip.get())); |
275 scoped_refptr<cc::Layer> layer = layerForPaintChunk(paintArtifact, paint
Chunk, transform); | 277 scoped_refptr<cc::Layer> layer = layerForPaintChunk(paintArtifact, paint
Chunk, transform); |
276 layer->SetNeedsDisplay(); | 278 layer->SetNeedsDisplay(); |
277 parent->AddChild(std::move(layer)); | 279 parent->AddChild(std::move(layer)); |
278 } | 280 } |
279 } | 281 } |
280 | 282 |
281 scoped_refptr<cc::Layer> PaintArtifactCompositor::layerForPaintChunk(const Paint
Artifact& paintArtifact, const PaintChunk& paintChunk, gfx::Transform transform) | 283 scoped_refptr<cc::Layer> PaintArtifactCompositor::layerForPaintChunk(const Paint
Artifact& paintArtifact, const PaintChunk& paintChunk, gfx::Transform transform) |
282 { | 284 { |
283 // If the paint chunk is a foreign layer, just return that layer. | 285 // If the paint chunk is a foreign layer, just return that layer. |
(...skipping 27 matching lines...) Expand all Loading... |
311 layer->SetIsDrawable(true); | 313 layer->SetIsDrawable(true); |
312 layer->SetDoubleSided(!paintChunk.properties.backfaceHidden); | 314 layer->SetDoubleSided(!paintChunk.properties.backfaceHidden); |
313 if (paintChunk.knownToBeOpaque) | 315 if (paintChunk.knownToBeOpaque) |
314 layer->SetContentsOpaque(true); | 316 layer->SetContentsOpaque(true); |
315 m_contentLayerClients.append(contentLayerClient.release()); | 317 m_contentLayerClients.append(contentLayerClient.release()); |
316 return layer; | 318 return layer; |
317 } | 319 } |
318 | 320 |
319 | 321 |
320 } // namespace blink | 322 } // namespace blink |
OLD | NEW |