Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(236)

Side by Side Diff: Source/core/svg/graphics/SVGImage.cpp

Issue 1160183003: Use SkPictureBuilder in SVGShapePainter, and generalize SkPictureBuilder. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 267 matching lines...) Expand 10 before | Expand all | Expand 10 after
278 float opacity = context->getNormalizedAlpha() / 255.f; 278 float opacity = context->getNormalizedAlpha() / 255.f;
279 279
280 FrameView* view = frameView(); 280 FrameView* view = frameView();
281 view->resize(containerSize()); 281 view->resize(containerSize());
282 282
283 // Always call scrollToFragment, even if the url is empty, because 283 // Always call scrollToFragment, even if the url is empty, because
284 // 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.
285 view->scrollToFragment(m_url); 285 view->scrollToFragment(m_url);
286 286
287 { 287 {
288 DisplayItemListContextRecorder contextRecorder(*context); 288 LayoutRect paintRect(enclosingIntRect(dstRect));
289 GraphicsContext& paintContext = contextRecorder.context(); 289 SkPictureBuilder pictureBuilder(paintRect);
290 290
291 ClipRecorder clipRecorder(paintContext, *this, DisplayItem::ClipNodeImag e, LayoutRect(enclosingIntRect(dstRect))); 291 {
292 ClipRecorder clipRecorder(pictureBuilder.context(), *this, DisplayIt em::ClipNodeImage, paintRect);
292 293
293 bool hasCompositing = compositeOp != SkXfermode::kSrcOver_Mode; 294 bool hasCompositing = compositeOp != SkXfermode::kSrcOver_Mode;
294 OwnPtr<CompositingRecorder> compositingRecorder; 295 OwnPtr<CompositingRecorder> compositingRecorder;
295 if (hasCompositing || opacity < 1) 296 if (hasCompositing || opacity < 1)
296 compositingRecorder = adoptPtr(new CompositingRecorder(paintContext, *this, compositeOp, opacity)); 297 compositingRecorder = adoptPtr(new CompositingRecorder(pictureBu ilder.context(), *this, compositeOp, opacity));
297 298
298 // We can only draw the entire frame, clipped to the rect we want. So co mpute where the top left 299 // We can only draw the entire frame, clipped to the rect we want. S o compute where the top left
299 // of the image would be if we were drawing without clipping, and transl ate accordingly. 300 // of the image would be if we were drawing without clipping, and tr anslate accordingly.
300 FloatSize scale(dstRect.width() / srcRect.width(), dstRect.height() / sr cRect.height()); 301 FloatSize scale(dstRect.width() / srcRect.width(), dstRect.height() / srcRect.height());
301 FloatSize topLeftOffset(srcRect.location().x() * scale.width(), srcRect. location().y() * scale.height()); 302 FloatSize topLeftOffset(srcRect.location().x() * scale.width(), srcR ect.location().y() * scale.height());
302 FloatPoint destOffset = dstRect.location() - topLeftOffset; 303 FloatPoint destOffset = dstRect.location() - topLeftOffset;
303 AffineTransform transform = AffineTransform::translation(destOffset.x(), destOffset.y()); 304 AffineTransform transform = AffineTransform::translation(destOffset. x(), destOffset.y());
304 transform.scale(scale.width(), scale.height()); 305 transform.scale(scale.width(), scale.height());
305 TransformRecorder transformRecorder(paintContext, *this, transform); 306 TransformRecorder transformRecorder(pictureBuilder.context(), *this, transform);
306 307
307 view->updateLayoutAndStyleForPainting(); 308 view->updateLayoutAndStyleForPainting();
308 view->paint(&paintContext, enclosingIntRect(srcRect)); 309 view->paint(&pictureBuilder.context(), enclosingIntRect(srcRect));
310 }
311
312 pictureBuilder.endRecording()->playback(context->canvas());
309 ASSERT(!view->needsLayout()); 313 ASSERT(!view->needsLayout());
310 } 314 }
311 315
312 if (imageObserver()) 316 if (imageObserver())
313 imageObserver()->didDraw(this); 317 imageObserver()->didDraw(this);
314 318
315 // Start any (SMIL) animations if needed. This will restart or continue 319 // Start any (SMIL) animations if needed. This will restart or continue
316 // animations if preceded by calls to resetAnimation or stopAnimation 320 // animations if preceded by calls to resetAnimation or stopAnimation
317 // respectively. 321 // respectively.
318 startAnimation(); 322 startAnimation();
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
468 472
469 return m_page; 473 return m_page;
470 } 474 }
471 475
472 String SVGImage::filenameExtension() const 476 String SVGImage::filenameExtension() const
473 { 477 {
474 return "svg"; 478 return "svg";
475 } 479 }
476 480
477 } 481 }
OLDNEW
« Source/core/paint/SVGShapePainter.cpp ('K') | « Source/core/paint/SVGShapePainter.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698