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/layer_settings.h" | 9 #include "cc/layers/layer_settings.h" |
10 #include "cc/layers/picture_layer.h" | 10 #include "cc/layers/picture_layer.h" |
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
170 gfx::RectF clipRect = node->clipRect().rect(); | 170 gfx::RectF clipRect = node->clipRect().rect(); |
171 | 171 |
172 // TODO(jbroman): This, and the similar logic in | 172 // TODO(jbroman): This, and the similar logic in |
173 // PaintArtifactCompositor::update, will need to be updated to account for | 173 // PaintArtifactCompositor::update, will need to be updated to account for |
174 // other kinds of intermediate layers, such as those that apply effects. | 174 // other kinds of intermediate layers, such as those that apply effects. |
175 // TODO(jbroman): This assumes that the transform space of this node's | 175 // TODO(jbroman): This assumes that the transform space of this node's |
176 // parent is an ancestor of this node's transform space. That's not | 176 // parent is an ancestor of this node's transform space. That's not |
177 // necessarily true, and this should be fixed. | 177 // necessarily true, and this should be fixed. |
178 gfx::Transform transform = transformToTransformSpace(localTransformSpace(nod
e), localTransformSpace(node->parent())); | 178 gfx::Transform transform = transformToTransformSpace(localTransformSpace(nod
e), localTransformSpace(node->parent())); |
179 gfx::Vector2dF offset = clipRect.OffsetFromOrigin(); | 179 gfx::Vector2dF offset = clipRect.OffsetFromOrigin(); |
| 180 transform.Translate(offset.x(), offset.y()); |
180 if (node->parent()) { | 181 if (node->parent()) { |
181 FloatPoint offsetDueToParentClipOffset = node->parent()->clipRect().rect
().location(); | 182 FloatPoint offsetDueToParentClipOffset = node->parent()->clipRect().rect
().location(); |
182 offset -= gfx::Vector2dF(offsetDueToParentClipOffset.x(), offsetDueToPar
entClipOffset.y()); | 183 gfx::Transform undoClipOffset; |
| 184 undoClipOffset.Translate(-offsetDueToParentClipOffset.x(), -offsetDueToP
arentClipOffset.y()); |
| 185 transform.PreconcatTransform(undoClipOffset); |
183 } | 186 } |
184 transform.Translate(offset.x(), offset.y()); | |
185 | 187 |
186 scoped_refptr<cc::Layer> layer = cc::Layer::Create(cc::LayerSettings()); | 188 scoped_refptr<cc::Layer> layer = cc::Layer::Create(cc::LayerSettings()); |
187 layer->SetIsDrawable(false); | 189 layer->SetIsDrawable(false); |
188 layer->SetMasksToBounds(true); | 190 layer->SetMasksToBounds(true); |
189 layer->SetPosition(gfx::PointF()); | 191 layer->SetPosition(gfx::PointF()); |
190 layer->SetBounds(gfx::ToRoundedSize(clipRect.size())); | 192 layer->SetBounds(gfx::ToRoundedSize(clipRect.size())); |
191 layer->SetTransform(transform); | 193 layer->SetTransform(transform); |
192 return layer; | 194 return layer; |
193 } | 195 } |
194 | 196 |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
286 // The common case: create a layer for painted content. | 288 // The common case: create a layer for painted content. |
287 gfx::Rect combinedBounds = enclosingIntRect(paintChunk.bounds); | 289 gfx::Rect combinedBounds = enclosingIntRect(paintChunk.bounds); |
288 scoped_refptr<cc::DisplayItemList> displayList = recordPaintChunk(paintArtif
act, paintChunk, combinedBounds); | 290 scoped_refptr<cc::DisplayItemList> displayList = recordPaintChunk(paintArtif
act, paintChunk, combinedBounds); |
289 OwnPtr<ContentLayerClientImpl> contentLayerClient = adoptPtr( | 291 OwnPtr<ContentLayerClientImpl> contentLayerClient = adoptPtr( |
290 new ContentLayerClientImpl(std::move(displayList), gfx::Rect(combinedBou
nds.size()))); | 292 new ContentLayerClientImpl(std::move(displayList), gfx::Rect(combinedBou
nds.size()))); |
291 | 293 |
292 // Include the offset in the transform, because it needs to apply in | 294 // Include the offset in the transform, because it needs to apply in |
293 // this layer's transform space (whereas layer position applies in its | 295 // this layer's transform space (whereas layer position applies in its |
294 // parent's transform space). | 296 // parent's transform space). |
295 gfx::Vector2dF offset = gfx::PointF(combinedBounds.origin()).OffsetFromOrigi
n(); | 297 gfx::Vector2dF offset = gfx::PointF(combinedBounds.origin()).OffsetFromOrigi
n(); |
| 298 transform.Translate(offset.x(), offset.y()); |
| 299 |
| 300 // If a clip was applied, its origin needs to be cancelled out in |
| 301 // this transform. |
296 if (const auto* clip = paintChunk.properties.clip.get()) { | 302 if (const auto* clip = paintChunk.properties.clip.get()) { |
297 // If a clip was applied, its origin needs to be cancelled out in | |
298 // this transform. | |
299 FloatPoint offsetDueToClipOffset = clip->clipRect().rect().location(); | 303 FloatPoint offsetDueToClipOffset = clip->clipRect().rect().location(); |
300 offset -= gfx::Vector2dF(offsetDueToClipOffset.x(), offsetDueToClipOffse
t.y()); | 304 gfx::Transform undoClipOffset; |
| 305 undoClipOffset.Translate(-offsetDueToClipOffset.x(), -offsetDueToClipOff
set.y()); |
| 306 transform.PreconcatTransform(undoClipOffset); |
301 } | 307 } |
302 transform.Translate(offset.x(), offset.y()); | |
303 | 308 |
304 scoped_refptr<cc::PictureLayer> layer = cc::PictureLayer::Create(cc::LayerSe
ttings(), contentLayerClient.get()); | 309 scoped_refptr<cc::PictureLayer> layer = cc::PictureLayer::Create(cc::LayerSe
ttings(), contentLayerClient.get()); |
305 layer->SetBounds(combinedBounds.size()); | 310 layer->SetBounds(combinedBounds.size()); |
306 layer->SetTransform(transform); | 311 layer->SetTransform(transform); |
307 layer->SetIsDrawable(true); | 312 layer->SetIsDrawable(true); |
308 layer->SetDoubleSided(!paintChunk.properties.backfaceHidden); | 313 layer->SetDoubleSided(!paintChunk.properties.backfaceHidden); |
309 if (paintChunk.knownToBeOpaque) | 314 if (paintChunk.knownToBeOpaque) |
310 layer->SetContentsOpaque(true); | 315 layer->SetContentsOpaque(true); |
311 m_contentLayerClients.append(contentLayerClient.release()); | 316 m_contentLayerClients.append(contentLayerClient.release()); |
312 return layer; | 317 return layer; |
313 } | 318 } |
314 | 319 |
315 | 320 |
316 } // namespace blink | 321 } // namespace blink |
OLD | NEW |