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

Side by Side Diff: third_party/WebKit/Source/platform/graphics/gpu/WebGLImageConversion.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: DCHECK m_status in ImageFrame. Shortened commit message. Thanks kbr@. 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "platform/graphics/gpu/WebGLImageConversion.h" 5 #include "platform/graphics/gpu/WebGLImageConversion.h"
6 6
7 #include "platform/graphics/ImageObserver.h" 7 #include "platform/graphics/ImageObserver.h"
8 #include "platform/graphics/cpu/arm/WebGLImageConversionNEON.h" 8 #include "platform/graphics/cpu/arm/WebGLImageConversionNEON.h"
9 #include "platform/graphics/cpu/mips/WebGLImageConversionMSA.h" 9 #include "platform/graphics/cpu/mips/WebGLImageConversionMSA.h"
10 #include "platform/graphics/cpu/x86/WebGLImageConversionSSE.h" 10 #include "platform/graphics/cpu/x86/WebGLImageConversionSSE.h"
(...skipping 1929 matching lines...) Expand 10 before | Expand all | Expand 10 after
1940 } 1940 }
1941 } 1941 }
1942 m_success = true; 1942 m_success = true;
1943 return; 1943 return;
1944 } 1944 }
1945 1945
1946 bool frameIsValid(const SkBitmap& frameBitmap) 1946 bool frameIsValid(const SkBitmap& frameBitmap)
1947 { 1947 {
1948 return !frameBitmap.isNull() 1948 return !frameBitmap.isNull()
1949 && !frameBitmap.empty() 1949 && !frameBitmap.empty()
1950 && frameBitmap.isImmutable()
1951 && frameBitmap.colorType() == kN32_SkColorType; 1950 && frameBitmap.colorType() == kN32_SkColorType;
1952 } 1951 }
1953 1952
1954 } // anonymous namespace 1953 } // anonymous namespace
1955 1954
1956 WebGLImageConversion::PixelStoreParams::PixelStoreParams() 1955 WebGLImageConversion::PixelStoreParams::PixelStoreParams()
1957 : alignment(4) 1956 : alignment(4)
1958 , rowLength(0) 1957 , rowLength(0)
1959 , imageHeight(0) 1958 , imageHeight(0)
1960 , skipPixels(0) 1959 , skipPixels(0)
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after
2166 if (!decoder || !decoder->frameCount()) 2165 if (!decoder || !decoder->frameCount())
2167 return; 2166 return;
2168 ImageFrame* frame = decoder->frameBufferAtIndex(0); 2167 ImageFrame* frame = decoder->frameBufferAtIndex(0);
2169 if (!frame || frame->getStatus() != ImageFrame::FrameComplete) 2168 if (!frame || frame->getStatus() != ImageFrame::FrameComplete)
2170 return; 2169 return;
2171 hasAlpha = frame->hasAlpha(); 2170 hasAlpha = frame->hasAlpha();
2172 SkBitmap bitmap = frame->bitmap(); 2171 SkBitmap bitmap = frame->bitmap();
2173 if (!frameIsValid(bitmap)) 2172 if (!frameIsValid(bitmap))
2174 return; 2173 return;
2175 2174
2176 // TODO(fmalita): Partial frames are not supported currently: frameIsVal id ensures that 2175 // TODO(fmalita): Partial frames are not supported currently: only fully
2177 // only immutable/fully decoded frames make it through. We could potent ially relax this 2176 // decoded frames make it through. We could potentially relax this and
2178 // and allow SkImage::NewFromBitmap to make a copy. 2177 // use SkImage::MakeFromBitmap(bitmap) to make a copy.
2179 ASSERT(bitmap.isImmutable()); 2178 skiaImage = frame->finalizePixelsAndGetImage();
2180 skiaImage = SkImage::MakeFromBitmap(bitmap);
2181 info = bitmap.info(); 2179 info = bitmap.info();
2182 2180
2183 if (hasAlpha && premultiplyAlpha) 2181 if (hasAlpha && premultiplyAlpha)
2184 m_alphaOp = AlphaDoPremultiply; 2182 m_alphaOp = AlphaDoPremultiply;
2185 } else if (!premultiplyAlpha && hasAlpha) { 2183 } else if (!premultiplyAlpha && hasAlpha) {
2186 // 1. For texImage2D with HTMLVideoElment input, assume no PremultiplyAl pha had been applied and the alpha value for each pixel is 0xFF 2184 // 1. For texImage2D with HTMLVideoElment input, assume no PremultiplyAl pha had been applied and the alpha value for each pixel is 0xFF
2187 // which is true at present and may be changed in the future and needs a djustment accordingly. 2185 // which is true at present and may be changed in the future and needs a djustment accordingly.
2188 // 2. For texImage2D with HTMLCanvasElement input in which Alpha is alre ady Premultiplied in this port, 2186 // 2. For texImage2D with HTMLCanvasElement input in which Alpha is alre ady Premultiplied in this port,
2189 // do AlphaDoUnmultiply if UNPACK_PREMULTIPLY_ALPHA_WEBGL is set to fals e. 2187 // do AlphaDoUnmultiply if UNPACK_PREMULTIPLY_ALPHA_WEBGL is set to fals e.
2190 if (m_imageHtmlDomSource != HtmlDomVideo) 2188 if (m_imageHtmlDomSource != HtmlDomVideo)
(...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after
2516 DstType* dstRowStart = static_cast<DstType*>(pdst); 2514 DstType* dstRowStart = static_cast<DstType*>(pdst);
2517 pack<WebGLImageConversion::DataFormatRGB565, WebGLImageConversion::A lphaDoNothing>(srcRowStart, dstRowStart, pixelsPerRow); 2515 pack<WebGLImageConversion::DataFormatRGB565, WebGLImageConversion::A lphaDoNothing>(srcRowStart, dstRowStart, pixelsPerRow);
2518 } 2516 }
2519 break; 2517 break;
2520 default: 2518 default:
2521 break; 2519 break;
2522 } 2520 }
2523 } 2521 }
2524 2522
2525 } // namespace blink 2523 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698