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 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
211 scaledSrc.setSize(adjustedSrcSize); | 211 scaledSrc.setSize(adjustedSrcSize); |
212 | 212 |
213 drawInternal(canvas, paint, dstRect, scaledSrc, DoNotRespectImageOrientation
, ClampImageToSourceRect, url); | 213 drawInternal(canvas, paint, dstRect, scaledSrc, DoNotRespectImageOrientation
, ClampImageToSourceRect, url); |
214 } | 214 } |
215 | 215 |
216 PassRefPtr<SkImage> SVGImage::imageForCurrentFrame() | 216 PassRefPtr<SkImage> SVGImage::imageForCurrentFrame() |
217 { | 217 { |
218 return imageForCurrentFrameForContainer(KURL()); | 218 return imageForCurrentFrameForContainer(KURL()); |
219 } | 219 } |
220 | 220 |
221 void SVGImage::drawPatternForContainer(GraphicsContext* context, const FloatSize
containerSize, | 221 void SVGImage::drawPatternForContainer(GraphicsContext& context, const FloatSize
containerSize, |
222 float zoom, const FloatRect& srcRect, const FloatSize& tileScale, const Floa
tPoint& phase, | 222 float zoom, const FloatRect& srcRect, const FloatSize& tileScale, const Floa
tPoint& phase, |
223 SkXfermode::Mode compositeOp, const FloatRect& dstRect, | 223 SkXfermode::Mode compositeOp, const FloatRect& dstRect, |
224 const FloatSize& repeatSpacing, const KURL& url) | 224 const FloatSize& repeatSpacing, const KURL& url) |
225 { | 225 { |
226 // Tile adjusted for scaling/stretch. | 226 // Tile adjusted for scaling/stretch. |
227 FloatRect tile(srcRect); | 227 FloatRect tile(srcRect); |
228 tile.scale(tileScale.width(), tileScale.height()); | 228 tile.scale(tileScale.width(), tileScale.height()); |
229 | 229 |
230 // Expand the tile to account for repeat spacing. | 230 // Expand the tile to account for repeat spacing. |
231 FloatRect spacedTile(tile); | 231 FloatRect spacedTile(tile); |
232 spacedTile.expand(FloatSize(repeatSpacing)); | 232 spacedTile.expand(FloatSize(repeatSpacing)); |
233 | 233 |
234 SkPictureBuilder patternPicture(spacedTile, nullptr, context); | 234 SkPictureBuilder patternPicture(spacedTile, nullptr, &context); |
235 if (!DrawingRecorder::useCachedDrawingIfPossible(patternPicture.context(), *
this, DisplayItem::Type::SVGImage)) { | 235 if (!DrawingRecorder::useCachedDrawingIfPossible(patternPicture.context(), *
this, DisplayItem::Type::SVGImage)) { |
236 DrawingRecorder patternPictureRecorder(patternPicture.context(), *this,
DisplayItem::Type::SVGImage, spacedTile); | 236 DrawingRecorder patternPictureRecorder(patternPicture.context(), *this,
DisplayItem::Type::SVGImage, spacedTile); |
237 // When generating an expanded tile, make sure we don't draw into the sp
acing area. | 237 // When generating an expanded tile, make sure we don't draw into the sp
acing area. |
238 if (tile != spacedTile) | 238 if (tile != spacedTile) |
239 patternPicture.context().clip(tile); | 239 patternPicture.context().clip(tile); |
240 SkPaint paint; | 240 SkPaint paint; |
241 drawForContainer(patternPicture.context().canvas(), paint, containerSize
, zoom, tile, srcRect, url); | 241 drawForContainer(patternPicture.context().canvas(), paint, containerSize
, zoom, tile, srcRect, url); |
242 } | 242 } |
243 RefPtr<const SkPicture> tilePicture = patternPicture.endRecording(); | 243 RefPtr<const SkPicture> tilePicture = patternPicture.endRecording(); |
244 | 244 |
245 SkMatrix patternTransform; | 245 SkMatrix patternTransform; |
246 patternTransform.setTranslate(phase.x() + spacedTile.x(), phase.y() + spaced
Tile.y()); | 246 patternTransform.setTranslate(phase.x() + spacedTile.x(), phase.y() + spaced
Tile.y()); |
247 RefPtr<SkShader> patternShader = adoptRef(SkShader::CreatePictureShader( | 247 RefPtr<SkShader> patternShader = adoptRef(SkShader::CreatePictureShader( |
248 tilePicture.get(), SkShader::kRepeat_TileMode, SkShader::kRepeat_TileMod
e, | 248 tilePicture.get(), SkShader::kRepeat_TileMode, SkShader::kRepeat_TileMod
e, |
249 &patternTransform, nullptr)); | 249 &patternTransform, nullptr)); |
250 | 250 |
251 SkPaint paint; | 251 SkPaint paint; |
252 paint.setShader(patternShader.get()); | 252 paint.setShader(patternShader.get()); |
253 paint.setXfermodeMode(compositeOp); | 253 paint.setXfermodeMode(compositeOp); |
254 paint.setColorFilter(context->colorFilter()); | 254 paint.setColorFilter(context.colorFilter()); |
255 context->drawRect(dstRect, paint); | 255 context.drawRect(dstRect, paint); |
256 } | 256 } |
257 | 257 |
258 PassRefPtr<SkImage> SVGImage::imageForCurrentFrameForContainer(const KURL& url) | 258 PassRefPtr<SkImage> SVGImage::imageForCurrentFrameForContainer(const KURL& url) |
259 { | 259 { |
260 if (!m_page) | 260 if (!m_page) |
261 return nullptr; | 261 return nullptr; |
262 | 262 |
263 SkPictureRecorder recorder; | 263 SkPictureRecorder recorder; |
264 SkCanvas* canvas = recorder.beginRecording(width(), height()); | 264 SkCanvas* canvas = recorder.beginRecording(width(), height()); |
265 drawForContainer(canvas, SkPaint(), FloatSize(size()), 1, rect(), rect(), ur
l); | 265 drawForContainer(canvas, SkPaint(), FloatSize(size()), 1, rect(), rect(), ur
l); |
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
509 | 509 |
510 return m_page; | 510 return m_page; |
511 } | 511 } |
512 | 512 |
513 String SVGImage::filenameExtension() const | 513 String SVGImage::filenameExtension() const |
514 { | 514 { |
515 return "svg"; | 515 return "svg"; |
516 } | 516 } |
517 | 517 |
518 } | 518 } |
OLD | NEW |