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

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

Issue 2155973002: Save a bitmap copy when advancing to dependent GIF and WebP animation frames (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: finalizePixelsAndGetImage. Created 4 years, 3 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 // 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/AcceleratedStaticBitmapImage.h" 10 #include "platform/graphics/AcceleratedStaticBitmapImage.h"
(...skipping 24 matching lines...) Expand all
35 35
36 // The following two functions are helpers used in cropImage 36 // The following two functions are helpers used in cropImage
37 static inline IntRect normalizeRect(const IntRect& rect) 37 static inline IntRect normalizeRect(const IntRect& rect)
38 { 38 {
39 return IntRect(std::min(rect.x(), rect.maxX()), 39 return IntRect(std::min(rect.x(), rect.maxX()),
40 std::min(rect.y(), rect.maxY()), 40 std::min(rect.y(), rect.maxY()),
41 std::max(rect.width(), -rect.width()), 41 std::max(rect.width(), -rect.width()),
42 std::max(rect.height(), -rect.height())); 42 std::max(rect.height(), -rect.height()));
43 } 43 }
44 44
45 static bool frameIsValid(const SkBitmap& frameBitmap)
46 {
47 ASSERT(!frameBitmap.isNull() && !frameBitmap.empty() && frameBitmap.isImmuta ble());
48 return frameBitmap.colorType() == kN32_SkColorType;
49 }
50
51 ParsedOptions parseOptions(const ImageBitmapOptions& options, Optional<IntRect> cropRect, IntSize sourceSize) 45 ParsedOptions parseOptions(const ImageBitmapOptions& options, Optional<IntRect> cropRect, IntSize sourceSize)
52 { 46 {
53 ParsedOptions parsedOptions; 47 ParsedOptions parsedOptions;
54 if (options.imageOrientation() == imageOrientationFlipY) { 48 if (options.imageOrientation() == imageOrientationFlipY) {
55 parsedOptions.flipY = true; 49 parsedOptions.flipY = true;
56 } else { 50 } else {
57 parsedOptions.flipY = false; 51 parsedOptions.flipY = false;
58 DCHECK(options.imageOrientation() == imageBitmapOptionNone); 52 DCHECK(options.imageOrientation() == imageBitmapOptionNone);
59 } 53 }
60 if (options.premultiplyAlpha() == imageBitmapOptionNone) { 54 if (options.premultiplyAlpha() == imageBitmapOptionNone) {
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 return newSkImageFromRaster(info, std::move(dstPixels), input->width() * inf o.bytesPerPixel()); 167 return newSkImageFromRaster(info, std::move(dstPixels), input->width() * inf o.bytesPerPixel());
174 } 168 }
175 169
176 PassRefPtr<SkImage> ImageBitmap::getSkImageFromDecoder(std::unique_ptr<ImageDeco der> decoder) 170 PassRefPtr<SkImage> ImageBitmap::getSkImageFromDecoder(std::unique_ptr<ImageDeco der> decoder)
177 { 171 {
178 if (!decoder->frameCount()) 172 if (!decoder->frameCount())
179 return nullptr; 173 return nullptr;
180 ImageFrame* frame = decoder->frameBufferAtIndex(0); 174 ImageFrame* frame = decoder->frameBufferAtIndex(0);
181 if (!frame || frame->getStatus() != ImageFrame::FrameComplete) 175 if (!frame || frame->getStatus() != ImageFrame::FrameComplete)
182 return nullptr; 176 return nullptr;
183 SkBitmap bitmap = frame->bitmap(); 177 DCHECK_EQ(frame->bitmap().colorType(), kN32_SkColorType);
Peter Kasting 2016/08/30 06:59:40 The old code handled this conditionally, so this i
aleksandar.stojiljkovic 2016/09/21 20:56:57 Done. Didn't see how it could be different from kN
184 if (!frameIsValid(bitmap)) 178 return frame->finalizePixelsAndGetImage();
185 return nullptr;
186 return fromSkSp(SkImage::MakeFromBitmap(bitmap));
187 } 179 }
188 180
189 bool ImageBitmap::isResizeOptionValid(const ImageBitmapOptions& options, Excepti onState& exceptionState) 181 bool ImageBitmap::isResizeOptionValid(const ImageBitmapOptions& options, Excepti onState& exceptionState)
190 { 182 {
191 if ((options.hasResizeWidth() && options.resizeWidth() == 0) || (options.has ResizeHeight() && options.resizeHeight() == 0)) { 183 if ((options.hasResizeWidth() && options.resizeWidth() == 0) || (options.has ResizeHeight() && options.resizeHeight() == 0)) {
192 exceptionState.throwDOMException(InvalidStateError, "The resizeWidth or/ and resizeHeight is equal to 0."); 184 exceptionState.throwDOMException(InvalidStateError, "The resizeWidth or/ and resizeHeight is equal to 0.");
193 return false; 185 return false;
194 } 186 }
195 return true; 187 return true;
196 } 188 }
(...skipping 455 matching lines...) Expand 10 before | Expand all | Expand 10 after
652 FloatSize ImageBitmap::elementSize(const FloatSize&) const 644 FloatSize ImageBitmap::elementSize(const FloatSize&) const
653 { 645 {
654 return FloatSize(width(), height()); 646 return FloatSize(width(), height());
655 } 647 }
656 648
657 DEFINE_TRACE(ImageBitmap) 649 DEFINE_TRACE(ImageBitmap)
658 { 650 {
659 } 651 }
660 652
661 } // namespace blink 653 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698