| 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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 52 #include "platform/TraceEvent.h" | 52 #include "platform/TraceEvent.h" |
| 53 #include "platform/geometry/IntRect.h" | 53 #include "platform/geometry/IntRect.h" |
| 54 #include "platform/graphics/GraphicsContext.h" | 54 #include "platform/graphics/GraphicsContext.h" |
| 55 #include "platform/graphics/ImageBuffer.h" | 55 #include "platform/graphics/ImageBuffer.h" |
| 56 #include "platform/graphics/ImageObserver.h" | 56 #include "platform/graphics/ImageObserver.h" |
| 57 #include "platform/graphics/paint/ClipRecorder.h" | 57 #include "platform/graphics/paint/ClipRecorder.h" |
| 58 #include "platform/graphics/paint/DisplayItemListContextRecorder.h" | 58 #include "platform/graphics/paint/DisplayItemListContextRecorder.h" |
| 59 #include "platform/graphics/paint/DrawingRecorder.h" | 59 #include "platform/graphics/paint/DrawingRecorder.h" |
| 60 #include "platform/graphics/paint/SkPictureBuilder.h" | 60 #include "platform/graphics/paint/SkPictureBuilder.h" |
| 61 #include "third_party/skia/include/core/SkPicture.h" | 61 #include "third_party/skia/include/core/SkPicture.h" |
| 62 #include "wtf/Optional.h" |
| 62 #include "wtf/PassRefPtr.h" | 63 #include "wtf/PassRefPtr.h" |
| 63 | 64 |
| 64 namespace blink { | 65 namespace blink { |
| 65 | 66 |
| 66 SVGImage::SVGImage(ImageObserver* observer) | 67 SVGImage::SVGImage(ImageObserver* observer) |
| 67 : Image(observer) | 68 : Image(observer) |
| 68 { | 69 { |
| 69 } | 70 } |
| 70 | 71 |
| 71 SVGImage::~SVGImage() | 72 SVGImage::~SVGImage() |
| (...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 283 // there may have been a previous url/fragment that needs to be reset. | 284 // there may have been a previous url/fragment that needs to be reset. |
| 284 view->scrollToFragment(m_url); | 285 view->scrollToFragment(m_url); |
| 285 | 286 |
| 286 { | 287 { |
| 287 DisplayItemListContextRecorder contextRecorder(*context); | 288 DisplayItemListContextRecorder contextRecorder(*context); |
| 288 GraphicsContext& paintContext = contextRecorder.context(); | 289 GraphicsContext& paintContext = contextRecorder.context(); |
| 289 | 290 |
| 290 ClipRecorder clipRecorder(paintContext, *this, DisplayItem::ClipNodeImag
e, LayoutRect(enclosingIntRect(dstRect))); | 291 ClipRecorder clipRecorder(paintContext, *this, DisplayItem::ClipNodeImag
e, LayoutRect(enclosingIntRect(dstRect))); |
| 291 | 292 |
| 292 bool hasCompositing = compositeOp != SkXfermode::kSrcOver_Mode; | 293 bool hasCompositing = compositeOp != SkXfermode::kSrcOver_Mode; |
| 293 OwnPtr<CompositingRecorder> compositingRecorder; | 294 Optional<CompositingRecorder> compositingRecorder; |
| 294 if (hasCompositing || opacity < 1) | 295 if (hasCompositing || opacity < 1) |
| 295 compositingRecorder = adoptPtr(new CompositingRecorder(paintContext,
*this, compositeOp, opacity)); | 296 compositingRecorder.emplace(paintContext, *this, compositeOp, opacit
y); |
| 296 | 297 |
| 297 // We can only draw the entire frame, clipped to the rect we want. So co
mpute where the top left | 298 // We can only draw the entire frame, clipped to the rect we want. So co
mpute where the top left |
| 298 // of the image would be if we were drawing without clipping, and transl
ate accordingly. | 299 // of the image would be if we were drawing without clipping, and transl
ate accordingly. |
| 299 FloatSize scale(dstRect.width() / srcRect.width(), dstRect.height() / sr
cRect.height()); | 300 FloatSize scale(dstRect.width() / srcRect.width(), dstRect.height() / sr
cRect.height()); |
| 300 FloatSize topLeftOffset(srcRect.location().x() * scale.width(), srcRect.
location().y() * scale.height()); | 301 FloatSize topLeftOffset(srcRect.location().x() * scale.width(), srcRect.
location().y() * scale.height()); |
| 301 FloatPoint destOffset = dstRect.location() - topLeftOffset; | 302 FloatPoint destOffset = dstRect.location() - topLeftOffset; |
| 302 AffineTransform transform = AffineTransform::translation(destOffset.x(),
destOffset.y()); | 303 AffineTransform transform = AffineTransform::translation(destOffset.x(),
destOffset.y()); |
| 303 transform.scale(scale.width(), scale.height()); | 304 transform.scale(scale.width(), scale.height()); |
| 304 TransformRecorder transformRecorder(paintContext, *this, transform); | 305 TransformRecorder transformRecorder(paintContext, *this, transform); |
| 305 | 306 |
| (...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 467 | 468 |
| 468 return m_page; | 469 return m_page; |
| 469 } | 470 } |
| 470 | 471 |
| 471 String SVGImage::filenameExtension() const | 472 String SVGImage::filenameExtension() const |
| 472 { | 473 { |
| 473 return "svg"; | 474 return "svg"; |
| 474 } | 475 } |
| 475 | 476 |
| 476 } | 477 } |
| OLD | NEW |