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

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

Issue 1841833002: Deal gracefully with null {GraphicsContext,SkPictureBuilder}.endRecording() results. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Don't end recording twice in DrawingRecorder. Created 4 years, 8 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
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 269 matching lines...) Expand 10 before | Expand all | Expand 10 after
280 SkPictureBuilder patternPicture(spacedTile, nullptr, &context); 280 SkPictureBuilder patternPicture(spacedTile, nullptr, &context);
281 if (!DrawingRecorder::useCachedDrawingIfPossible(patternPicture.context(), * this, DisplayItem::Type::SVGImage)) { 281 if (!DrawingRecorder::useCachedDrawingIfPossible(patternPicture.context(), * this, DisplayItem::Type::SVGImage)) {
282 DrawingRecorder patternPictureRecorder(patternPicture.context(), *this, DisplayItem::Type::SVGImage, spacedTile); 282 DrawingRecorder patternPictureRecorder(patternPicture.context(), *this, DisplayItem::Type::SVGImage, spacedTile);
283 // When generating an expanded tile, make sure we don't draw into the sp acing area. 283 // When generating an expanded tile, make sure we don't draw into the sp acing area.
284 if (tile != spacedTile) 284 if (tile != spacedTile)
285 patternPicture.context().clip(tile); 285 patternPicture.context().clip(tile);
286 SkPaint paint; 286 SkPaint paint;
287 drawForContainer(patternPicture.context().canvas(), paint, containerSize , zoom, tile, srcRect, url); 287 drawForContainer(patternPicture.context().canvas(), paint, containerSize , zoom, tile, srcRect, url);
288 } 288 }
289 RefPtr<SkPicture> tilePicture = patternPicture.endRecording(); 289 RefPtr<SkPicture> tilePicture = patternPicture.endRecording();
290 if (!tilePicture)
291 return;
290 292
291 SkMatrix patternTransform; 293 SkMatrix patternTransform;
292 patternTransform.setTranslate(phase.x() + spacedTile.x(), phase.y() + spaced Tile.y()); 294 patternTransform.setTranslate(phase.x() + spacedTile.x(), phase.y() + spaced Tile.y());
293 295
294 SkPaint paint; 296 SkPaint paint;
295 paint.setShader(SkShader::MakePictureShader(toSkSp(tilePicture.release()), 297 paint.setShader(SkShader::MakePictureShader(toSkSp(tilePicture.release()),
296 SkShader::kRepeat_TileMode, SkShader::kRepeat_TileMode, &patternTransfor m, nullptr)); 298 SkShader::kRepeat_TileMode, SkShader::kRepeat_TileMode, &patternTransfor m, nullptr));
297 paint.setXfermodeMode(compositeOp); 299 paint.setXfermodeMode(compositeOp);
298 paint.setColorFilter(context.colorFilter()); 300 paint.setColorFilter(context.colorFilter());
299 context.drawRect(dstRect, paint); 301 context.drawRect(dstRect, paint);
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
363 ASSERT(!view->needsLayout()); 365 ASSERT(!view->needsLayout());
364 } 366 }
365 367
366 { 368 {
367 SkAutoCanvasRestore ar(canvas, false); 369 SkAutoCanvasRestore ar(canvas, false);
368 if (drawNeedsLayer(paint)) { 370 if (drawNeedsLayer(paint)) {
369 SkRect layerRect = dstRect; 371 SkRect layerRect = dstRect;
370 canvas->saveLayer(&layerRect, &paint); 372 canvas->saveLayer(&layerRect, &paint);
371 } 373 }
372 RefPtr<const SkPicture> recording = imagePicture.endRecording(); 374 RefPtr<const SkPicture> recording = imagePicture.endRecording();
373 canvas->drawPicture(recording.get()); 375 if (recording)
376 canvas->drawPicture(recording.get());
374 } 377 }
375 378
376 if (getImageObserver()) 379 if (getImageObserver())
377 getImageObserver()->didDraw(this); 380 getImageObserver()->didDraw(this);
378 381
379 // Start any (SMIL) animations if needed. This will restart or continue 382 // Start any (SMIL) animations if needed. This will restart or continue
380 // animations if preceded by calls to resetAnimation or stopAnimation 383 // animations if preceded by calls to resetAnimation or stopAnimation
381 // respectively. 384 // respectively.
382 startAnimation(); 385 startAnimation();
383 } 386 }
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
536 539
537 return m_page; 540 return m_page;
538 } 541 }
539 542
540 String SVGImage::filenameExtension() const 543 String SVGImage::filenameExtension() const
541 { 544 {
542 return "svg"; 545 return "svg";
543 } 546 }
544 547
545 } // namespace blink 548 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698