| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2006 Eric Seidel <eric@webkit.org> | 2 * Copyright (C) 2006 Eric Seidel <eric@webkit.org> |
| 3 * Copyright (C) 2008, 2009 Apple Inc. All rights reserved. | 3 * Copyright (C) 2008, 2009 Apple Inc. All rights reserved. |
| 4 * Copyright (C) Research In Motion Limited 2011. All rights reserved. | 4 * Copyright (C) Research In Motion Limited 2011. All rights reserved. |
| 5 * | 5 * |
| 6 * Redistribution and use in source and binary forms, with or without | 6 * Redistribution and use in source and binary forms, with or without |
| 7 * modification, are permitted provided that the following conditions | 7 * modification, are permitted provided that the following conditions |
| 8 * are met: | 8 * are met: |
| 9 * 1. Redistributions of source code must retain the above copyright | 9 * 1. Redistributions of source code must retain the above copyright |
| 10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
| (...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 272 // Tile adjusted for scaling/stretch. | 272 // Tile adjusted for scaling/stretch. |
| 273 FloatRect tile(srcRect); | 273 FloatRect tile(srcRect); |
| 274 tile.scale(tileScale.width(), tileScale.height()); | 274 tile.scale(tileScale.width(), tileScale.height()); |
| 275 | 275 |
| 276 // Expand the tile to account for repeat spacing. | 276 // Expand the tile to account for repeat spacing. |
| 277 FloatRect spacedTile(tile); | 277 FloatRect spacedTile(tile); |
| 278 spacedTile.expand(FloatSize(repeatSpacing)); | 278 spacedTile.expand(FloatSize(repeatSpacing)); |
| 279 | 279 |
| 280 SkPictureBuilder patternPicture(spacedTile, nullptr, &context); | 280 SkPictureBuilder patternPicture(spacedTile, nullptr, &context); |
| 281 { | 281 { |
| 282 DrawingRecorder patternPictureRecorder(patternPicture.context(), pattern
Picture, DisplayItem::Type::SVGImage, spacedTile); | 282 DrawingRecorder patternPictureRecorder(patternPicture.context(), pattern
Picture, DisplayItem::Type::kSVGImage, spacedTile); |
| 283 // When generating an expanded tile, make sure we don't draw into the sp
acing area. | 283 // When generating an expanded tile, make sure we don't draw into the sp
acing area. |
| 284 if (tile != spacedTile) | 284 if (tile != spacedTile) |
| 285 patternPicture.context().clip(tile); | 285 patternPicture.context().clip(tile); |
| 286 SkPaint paint; | 286 SkPaint paint; |
| 287 drawForContainer(patternPicture.context().canvas(), paint, containerSize
, zoom, tile, srcRect, url); | 287 drawForContainer(patternPicture.context().canvas(), paint, containerSize
, zoom, tile, srcRect, url); |
| 288 } | 288 } |
| 289 RefPtr<SkPicture> tilePicture = patternPicture.endRecording(); | 289 RefPtr<SkPicture> tilePicture = patternPicture.endRecording(); |
| 290 | 290 |
| 291 SkMatrix patternTransform; | 291 SkMatrix patternTransform; |
| 292 patternTransform.setTranslate(phase.x() + spacedTile.x(), phase.y() + spaced
Tile.y()); | 292 patternTransform.setTranslate(phase.x() + spacedTile.x(), phase.y() + spaced
Tile.y()); |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 354 | 354 |
| 355 // If the image was reset, we need to rewind the timeline back to 0. This | 355 // If the image was reset, we need to rewind the timeline back to 0. This |
| 356 // needs to be done before painting, or else we wouldn't get the correct | 356 // needs to be done before painting, or else we wouldn't get the correct |
| 357 // reset semantics (we'd paint the "last" frame rather than the one at | 357 // reset semantics (we'd paint the "last" frame rather than the one at |
| 358 // time=0.) The reason we do this here and not in resetAnimation() is to | 358 // time=0.) The reason we do this here and not in resetAnimation() is to |
| 359 // avoid setting timers from the latter. | 359 // avoid setting timers from the latter. |
| 360 flushPendingTimelineRewind(); | 360 flushPendingTimelineRewind(); |
| 361 | 361 |
| 362 SkPictureBuilder imagePicture(dstRect); | 362 SkPictureBuilder imagePicture(dstRect); |
| 363 { | 363 { |
| 364 ClipRecorder clipRecorder(imagePicture.context(), imagePicture, DisplayI
tem::ClipNodeImage, enclosingIntRect(dstRect)); | 364 ClipRecorder clipRecorder(imagePicture.context(), imagePicture, DisplayI
tem::kClipNodeImage, enclosingIntRect(dstRect)); |
| 365 | 365 |
| 366 // We can only draw the entire frame, clipped to the rect we want. So co
mpute where the top left | 366 // We can only draw the entire frame, clipped to the rect we want. So co
mpute where the top left |
| 367 // of the image would be if we were drawing without clipping, and transl
ate accordingly. | 367 // of the image would be if we were drawing without clipping, and transl
ate accordingly. |
| 368 FloatSize scale(dstRect.width() / srcRect.width(), dstRect.height() / sr
cRect.height()); | 368 FloatSize scale(dstRect.width() / srcRect.width(), dstRect.height() / sr
cRect.height()); |
| 369 FloatSize topLeftOffset(srcRect.location().x() * scale.width(), srcRect.
location().y() * scale.height()); | 369 FloatSize topLeftOffset(srcRect.location().x() * scale.width(), srcRect.
location().y() * scale.height()); |
| 370 FloatPoint destOffset = dstRect.location() - topLeftOffset; | 370 FloatPoint destOffset = dstRect.location() - topLeftOffset; |
| 371 AffineTransform transform = AffineTransform::translation(destOffset.x(),
destOffset.y()); | 371 AffineTransform transform = AffineTransform::translation(destOffset.x(),
destOffset.y()); |
| 372 transform.scale(scale.width(), scale.height()); | 372 transform.scale(scale.width(), scale.height()); |
| 373 TransformRecorder transformRecorder(imagePicture.context(), imagePicture
, transform); | 373 TransformRecorder transformRecorder(imagePicture.context(), imagePicture
, transform); |
| 374 | 374 |
| (...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 588 | 588 |
| 589 return m_page ? SizeAvailable : SizeUnavailable; | 589 return m_page ? SizeAvailable : SizeUnavailable; |
| 590 } | 590 } |
| 591 | 591 |
| 592 String SVGImage::filenameExtension() const | 592 String SVGImage::filenameExtension() const |
| 593 { | 593 { |
| 594 return "svg"; | 594 return "svg"; |
| 595 } | 595 } |
| 596 | 596 |
| 597 } // namespace blink | 597 } // namespace blink |
| OLD | NEW |