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

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

Issue 2348263005: Eliminate one copy from ImageBitmap deserialization. (Closed)
Patch Set: Created 4 years, 2 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 395 matching lines...) Expand 10 before | Expand all | Expand 10 after
406 if (isPremultiplyAlphaReverted) { 406 if (isPremultiplyAlphaReverted) {
407 parsedOptions.premultiplyAlpha = false; 407 parsedOptions.premultiplyAlpha = false;
408 m_image = StaticBitmapImage::create(premulSkImageToUnPremul(m_image->ima geForCurrentFrame().get())); 408 m_image = StaticBitmapImage::create(premulSkImageToUnPremul(m_image->ima geForCurrentFrame().get()));
409 } 409 }
410 if (!m_image) 410 if (!m_image)
411 return; 411 return;
412 m_image->setOriginClean(canvas->originClean()); 412 m_image->setOriginClean(canvas->originClean());
413 m_image->setPremultiplied(parsedOptions.premultiplyAlpha); 413 m_image->setPremultiplied(parsedOptions.premultiplyAlpha);
414 } 414 }
415 415
416 ImageBitmap::ImageBitmap(std::unique_ptr<uint8_t[]> data, uint32_t width, uint32 _t height, bool isImageBitmapPremultiplied, bool isImageBitmapOriginClean) 416 ImageBitmap::ImageBitmap(const void* pixelData, uint32_t width, uint32_t height, bool isImageBitmapPremultiplied, bool isImageBitmapOriginClean)
417 { 417 {
418 SkImageInfo info = SkImageInfo::MakeN32(width, height, isImageBitmapPremulti plied ? kPremul_SkAlphaType : kUnpremul_SkAlphaType); 418 SkImageInfo info = SkImageInfo::MakeN32(width, height, isImageBitmapPremulti plied ? kPremul_SkAlphaType : kUnpremul_SkAlphaType);
419 m_image = StaticBitmapImage::create(SkImage::MakeRasterCopy(SkPixmap(info, d ata.get(), info.bytesPerPixel() * width))); 419 SkPixmap pixmap(info, pixelData, info.bytesPerPixel() * width);
420 m_image = StaticBitmapImage::create(SkImage::MakeRasterCopy(pixmap));
420 if (!m_image) 421 if (!m_image)
421 return; 422 return;
422 m_image->setPremultiplied(isImageBitmapPremultiplied); 423 m_image->setPremultiplied(isImageBitmapPremultiplied);
423 m_image->setOriginClean(isImageBitmapOriginClean); 424 m_image->setOriginClean(isImageBitmapOriginClean);
424 } 425 }
425 426
426 static sk_sp<SkImage> scaleSkImage(sk_sp<SkImage> skImage, unsigned resizeWidth, unsigned resizeHeight, SkFilterQuality resizeQuality) 427 static sk_sp<SkImage> scaleSkImage(sk_sp<SkImage> skImage, unsigned resizeWidth, unsigned resizeHeight, SkFilterQuality resizeQuality)
427 { 428 {
428 SkImageInfo resizedInfo = SkImageInfo::Make(resizeWidth, resizeHeight, kN32_ SkColorType, kUnpremul_SkAlphaType); 429 SkImageInfo resizedInfo = SkImageInfo::Make(resizeWidth, resizeHeight, kN32_ SkColorType, kUnpremul_SkAlphaType);
429 RefPtr<ArrayBuffer> dstBuffer = ArrayBuffer::createOrNull(resizeWidth * resi zeHeight, resizedInfo.bytesPerPixel()); 430 RefPtr<ArrayBuffer> dstBuffer = ArrayBuffer::createOrNull(resizeWidth * resi zeHeight, resizedInfo.bytesPerPixel());
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
623 ImageBitmap* ImageBitmap::create(PassRefPtr<StaticBitmapImage> image, Optional<I ntRect> cropRect, const ImageBitmapOptions& options) 624 ImageBitmap* ImageBitmap::create(PassRefPtr<StaticBitmapImage> image, Optional<I ntRect> cropRect, const ImageBitmapOptions& options)
624 { 625 {
625 return new ImageBitmap(std::move(image), cropRect, options); 626 return new ImageBitmap(std::move(image), cropRect, options);
626 } 627 }
627 628
628 ImageBitmap* ImageBitmap::create(PassRefPtr<StaticBitmapImage> image) 629 ImageBitmap* ImageBitmap::create(PassRefPtr<StaticBitmapImage> image)
629 { 630 {
630 return new ImageBitmap(std::move(image)); 631 return new ImageBitmap(std::move(image));
631 } 632 }
632 633
633 ImageBitmap* ImageBitmap::create(std::unique_ptr<uint8_t[]> data, uint32_t width , uint32_t height, bool isImageBitmapPremultiplied, bool isImageBitmapOriginClea n) 634 ImageBitmap* ImageBitmap::create(const void* pixelData, uint32_t width, uint32_t height, bool isImageBitmapPremultiplied, bool isImageBitmapOriginClean)
634 { 635 {
635 return new ImageBitmap(std::move(data), width, height, isImageBitmapPremulti plied, isImageBitmapOriginClean); 636 return new ImageBitmap(pixelData, width, height, isImageBitmapPremultiplied, isImageBitmapOriginClean);
636 } 637 }
637 638
638 void ImageBitmap::close() 639 void ImageBitmap::close()
639 { 640 {
640 if (!m_image || m_isNeutered) 641 if (!m_image || m_isNeutered)
641 return; 642 return;
642 m_image.clear(); 643 m_image.clear();
643 m_isNeutered = true; 644 m_isNeutered = true;
644 } 645 }
645 646
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
708 FloatSize ImageBitmap::elementSize(const FloatSize&) const 709 FloatSize ImageBitmap::elementSize(const FloatSize&) const
709 { 710 {
710 return FloatSize(width(), height()); 711 return FloatSize(width(), height());
711 } 712 }
712 713
713 DEFINE_TRACE(ImageBitmap) 714 DEFINE_TRACE(ImageBitmap)
714 { 715 {
715 } 716 }
716 717
717 } // namespace blink 718 } // 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