| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2006 Nikolas Zimmermann <zimmermann@kde.org> | 2 * Copyright (C) 2006 Nikolas Zimmermann <zimmermann@kde.org> |
| 3 * Copyright (C) Research In Motion Limited 2010. All rights reserved. | 3 * Copyright (C) Research In Motion Limited 2010. All rights reserved. |
| 4 * Copyright 2014 The Chromium Authors. All rights reserved. | 4 * Copyright 2014 The Chromium Authors. All rights reserved. |
| 5 * | 5 * |
| 6 * This library is free software; you can redistribute it and/or | 6 * This library is free software; you can redistribute it and/or |
| 7 * modify it under the terms of the GNU Library General Public | 7 * modify it under the terms of the GNU Library General Public |
| 8 * License as published by the Free Software Foundation; either | 8 * License as published by the Free Software Foundation; either |
| 9 * version 2 of the License, or (at your option) any later version. | 9 * version 2 of the License, or (at your option) any later version. |
| 10 * | 10 * |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 115 } else { | 115 } else { |
| 116 // A viewbox overrides patternContentUnits, per spec. | 116 // A viewbox overrides patternContentUnits, per spec. |
| 117 if (attributes.PatternContentUnits() == | 117 if (attributes.PatternContentUnits() == |
| 118 SVGUnitTypes::kSvgUnitTypeObjectboundingbox) | 118 SVGUnitTypes::kSvgUnitTypeObjectboundingbox) |
| 119 tile_transform.Scale(client_bounding_box.Width(), | 119 tile_transform.Scale(client_bounding_box.Width(), |
| 120 client_bounding_box.Height()); | 120 client_bounding_box.Height()); |
| 121 } | 121 } |
| 122 | 122 |
| 123 std::unique_ptr<PatternData> pattern_data = WTF::WrapUnique(new PatternData); | 123 std::unique_ptr<PatternData> pattern_data = WTF::WrapUnique(new PatternData); |
| 124 pattern_data->pattern = Pattern::CreatePaintRecordPattern( | 124 pattern_data->pattern = Pattern::CreatePaintRecordPattern( |
| 125 AsPaintRecord(tile_bounds.Size(), tile_transform), | 125 AsPaintRecord(tile_bounds, tile_transform)); |
| 126 FloatRect(FloatPoint(), tile_bounds.Size())); | |
| 127 | 126 |
| 128 // Compute pattern space transformation. | 127 // Compute pattern space transformation. |
| 129 pattern_data->transform.Translate(tile_bounds.X(), tile_bounds.Y()); | 128 pattern_data->transform.Translate(tile_bounds.X(), tile_bounds.Y()); |
| 130 pattern_data->transform.PreMultiply(attributes.PatternTransform()); | 129 pattern_data->transform.PreMultiply(attributes.PatternTransform()); |
| 131 | 130 |
| 132 return pattern_data; | 131 return pattern_data; |
| 133 } | 132 } |
| 134 | 133 |
| 135 SVGPaintServer LayoutSVGResourcePattern::PreparePaintServer( | 134 SVGPaintServer LayoutSVGResourcePattern::PreparePaintServer( |
| 136 const LayoutObject& object) { | 135 const LayoutObject& object) { |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 190 if (linked_resource == expected_layout_object) | 189 if (linked_resource == expected_layout_object) |
| 191 return expected_layout_object; | 190 return expected_layout_object; |
| 192 content_layout_object = linked_resource; | 191 content_layout_object = linked_resource; |
| 193 } | 192 } |
| 194 // There was a cycle, just use this resource as the "content resource" even | 193 // There was a cycle, just use this resource as the "content resource" even |
| 195 // though it will be empty (have no children). | 194 // though it will be empty (have no children). |
| 196 return this; | 195 return this; |
| 197 } | 196 } |
| 198 | 197 |
| 199 sk_sp<PaintRecord> LayoutSVGResourcePattern::AsPaintRecord( | 198 sk_sp<PaintRecord> LayoutSVGResourcePattern::AsPaintRecord( |
| 200 const FloatSize& size, | 199 const FloatRect& tile_bounds, |
| 201 const AffineTransform& tile_transform) const { | 200 const AffineTransform& tile_transform) const { |
| 202 DCHECK(!should_collect_pattern_attributes_); | 201 DCHECK(!should_collect_pattern_attributes_); |
| 203 | 202 |
| 204 AffineTransform content_transform; | 203 AffineTransform content_transform; |
| 205 if (Attributes().PatternContentUnits() == | 204 if (Attributes().PatternContentUnits() == |
| 206 SVGUnitTypes::kSvgUnitTypeObjectboundingbox) | 205 SVGUnitTypes::kSvgUnitTypeObjectboundingbox) |
| 207 content_transform = tile_transform; | 206 content_transform = tile_transform; |
| 208 | 207 |
| 209 FloatRect bounds(FloatPoint(), size); | 208 FloatRect bounds(FloatPoint(), tile_bounds.Size()); |
| 210 const LayoutSVGResourceContainer* pattern_layout_object = | 209 const LayoutSVGResourceContainer* pattern_layout_object = |
| 211 ResolveContentElement(); | 210 ResolveContentElement(); |
| 212 DCHECK(pattern_layout_object); | 211 DCHECK(pattern_layout_object); |
| 213 DCHECK(!pattern_layout_object->NeedsLayout()); | 212 DCHECK(!pattern_layout_object->NeedsLayout()); |
| 214 | 213 |
| 215 SubtreeContentTransformScope content_transform_scope(content_transform); | 214 SubtreeContentTransformScope content_transform_scope(content_transform); |
| 216 | 215 |
| 217 PaintRecordBuilder builder(bounds); | 216 PaintRecordBuilder builder(bounds); |
| 218 for (LayoutObject* child = pattern_layout_object->FirstChild(); child; | 217 for (LayoutObject* child = pattern_layout_object->FirstChild(); child; |
| 219 child = child->NextSibling()) | 218 child = child->NextSibling()) |
| 220 SVGPaintContext::PaintResourceSubtree(builder.Context(), child); | 219 SVGPaintContext::PaintResourceSubtree(builder.Context(), child); |
| 221 PaintRecorder paint_recorder; | 220 PaintRecorder paint_recorder; |
| 222 PaintCanvas* canvas = paint_recorder.beginRecording(bounds); | 221 PaintCanvas* canvas = paint_recorder.beginRecording(bounds); |
| 223 canvas->save(); | 222 canvas->save(); |
| 224 canvas->concat(AffineTransformToSkMatrix(tile_transform)); | 223 canvas->concat(AffineTransformToSkMatrix(tile_transform)); |
| 225 builder.EndRecording(*canvas); | 224 builder.EndRecording(*canvas); |
| 226 canvas->restore(); | 225 canvas->restore(); |
| 227 return paint_recorder.finishRecordingAsPicture(); | 226 return paint_recorder.finishRecordingAsPicture(); |
| 228 } | 227 } |
| 229 | 228 |
| 230 } // namespace blink | 229 } // namespace blink |
| OLD | NEW |