| 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 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 254 // Compensate for the container size rounding by adjusting the source rect. | 254 // Compensate for the container size rounding by adjusting the source rect. |
| 255 FloatSize adjustedSrcSize = scaledSrc.size(); | 255 FloatSize adjustedSrcSize = scaledSrc.size(); |
| 256 adjustedSrcSize.scale(roundedContainerSize.width() / containerSize.width(),
roundedContainerSize.height() / containerSize.height()); | 256 adjustedSrcSize.scale(roundedContainerSize.width() / containerSize.width(),
roundedContainerSize.height() / containerSize.height()); |
| 257 scaledSrc.setSize(adjustedSrcSize); | 257 scaledSrc.setSize(adjustedSrcSize); |
| 258 | 258 |
| 259 drawInternal(canvas, paint, dstRect, scaledSrc, DoNotRespectImageOrientation
, ClampImageToSourceRect, url); | 259 drawInternal(canvas, paint, dstRect, scaledSrc, DoNotRespectImageOrientation
, ClampImageToSourceRect, url); |
| 260 } | 260 } |
| 261 | 261 |
| 262 PassRefPtr<SkImage> SVGImage::imageForCurrentFrame() | 262 PassRefPtr<SkImage> SVGImage::imageForCurrentFrame() |
| 263 { | 263 { |
| 264 return imageForCurrentFrameForContainer(KURL()); | 264 return imageForCurrentFrameForContainer(KURL(), FloatSize(size())); |
| 265 } | 265 } |
| 266 | 266 |
| 267 void SVGImage::drawPatternForContainer(GraphicsContext& context, const FloatSize
containerSize, | 267 void SVGImage::drawPatternForContainer(GraphicsContext& context, const FloatSize
containerSize, |
| 268 float zoom, const FloatRect& srcRect, const FloatSize& tileScale, const Floa
tPoint& phase, | 268 float zoom, const FloatRect& srcRect, const FloatSize& tileScale, const Floa
tPoint& phase, |
| 269 SkXfermode::Mode compositeOp, const FloatRect& dstRect, | 269 SkXfermode::Mode compositeOp, const FloatRect& dstRect, |
| 270 const FloatSize& repeatSpacing, const KURL& url) | 270 const FloatSize& repeatSpacing, const KURL& url) |
| 271 { | 271 { |
| 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()); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 294 tilePicture.get(), SkShader::kRepeat_TileMode, SkShader::kRepeat_TileMod
e, | 294 tilePicture.get(), SkShader::kRepeat_TileMode, SkShader::kRepeat_TileMod
e, |
| 295 &patternTransform, nullptr)); | 295 &patternTransform, nullptr)); |
| 296 | 296 |
| 297 SkPaint paint; | 297 SkPaint paint; |
| 298 paint.setShader(patternShader.get()); | 298 paint.setShader(patternShader.get()); |
| 299 paint.setXfermodeMode(compositeOp); | 299 paint.setXfermodeMode(compositeOp); |
| 300 paint.setColorFilter(context.colorFilter()); | 300 paint.setColorFilter(context.colorFilter()); |
| 301 context.drawRect(dstRect, paint); | 301 context.drawRect(dstRect, paint); |
| 302 } | 302 } |
| 303 | 303 |
| 304 PassRefPtr<SkImage> SVGImage::imageForCurrentFrameForContainer(const KURL& url) | 304 PassRefPtr<SkImage> SVGImage::imageForCurrentFrameForContainer(const KURL& url,
const FloatSize& containerSize) |
| 305 { | 305 { |
| 306 if (!m_page) | 306 if (!m_page) |
| 307 return nullptr; | 307 return nullptr; |
| 308 | 308 |
| 309 SkPictureRecorder recorder; | 309 SkPictureRecorder recorder; |
| 310 SkCanvas* canvas = recorder.beginRecording(width(), height()); | 310 SkCanvas* canvas = recorder.beginRecording(width(), height()); |
| 311 drawForContainer(canvas, SkPaint(), FloatSize(size()), 1, rect(), rect(), ur
l); | 311 drawForContainer(canvas, SkPaint(), containerSize, 1, rect(), rect(), url); |
| 312 RefPtr<SkPicture> picture = adoptRef(recorder.endRecording()); | 312 RefPtr<SkPicture> picture = adoptRef(recorder.endRecording()); |
| 313 | 313 |
| 314 return adoptRef( | 314 return adoptRef( |
| 315 SkImage::NewFromPicture(picture.get(), SkISize::Make(width(), height()),
nullptr, nullptr)); | 315 SkImage::NewFromPicture(picture.get(), SkISize::Make(width(), height()),
nullptr, nullptr)); |
| 316 } | 316 } |
| 317 | 317 |
| 318 static bool drawNeedsLayer(const SkPaint& paint) | 318 static bool drawNeedsLayer(const SkPaint& paint) |
| 319 { | 319 { |
| 320 if (SkColorGetA(paint.getColor()) < 255) | 320 if (SkColorGetA(paint.getColor()) < 255) |
| 321 return true; | 321 return true; |
| (...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 554 | 554 |
| 555 return m_page; | 555 return m_page; |
| 556 } | 556 } |
| 557 | 557 |
| 558 String SVGImage::filenameExtension() const | 558 String SVGImage::filenameExtension() const |
| 559 { | 559 { |
| 560 return "svg"; | 560 return "svg"; |
| 561 } | 561 } |
| 562 | 562 |
| 563 } // namespace blink | 563 } // namespace blink |
| OLD | NEW |