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

Side by Side Diff: third_party/WebKit/Source/core/frame/ImageBitmap.cpp

Issue 1694793002: Reland of: Revise the code for premultiplyAlpha=false for createImageBitmap(HTMLCanvasElement) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: update layout test Created 4 years, 10 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
« no previous file with comments | « third_party/WebKit/LayoutTests/fast/canvas/canvas-createImageBitmap-drawImage-with-options-expected.txt ('k') | 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 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "core/frame/ImageBitmap.h" 5 #include "core/frame/ImageBitmap.h"
6 6
7 #include "core/html/HTMLCanvasElement.h" 7 #include "core/html/HTMLCanvasElement.h"
8 #include "core/html/HTMLVideoElement.h" 8 #include "core/html/HTMLVideoElement.h"
9 #include "core/html/ImageData.h" 9 #include "core/html/ImageData.h"
10 #include "platform/image-decoders/ImageDecoder.h" 10 #include "platform/image-decoders/ImageDecoder.h"
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 } 183 }
184 m_image->setOriginClean(!video->wouldTaintOrigin(document->securityOrigin()) ); 184 m_image->setOriginClean(!video->wouldTaintOrigin(document->securityOrigin()) );
185 } 185 }
186 186
187 ImageBitmap::ImageBitmap(HTMLCanvasElement* canvas, const IntRect& cropRect, con st ImageBitmapOptions& options) 187 ImageBitmap::ImageBitmap(HTMLCanvasElement* canvas, const IntRect& cropRect, con st ImageBitmapOptions& options)
188 { 188 {
189 ASSERT(canvas->isPaintable()); 189 ASSERT(canvas->isPaintable());
190 bool imageOrientationFlipYFlag; 190 bool imageOrientationFlipYFlag;
191 bool premultiplyAlphaEnabledFlag; 191 bool premultiplyAlphaEnabledFlag;
192 parseOptions(options, imageOrientationFlipYFlag, premultiplyAlphaEnabledFlag ); 192 parseOptions(options, imageOrientationFlipYFlag, premultiplyAlphaEnabledFlag );
193 m_image = cropImage(canvas->copiedImage(BackBuffer, PreferAcceleration).get( ), cropRect, imageOrientationFlipYFlag, premultiplyAlphaEnabledFlag); 193 // canvas is always premultiplied, so set the last parameter to true and con vert to un-premul later
194 m_image = cropImage(canvas->copiedImage(BackBuffer, PreferAcceleration).get( ), cropRect, imageOrientationFlipYFlag, true);
195 if (!premultiplyAlphaEnabledFlag)
196 m_image = StaticBitmapImage::create(premulSkImageToUnPremul(m_image->ima geForCurrentFrame().get()));
194 m_image->setOriginClean(canvas->originClean()); 197 m_image->setOriginClean(canvas->originClean());
195 } 198 }
196 199
197 ImageBitmap::ImageBitmap(ImageData* data, const IntRect& cropRect, const ImageBi tmapOptions& options) 200 ImageBitmap::ImageBitmap(ImageData* data, const IntRect& cropRect, const ImageBi tmapOptions& options)
198 { 201 {
199 IntRect srcRect = intersection(cropRect, IntRect(IntPoint(), data->size())); 202 IntRect srcRect = intersection(cropRect, IntRect(IntPoint(), data->size()));
200 203
201 OwnPtr<ImageBuffer> buffer = ImageBuffer::create(cropRect.size(), NonOpaque, DoNotInitializeImagePixels); 204 OwnPtr<ImageBuffer> buffer = ImageBuffer::create(cropRect.size(), NonOpaque, DoNotInitializeImagePixels);
202 if (!buffer) 205 if (!buffer)
203 return; 206 return;
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
360 { 363 {
361 return FloatSize(width(), height()); 364 return FloatSize(width(), height());
362 } 365 }
363 366
364 DEFINE_TRACE(ImageBitmap) 367 DEFINE_TRACE(ImageBitmap)
365 { 368 {
366 ImageLoaderClient::trace(visitor); 369 ImageLoaderClient::trace(visitor);
367 } 370 }
368 371
369 } // namespace blink 372 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/LayoutTests/fast/canvas/canvas-createImageBitmap-drawImage-with-options-expected.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698