| 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 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 216 draw(canvas, paint, dstRect, scaledSrc, DoNotRespectImageOrientation, ClampI
mageToSourceRect); | 216 draw(canvas, paint, dstRect, scaledSrc, DoNotRespectImageOrientation, ClampI
mageToSourceRect); |
| 217 } | 217 } |
| 218 | 218 |
| 219 PassRefPtr<SkImage> SVGImage::imageForCurrentFrame() | 219 PassRefPtr<SkImage> SVGImage::imageForCurrentFrame() |
| 220 { | 220 { |
| 221 if (!m_page) | 221 if (!m_page) |
| 222 return nullptr; | 222 return nullptr; |
| 223 | 223 |
| 224 SkPictureRecorder recorder; | 224 SkPictureRecorder recorder; |
| 225 SkCanvas* canvas = recorder.beginRecording(width(), height()); | 225 SkCanvas* canvas = recorder.beginRecording(width(), height()); |
| 226 drawForContainer(canvas, SkPaint(), size(), 1, rect(), rect()); | 226 drawForContainer(canvas, SkPaint(), FloatSize(size()), 1, rect(), rect()); |
| 227 RefPtr<SkPicture> picture = adoptRef(recorder.endRecording()); | 227 RefPtr<SkPicture> picture = adoptRef(recorder.endRecording()); |
| 228 | 228 |
| 229 return adoptRef( | 229 return adoptRef( |
| 230 SkImage::NewFromPicture(picture.get(), SkISize::Make(width(), height()),
nullptr, nullptr)); | 230 SkImage::NewFromPicture(picture.get(), SkISize::Make(width(), height()),
nullptr, nullptr)); |
| 231 } | 231 } |
| 232 | 232 |
| 233 void SVGImage::drawPatternForContainer(GraphicsContext* context, const FloatSize
containerSize, | 233 void SVGImage::drawPatternForContainer(GraphicsContext* context, const FloatSize
containerSize, |
| 234 float zoom, const FloatRect& srcRect, const FloatSize& tileScale, const Floa
tPoint& phase, | 234 float zoom, const FloatRect& srcRect, const FloatSize& tileScale, const Floa
tPoint& phase, |
| 235 SkXfermode::Mode compositeOp, const FloatRect& dstRect, | 235 SkXfermode::Mode compositeOp, const FloatRect& dstRect, |
| 236 const IntSize& repeatSpacing) | 236 const IntSize& repeatSpacing) |
| 237 { | 237 { |
| 238 // Tile adjusted for scaling/stretch. | 238 // Tile adjusted for scaling/stretch. |
| 239 FloatRect tile(srcRect); | 239 FloatRect tile(srcRect); |
| 240 tile.scale(tileScale.width(), tileScale.height()); | 240 tile.scale(tileScale.width(), tileScale.height()); |
| 241 | 241 |
| 242 // Expand the tile to account for repeat spacing. | 242 // Expand the tile to account for repeat spacing. |
| 243 FloatRect spacedTile(tile); | 243 FloatRect spacedTile(tile); |
| 244 spacedTile.expand(repeatSpacing); | 244 spacedTile.expand(FloatSize(repeatSpacing)); |
| 245 | 245 |
| 246 SkPictureBuilder patternPicture(spacedTile, nullptr, context); | 246 SkPictureBuilder patternPicture(spacedTile, nullptr, context); |
| 247 if (!DrawingRecorder::useCachedDrawingIfPossible(patternPicture.context(), *
this, DisplayItem::Type::SVGImage)) { | 247 if (!DrawingRecorder::useCachedDrawingIfPossible(patternPicture.context(), *
this, DisplayItem::Type::SVGImage)) { |
| 248 DrawingRecorder patternPictureRecorder(patternPicture.context(), *this,
DisplayItem::Type::SVGImage, spacedTile); | 248 DrawingRecorder patternPictureRecorder(patternPicture.context(), *this,
DisplayItem::Type::SVGImage, spacedTile); |
| 249 // When generating an expanded tile, make sure we don't draw into the sp
acing area. | 249 // When generating an expanded tile, make sure we don't draw into the sp
acing area. |
| 250 if (tile != spacedTile) | 250 if (tile != spacedTile) |
| 251 patternPicture.context().clip(tile); | 251 patternPicture.context().clip(tile); |
| 252 SkPaint paint; | 252 SkPaint paint; |
| 253 drawForContainer(patternPicture.context().canvas(), paint, containerSize
, zoom, tile, srcRect); | 253 drawForContainer(patternPicture.context().canvas(), paint, containerSize
, zoom, tile, srcRect); |
| 254 } | 254 } |
| (...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 500 | 500 |
| 501 return m_page; | 501 return m_page; |
| 502 } | 502 } |
| 503 | 503 |
| 504 String SVGImage::filenameExtension() const | 504 String SVGImage::filenameExtension() const |
| 505 { | 505 { |
| 506 return "svg"; | 506 return "svg"; |
| 507 } | 507 } |
| 508 | 508 |
| 509 } | 509 } |
| OLD | NEW |