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

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

Issue 2097393002: Pass origin clean flag of ImageBitmap when structure clone (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 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/Source/core/frame/ImageBitmap.h ('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/graphics/skia/SkiaUtils.h" 10 #include "platform/graphics/skia/SkiaUtils.h"
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after
251 // canvas is always premultiplied, so set the last parameter to true and con vert to un-premul later 251 // canvas is always premultiplied, so set the last parameter to true and con vert to un-premul later
252 m_image = cropImage(canvas->copiedImage(BackBuffer, PreferAcceleration).get( ), cropRect, flipY, true); 252 m_image = cropImage(canvas->copiedImage(BackBuffer, PreferAcceleration).get( ), cropRect, flipY, true);
253 if (!m_image) 253 if (!m_image)
254 return; 254 return;
255 if (!premultiplyAlpha) 255 if (!premultiplyAlpha)
256 m_image = StaticBitmapImage::create(premulSkImageToUnPremul(m_image->ima geForCurrentFrame().get())); 256 m_image = StaticBitmapImage::create(premulSkImageToUnPremul(m_image->ima geForCurrentFrame().get()));
257 m_image->setOriginClean(canvas->originClean()); 257 m_image->setOriginClean(canvas->originClean());
258 m_image->setPremultiplied(premultiplyAlpha); 258 m_image->setPremultiplied(premultiplyAlpha);
259 } 259 }
260 260
261 ImageBitmap::ImageBitmap(ImageData* data, const IntRect& cropRect, const ImageBi tmapOptions& options, const bool& isImageDataPremultiplied) 261 // The last two parameters are used for structure-cloning.
262 ImageBitmap::ImageBitmap(ImageData* data, const IntRect& cropRect, const ImageBi tmapOptions& options, const bool& isImageDataPremultiplied, const bool& isImageD ataOriginClean)
262 { 263 {
263 bool flipY; 264 bool flipY;
264 bool premultiplyAlpha; 265 bool premultiplyAlpha;
265 parseOptions(options, flipY, premultiplyAlpha); 266 parseOptions(options, flipY, premultiplyAlpha);
266 IntRect srcRect = intersection(cropRect, IntRect(IntPoint(), data->size())); 267 IntRect srcRect = intersection(cropRect, IntRect(IntPoint(), data->size()));
267 268
268 // treat non-premultiplyAlpha as a special case 269 // treat non-premultiplyAlpha as a special case
269 if (!premultiplyAlpha) { 270 if (!premultiplyAlpha) {
270 unsigned char* srcAddr = data->data()->data(); 271 unsigned char* srcAddr = data->data()->data();
271 int srcHeight = data->size().height(); 272 int srcHeight = data->size().height();
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
309 else if (j % 4 == 2) 310 else if (j % 4 == 2)
310 copiedDataBuffer[dstStartCopyPosition + j] = srcAddr [srcStartCopyPosition + j - 2]; 311 copiedDataBuffer[dstStartCopyPosition + j] = srcAddr [srcStartCopyPosition + j - 2];
311 else 312 else
312 copiedDataBuffer[dstStartCopyPosition + j] = srcAddr [srcStartCopyPosition + j]; 313 copiedDataBuffer[dstStartCopyPosition + j] = srcAddr [srcStartCopyPosition + j];
313 } 314 }
314 } 315 }
315 } 316 }
316 m_image = StaticBitmapImage::create(newSkImageFromRaster(info, std:: move(copiedDataBuffer), dstPixelBytesPerRow)); 317 m_image = StaticBitmapImage::create(newSkImageFromRaster(info, std:: move(copiedDataBuffer), dstPixelBytesPerRow));
317 } 318 }
318 m_image->setPremultiplied(premultiplyAlpha); 319 m_image->setPremultiplied(premultiplyAlpha);
320 m_image->setOriginClean(isImageDataOriginClean);
319 return; 321 return;
320 } 322 }
321 323
322 std::unique_ptr<ImageBuffer> buffer = ImageBuffer::create(cropRect.size(), N onOpaque, DoNotInitializeImagePixels); 324 std::unique_ptr<ImageBuffer> buffer = ImageBuffer::create(cropRect.size(), N onOpaque, DoNotInitializeImagePixels);
323 if (!buffer) 325 if (!buffer)
324 return; 326 return;
325 327
326 if (srcRect.isEmpty()) { 328 if (srcRect.isEmpty()) {
327 m_image = StaticBitmapImage::create(buffer->newSkImageSnapshot(PreferNoA cceleration, SnapshotReasonUnknown)); 329 m_image = StaticBitmapImage::create(buffer->newSkImageSnapshot(PreferNoA cceleration, SnapshotReasonUnknown));
328 return; 330 return;
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
396 IntRect normalizedCropRect = normalizeRect(cropRect); 398 IntRect normalizedCropRect = normalizeRect(cropRect);
397 return new ImageBitmap(video, normalizedCropRect, document, options); 399 return new ImageBitmap(video, normalizedCropRect, document, options);
398 } 400 }
399 401
400 ImageBitmap* ImageBitmap::create(HTMLCanvasElement* canvas, const IntRect& cropR ect, const ImageBitmapOptions& options) 402 ImageBitmap* ImageBitmap::create(HTMLCanvasElement* canvas, const IntRect& cropR ect, const ImageBitmapOptions& options)
401 { 403 {
402 IntRect normalizedCropRect = normalizeRect(cropRect); 404 IntRect normalizedCropRect = normalizeRect(cropRect);
403 return new ImageBitmap(canvas, normalizedCropRect, options); 405 return new ImageBitmap(canvas, normalizedCropRect, options);
404 } 406 }
405 407
406 ImageBitmap* ImageBitmap::create(ImageData* data, const IntRect& cropRect, const ImageBitmapOptions& options, const bool& isImageDataPremultiplied) 408 ImageBitmap* ImageBitmap::create(ImageData* data, const IntRect& cropRect, const ImageBitmapOptions& options, const bool& isImageDataPremultiplied, const bool& isImageDataOriginClean)
407 { 409 {
408 IntRect normalizedCropRect = normalizeRect(cropRect); 410 IntRect normalizedCropRect = normalizeRect(cropRect);
409 return new ImageBitmap(data, normalizedCropRect, options, isImageDataPremult iplied); 411 return new ImageBitmap(data, normalizedCropRect, options, isImageDataPremult iplied, isImageDataOriginClean);
410 } 412 }
411 413
412 ImageBitmap* ImageBitmap::create(ImageBitmap* bitmap, const IntRect& cropRect, c onst ImageBitmapOptions& options) 414 ImageBitmap* ImageBitmap::create(ImageBitmap* bitmap, const IntRect& cropRect, c onst ImageBitmapOptions& options)
413 { 415 {
414 IntRect normalizedCropRect = normalizeRect(cropRect); 416 IntRect normalizedCropRect = normalizeRect(cropRect);
415 return new ImageBitmap(bitmap, normalizedCropRect, options); 417 return new ImageBitmap(bitmap, normalizedCropRect, options);
416 } 418 }
417 419
418 ImageBitmap* ImageBitmap::create(PassRefPtr<StaticBitmapImage> image, const IntR ect& cropRect, const ImageBitmapOptions& options) 420 ImageBitmap* ImageBitmap::create(PassRefPtr<StaticBitmapImage> image, const IntR ect& cropRect, const ImageBitmapOptions& options)
419 { 421 {
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
519 FloatSize ImageBitmap::elementSize(const FloatSize&) const 521 FloatSize ImageBitmap::elementSize(const FloatSize&) const
520 { 522 {
521 return FloatSize(width(), height()); 523 return FloatSize(width(), height());
522 } 524 }
523 525
524 DEFINE_TRACE(ImageBitmap) 526 DEFINE_TRACE(ImageBitmap)
525 { 527 {
526 } 528 }
527 529
528 } // namespace blink 530 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/frame/ImageBitmap.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698