Index: third_party/WebKit/Source/platform/graphics/gpu/WebGLImageConversion.cpp |
diff --git a/third_party/WebKit/Source/platform/graphics/gpu/WebGLImageConversion.cpp b/third_party/WebKit/Source/platform/graphics/gpu/WebGLImageConversion.cpp |
index 48d109cf2fcb93745b9074e44e594fa9cc739ba9..eb983aae54ece40f4e73f2b4df320a44c69eb6d7 100644 |
--- a/third_party/WebKit/Source/platform/graphics/gpu/WebGLImageConversion.cpp |
+++ b/third_party/WebKit/Source/platform/graphics/gpu/WebGLImageConversion.cpp |
@@ -1618,6 +1618,24 @@ void Pack<WebGLImageConversion::kDataFormatRGBA32_S, |
template <> |
void Pack<WebGLImageConversion::kDataFormatRGBA2_10_10_10, |
+ WebGLImageConversion::kAlphaDoNothing, |
+ float, |
+ uint32_t>(const float* source, |
+ uint32_t* destination, |
+ unsigned pixels_per_row) { |
+ for (unsigned i = 0; i < pixels_per_row; ++i) { |
+ uint32_t r = static_cast<uint32_t>(source[0] * 1023.0f); |
+ uint32_t g = static_cast<uint32_t>(source[1] * 1023.0f); |
+ uint32_t b = static_cast<uint32_t>(source[2] * 1023.0f); |
+ uint32_t a = static_cast<uint32_t>(source[3] * 3.0f); |
+ destination[0] = (a << 30) | (b << 20) | (g << 10) | r; |
+ source += 4; |
+ destination += 1; |
+ } |
+} |
+ |
+template <> |
+void Pack<WebGLImageConversion::kDataFormatRGBA2_10_10_10, |
WebGLImageConversion::kAlphaDoPremultiply, |
float, |
uint32_t>(const float* source, |
@@ -1635,6 +1653,25 @@ void Pack<WebGLImageConversion::kDataFormatRGBA2_10_10_10, |
} |
template <> |
+void Pack<WebGLImageConversion::kDataFormatRGBA2_10_10_10, |
+ WebGLImageConversion::kAlphaDoUnmultiply, |
+ float, |
+ uint32_t>(const float* source, |
+ uint32_t* destination, |
+ unsigned pixels_per_row) { |
+ for (unsigned i = 0; i < pixels_per_row; ++i) { |
+ float scale_factor = source[3] ? 1023.0f / source[3] : 1023.0f; |
+ uint32_t r = static_cast<uint32_t>(source[0] * scale_factor); |
+ uint32_t g = static_cast<uint32_t>(source[1] * scale_factor); |
+ uint32_t b = static_cast<uint32_t>(source[2] * scale_factor); |
+ uint32_t a = static_cast<uint32_t>(source[3] * 3.0f); |
+ destination[0] = (a << 30) | (b << 20) | (g << 10) | r; |
+ source += 4; |
+ destination += 1; |
+ } |
+} |
+ |
+template <> |
void Pack<WebGLImageConversion::kDataFormatRG8, |
WebGLImageConversion::kAlphaDoNothing, |
uint8_t, |
@@ -2405,7 +2442,8 @@ struct SupportsConversionFromDomElements { |
Format == WebGLImageConversion::kDataFormatR16F || |
Format == WebGLImageConversion::kDataFormatRGBA5551 || |
Format == WebGLImageConversion::kDataFormatRGBA4444 || |
- Format == WebGLImageConversion::kDataFormatRGB565; |
+ Format == WebGLImageConversion::kDataFormatRGB565 || |
+ Format == WebGLImageConversion::kDataFormatRGBA2_10_10_10; |
}; |
template <WebGLImageConversion::DataFormat SrcFormat, |