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

Side by Side Diff: third_party/WebKit/Source/core/html/HTMLCanvasElement.cpp

Issue 2517693002: Add null check in createTransparentImage (Closed)
Patch Set: Created 4 years, 1 month 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2004, 2006, 2007 Apple Inc. All rights reserved. 2 * Copyright (C) 2004, 2006, 2007 Apple Inc. All rights reserved.
3 * Copyright (C) 2007 Alp Toker <alp@atoker.com> 3 * Copyright (C) 2007 Alp Toker <alp@atoker.com>
4 * Copyright (C) 2010 Torch Mobile (Beijing) Co. Ltd. All rights reserved. 4 * Copyright (C) 2010 Torch Mobile (Beijing) Co. Ltd. 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 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 108
109 // A default value of quality argument for toDataURL and toBlob 109 // A default value of quality argument for toDataURL and toBlob
110 // It is in an invalid range (outside 0.0 - 1.0) so that it will not be 110 // It is in an invalid range (outside 0.0 - 1.0) so that it will not be
111 // misinterpreted as a user-input value 111 // misinterpreted as a user-input value
112 const int UndefinedQualityValue = -1.0; 112 const int UndefinedQualityValue = -1.0;
113 113
114 PassRefPtr<Image> createTransparentImage(const IntSize& size) { 114 PassRefPtr<Image> createTransparentImage(const IntSize& size) {
115 DCHECK(ImageBuffer::canCreateImageBuffer(size)); 115 DCHECK(ImageBuffer::canCreateImageBuffer(size));
116 sk_sp<SkSurface> surface = 116 sk_sp<SkSurface> surface =
117 SkSurface::MakeRasterN32Premul(size.width(), size.height()); 117 SkSurface::MakeRasterN32Premul(size.width(), size.height());
118 return StaticBitmapImage::create(surface->makeImageSnapshot()); 118 return surface ? StaticBitmapImage::create(surface->makeImageSnapshot())
119 : nullptr;
119 } 120 }
120 121
121 } // namespace 122 } // namespace
122 123
123 inline HTMLCanvasElement::HTMLCanvasElement(Document& document) 124 inline HTMLCanvasElement::HTMLCanvasElement(Document& document)
124 : HTMLElement(canvasTag, document), 125 : HTMLElement(canvasTag, document),
125 ContextLifecycleObserver(&document), 126 ContextLifecycleObserver(&document),
126 PageVisibilityObserver(document.page()), 127 PageVisibilityObserver(document.page()),
127 m_size(DefaultWidth, DefaultHeight), 128 m_size(DefaultWidth, DefaultHeight),
128 m_context(this, nullptr), 129 m_context(this, nullptr),
(...skipping 1254 matching lines...) Expand 10 before | Expand all | Expand 10 after
1383 mojom::blink::OffscreenCanvasSurfacePtr service; 1384 mojom::blink::OffscreenCanvasSurfacePtr service;
1384 Platform::current()->interfaceProvider()->getInterface( 1385 Platform::current()->interfaceProvider()->getInterface(
1385 mojo::GetProxy(&service)); 1386 mojo::GetProxy(&service));
1386 m_surfaceLayerBridge = 1387 m_surfaceLayerBridge =
1387 wrapUnique(new CanvasSurfaceLayerBridge(std::move(service))); 1388 wrapUnique(new CanvasSurfaceLayerBridge(std::move(service)));
1388 return m_surfaceLayerBridge->createSurfaceLayer(this->width(), 1389 return m_surfaceLayerBridge->createSurfaceLayer(this->width(),
1389 this->height()); 1390 this->height());
1390 } 1391 }
1391 1392
1392 } // namespace blink 1393 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698