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

Side by Side Diff: third_party/WebKit/Source/platform/graphics/gpu/WebGLImageConversion.cpp

Issue 2016043002: Avoid copy pixel data in texImage2D(ImageBitmap) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: change to OwnPtr Created 4 years, 6 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/CheckedInt.h" 7 #include "platform/CheckedInt.h"
8 #include "platform/graphics/ImageObserver.h" 8 #include "platform/graphics/ImageObserver.h"
9 #include "platform/graphics/cpu/arm/WebGLImageConversionNEON.h" 9 #include "platform/graphics/cpu/arm/WebGLImageConversionNEON.h"
10 #include "platform/graphics/cpu/x86/WebGLImageConversionSSE.h" 10 #include "platform/graphics/cpu/x86/WebGLImageConversionSSE.h"
(...skipping 2295 matching lines...) Expand 10 before | Expand all | Expand 10 after
2306 2306
2307 if (!packPixels(reinterpret_cast<const uint8_t*>(pixels), sourceFormat, widt h, height, sourceUnpackAlignment, format, type, alphaOp, data.data(), flipY)) 2307 if (!packPixels(reinterpret_cast<const uint8_t*>(pixels), sourceFormat, widt h, height, sourceUnpackAlignment, format, type, alphaOp, data.data(), flipY))
2308 return false; 2308 return false;
2309 if (ImageObserver *observer = image->getImageObserver()) 2309 if (ImageObserver *observer = image->getImageObserver())
2310 observer->didDraw(image); 2310 observer->didDraw(image);
2311 return true; 2311 return true;
2312 } 2312 }
2313 2313
2314 bool WebGLImageConversion::extractImageData( 2314 bool WebGLImageConversion::extractImageData(
2315 const uint8_t* imageData, 2315 const uint8_t* imageData,
2316 DataFormat sourceDataFormat,
2316 const IntSize& imageDataSize, 2317 const IntSize& imageDataSize,
2317 GLenum format, 2318 GLenum format,
2318 GLenum type, 2319 GLenum type,
2319 bool flipY, 2320 bool flipY,
2320 bool premultiplyAlpha, 2321 bool premultiplyAlpha,
2321 Vector<uint8_t>& data) 2322 Vector<uint8_t>& data)
2322 { 2323 {
2323 if (!imageData) 2324 if (!imageData)
2324 return false; 2325 return false;
2325 int width = imageDataSize.width(); 2326 int width = imageDataSize.width();
2326 int height = imageDataSize.height(); 2327 int height = imageDataSize.height();
2327 2328
2328 unsigned packedSize; 2329 unsigned packedSize;
2329 // Output data is tightly packed (alignment == 1). 2330 // Output data is tightly packed (alignment == 1).
2330 PixelStoreParams params; 2331 PixelStoreParams params;
2331 params.alignment = 1; 2332 params.alignment = 1;
2332 if (computeImageSizeInBytes(format, type, width, height, 1, params, &packedS ize, 0, 0) != GL_NO_ERROR) 2333 if (computeImageSizeInBytes(format, type, width, height, 1, params, &packedS ize, 0, 0) != GL_NO_ERROR)
2333 return false; 2334 return false;
2334 data.resize(packedSize); 2335 data.resize(packedSize);
2335 2336
2336 if (!packPixels(imageData, DataFormatRGBA8, width, height, 0, format, type, premultiplyAlpha ? AlphaDoPremultiply : AlphaDoNothing, data.data(), flipY)) 2337 if (!packPixels(imageData, sourceDataFormat, width, height, 0, format, type, premultiplyAlpha ? AlphaDoPremultiply : AlphaDoNothing, data.data(), flipY))
2337 return false; 2338 return false;
2338 2339
2339 return true; 2340 return true;
2340 } 2341 }
2341 2342
2342 bool WebGLImageConversion::extractTextureData( 2343 bool WebGLImageConversion::extractTextureData(
2343 unsigned width, 2344 unsigned width,
2344 unsigned height, 2345 unsigned height,
2345 GLenum format, GLenum type, 2346 GLenum format, GLenum type,
2346 unsigned unpackAlignment, 2347 unsigned unpackAlignment,
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
2403 } 2404 }
2404 2405
2405 FormatConverter converter(width, height, sourceData, destinationData, srcStr ide, dstStride); 2406 FormatConverter converter(width, height, sourceData, destinationData, srcStr ide, dstStride);
2406 converter.convert(sourceDataFormat, dstDataFormat, alphaOp); 2407 converter.convert(sourceDataFormat, dstDataFormat, alphaOp);
2407 if (!converter.Success()) 2408 if (!converter.Success())
2408 return false; 2409 return false;
2409 return true; 2410 return true;
2410 } 2411 }
2411 2412
2412 } // namespace blink 2413 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698