| 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 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 240 void SVGImage::draw(GraphicsContext* context, const FloatRect& dstRect, const Fl
oatRect& srcRect, CompositeOperator compositeOp, blink::WebBlendMode blendMode) | 240 void SVGImage::draw(GraphicsContext* context, const FloatRect& dstRect, const Fl
oatRect& srcRect, CompositeOperator compositeOp, blink::WebBlendMode blendMode) |
| 241 { | 241 { |
| 242 if (!m_page) | 242 if (!m_page) |
| 243 return; | 243 return; |
| 244 | 244 |
| 245 GraphicsContextStateSaver stateSaver(*context); | 245 GraphicsContextStateSaver stateSaver(*context); |
| 246 context->setCompositeOperation(compositeOp, blendMode); | 246 context->setCompositeOperation(compositeOp, blendMode); |
| 247 context->clip(enclosingIntRect(dstRect)); | 247 context->clip(enclosingIntRect(dstRect)); |
| 248 | 248 |
| 249 bool compositingRequiresTransparencyLayer = compositeOp != CompositeSourceOv
er || blendMode != blink::WebBlendModeNormal; | 249 bool compositingRequiresTransparencyLayer = compositeOp != CompositeSourceOv
er || blendMode != blink::WebBlendModeNormal; |
| 250 if (compositingRequiresTransparencyLayer) { | 250 bool requiresTransparencyLayer = compositingRequiresTransparencyLayer || con
text->alpha() < 1; |
| 251 context->beginTransparencyLayer(1); | 251 if (requiresTransparencyLayer) { |
| 252 context->setCompositeOperation(CompositeSourceOver, blink::WebBlendModeN
ormal); | 252 context->beginTransparencyLayer(context->alpha()); |
| 253 if (compositingRequiresTransparencyLayer) |
| 254 context->setCompositeOperation(CompositeSourceOver, blink::WebBlendM
odeNormal); |
| 253 } | 255 } |
| 254 | 256 |
| 255 FloatSize scale(dstRect.width() / srcRect.width(), dstRect.height() / srcRec
t.height()); | 257 FloatSize scale(dstRect.width() / srcRect.width(), dstRect.height() / srcRec
t.height()); |
| 256 | 258 |
| 257 // We can only draw the entire frame, clipped to the rect we want. So comput
e where the top left | 259 // We can only draw the entire frame, clipped to the rect we want. So comput
e where the top left |
| 258 // of the image would be if we were drawing without clipping, and translate
accordingly. | 260 // of the image would be if we were drawing without clipping, and translate
accordingly. |
| 259 FloatSize topLeftOffset(srcRect.location().x() * scale.width(), srcRect.loca
tion().y() * scale.height()); | 261 FloatSize topLeftOffset(srcRect.location().x() * scale.width(), srcRect.loca
tion().y() * scale.height()); |
| 260 FloatPoint destOffset = dstRect.location() - topLeftOffset; | 262 FloatPoint destOffset = dstRect.location() - topLeftOffset; |
| 261 | 263 |
| 262 context->translate(destOffset.x(), destOffset.y()); | 264 context->translate(destOffset.x(), destOffset.y()); |
| 263 context->scale(scale); | 265 context->scale(scale); |
| 264 | 266 |
| 265 FrameView* view = frameView(); | 267 FrameView* view = frameView(); |
| 266 view->resize(containerSize()); | 268 view->resize(containerSize()); |
| 267 | 269 |
| 268 if (view->needsLayout()) | 270 if (view->needsLayout()) |
| 269 view->layout(); | 271 view->layout(); |
| 270 | 272 |
| 271 view->paint(context, enclosingIntRect(srcRect)); | 273 view->paint(context, enclosingIntRect(srcRect)); |
| 272 | 274 |
| 273 if (compositingRequiresTransparencyLayer) | 275 if (requiresTransparencyLayer) |
| 274 context->endLayer(); | 276 context->endLayer(); |
| 275 | 277 |
| 276 stateSaver.restore(); | 278 stateSaver.restore(); |
| 277 | 279 |
| 278 if (imageObserver()) | 280 if (imageObserver()) |
| 279 imageObserver()->didDraw(this); | 281 imageObserver()->didDraw(this); |
| 280 } | 282 } |
| 281 | 283 |
| 282 RenderBox* SVGImage::embeddedContentBox() const | 284 RenderBox* SVGImage::embeddedContentBox() const |
| 283 { | 285 { |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 412 | 414 |
| 413 return m_page; | 415 return m_page; |
| 414 } | 416 } |
| 415 | 417 |
| 416 String SVGImage::filenameExtension() const | 418 String SVGImage::filenameExtension() const |
| 417 { | 419 { |
| 418 return "svg"; | 420 return "svg"; |
| 419 } | 421 } |
| 420 | 422 |
| 421 } | 423 } |
| OLD | NEW |