Chromium Code Reviews| Index: third_party/WebKit/Source/modules/webgl/WebGL2RenderingContextBase.cpp |
| diff --git a/third_party/WebKit/Source/modules/webgl/WebGL2RenderingContextBase.cpp b/third_party/WebKit/Source/modules/webgl/WebGL2RenderingContextBase.cpp |
| index 67204a9facc19aa68490ebbe714478df25078954..fd8f73a7acaafae896960cf580391d9ff1b19fe2 100644 |
| --- a/third_party/WebKit/Source/modules/webgl/WebGL2RenderingContextBase.cpp |
| +++ b/third_party/WebKit/Source/modules/webgl/WebGL2RenderingContextBase.cpp |
| @@ -1072,7 +1072,7 @@ void WebGL2RenderingContextBase::texSubImage3D(GLenum target, GLint level, GLint |
| if (format == GL_RGBA && type == GL_UNSIGNED_BYTE && !m_unpackFlipY && !m_unpackPremultiplyAlpha) { |
| needConversion = false; |
| } else { |
| - if (!WebGLImageConversion::extractImageData(pixels->data()->data(), pixels->size(), format, type, m_unpackFlipY, m_unpackPremultiplyAlpha, data)) { |
| + if (!WebGLImageConversion::extractImageData(pixels->data()->data(), WebGLImageConversion::DataFormat::DataFormatRGBA8, pixels->size(), format, type, m_unpackFlipY, m_unpackPremultiplyAlpha, data)) { |
| synthesizeGLError(GL_INVALID_VALUE, "texSubImage3D", "bad image data"); |
| return; |
| } |
| @@ -1149,20 +1149,28 @@ void WebGL2RenderingContextBase::texSubImage3D(GLenum target, GLint level, GLint |
| type = GL_FLOAT; |
| } |
| ASSERT(bitmap->bitmapImage()); |
| - OwnPtr<uint8_t[]> pixelData = bitmap->copyBitmapData(bitmap->isPremultiplied() ? PremultiplyAlpha : DontPremultiplyAlpha); |
| + RefPtr<SkImage> skImage = bitmap->bitmapImage()->imageForCurrentFrame(); |
| + SkPixmap pixmap; |
| + uint8_t* pixelData = nullptr; |
|
Justin Novosad
2016/05/27 14:16:19
Should use an OwnPtr for this.
xidachen
2016/05/27 15:10:13
I don't think we can do that. SkImage is in charge
Justin Novosad
2016/05/27 16:13:48
That just means you were not doing it right.
Not u
xidachen
2016/05/27 17:14:56
Yes, that makes perfect sense. Thanks for pointing
|
| + bool peekSucceed = skImage->peekPixels(&pixmap); |
| + if (peekSucceed) |
| + pixelData = static_cast<uint8_t*>(pixmap.writable_addr()); |
| + else if (skImage->isTextureBacked()) |
| + pixelData = bitmap->copyBitmapData(bitmap->isPremultiplied() ? PremultiplyAlpha : DontPremultiplyAlpha).leakPtr(); |
| Vector<uint8_t> data; |
| bool needConversion = true; |
| - if (format == GL_RGBA && type == GL_UNSIGNED_BYTE) { |
| + if (((peekSucceed && pixmap.colorType() == SkColorType::kRGBA_8888_SkColorType) || !peekSucceed) && format == GL_RGBA && type == GL_UNSIGNED_BYTE) { |
|
Zhenyao Mo
2016/05/27 13:49:21
if peekSucceed is false, why needConversion is set
xidachen
2016/05/27 13:54:44
Sorry for this long if statement. Allow me to expl
Zhenyao Mo
2016/05/27 14:08:30
You are right. I got confused. Should not read co
Justin Novosad
2016/05/27 14:16:19
Please break-up long expressions make the code mor
xidachen
2016/05/27 15:10:13
Done.
|
| needConversion = false; |
| } else { |
| // In the case of ImageBitmap, we do not need to apply flipY or premultiplyAlpha. |
| - if (!WebGLImageConversion::extractImageData(pixelData.get(), bitmap->size(), format, type, false, false, data)) { |
| + if ((peekSucceed && pixmap.colorType() == SkColorType::kBGRA_8888_SkColorType && !WebGLImageConversion::extractImageData(pixelData, WebGLImageConversion::DataFormat::DataFormatBGRA8, bitmap->size(), format, type, false, false, data)) |
| + || (((peekSucceed && pixmap.colorType() == SkColorType::kRGBA_8888_SkColorType) || !peekSucceed) && !WebGLImageConversion::extractImageData(pixelData, WebGLImageConversion::DataFormat::DataFormatRGBA8, bitmap->size(), format, type, false, false, data))) { |
| synthesizeGLError(GL_INVALID_VALUE, "texSubImage3D", "bad image data"); |
| return; |
| } |
| } |
| resetUnpackParameters(); |
| - contextGL()->TexSubImage3D(target, level, xoffset, yoffset, zoffset, bitmap->width(), bitmap->height(), 1, format, type, needConversion ? data.data() : pixelData.get()); |
| + contextGL()->TexSubImage3D(target, level, xoffset, yoffset, zoffset, bitmap->width(), bitmap->height(), 1, format, type, needConversion ? data.data() : pixelData); |
| restoreUnpackParameters(); |
| } |