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

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

Issue 2821363003: WebGL: tex(Sub)Image(2D|3D) texImageSource support for RGB10_A2 textures. (Closed)
Patch Set: Created 3 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/WebKit/Source/modules/webgl/WebGLRenderingContextBase.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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,
« no previous file with comments | « third_party/WebKit/Source/modules/webgl/WebGLRenderingContextBase.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698