Fix the issue that some possible source formats are ignored for float textures in...
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 5 Feb 2013 02:25:46 +0000 (02:25 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 5 Feb 2013 02:25:46 +0000 (02:25 +0000)
https://bugs.webkit.org/show_bug.cgi?id=108812

Patch by Jun Jiang <jun.a.jiang@intel.com> on 2013-02-04
Reviewed by Kenneth Russell.

Already covered by latest WebGL conformance test.

* platform/graphics/GraphicsContext3D.cpp:
(WebCore):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@141843 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/platform/graphics/GraphicsContext3D.cpp

index 0df6a291985b58a8606e3927dd4d84f744a00fa0..6a3dd1be146925403e18fb878000bbd8d4b73f12 100644 (file)
@@ -1,3 +1,15 @@
+2013-02-04  Jun Jiang  <jun.a.jiang@intel.com>
+
+        Fix the issue that some possible source formats are ignored for float textures in texture packing for CG port
+        https://bugs.webkit.org/show_bug.cgi?id=108812
+
+        Reviewed by Kenneth Russell.
+
+        Already covered by latest WebGL conformance test.
+
+        * platform/graphics/GraphicsContext3D.cpp:
+        (WebCore):
+
 2013-02-04  Gyuyoung Kim  <gyuyoung.kim@samsung.com>
 
         [EFL] Remove needless local variables in LocalizedStringsEfl.cpp
index 0bf0a9cbf42b42cc00139f393eafbf060efd2c32..59dad26f78826cf8479a237c5b36c63c4761ab38 100644 (file)
@@ -519,6 +519,58 @@ template<> ALWAYS_INLINE void unpack<GraphicsContext3D::DataFormatBGRA8, uint8_t
     }
 }
 
+template<> ALWAYS_INLINE void unpack<GraphicsContext3D::DataFormatABGR8, uint8_t, float>(const uint8_t* source, float* destination, unsigned pixelsPerRow)
+{
+    const float scaleFactor = 1.0f / 255.0f;
+    for (unsigned i = 0; i < pixelsPerRow; ++i) {
+        destination[0] = source[3] * scaleFactor;
+        destination[1] = source[2] * scaleFactor;
+        destination[2] = source[1] * scaleFactor;
+        destination[3] = source[0] * scaleFactor;
+        source += 4;
+        destination += 4;
+    }
+}
+
+template<> ALWAYS_INLINE void unpack<GraphicsContext3D::DataFormatARGB8, uint8_t, float>(const uint8_t* source, float* destination, unsigned pixelsPerRow)
+{
+    const float scaleFactor = 1.0f / 255.0f;
+    for (unsigned i = 0; i < pixelsPerRow; ++i) {
+        destination[0] = source[1] * scaleFactor;
+        destination[1] = source[2] * scaleFactor;
+        destination[2] = source[3] * scaleFactor;
+        destination[3] = source[0] * scaleFactor;
+        source += 4;
+        destination += 4;
+    }
+}
+
+template<> ALWAYS_INLINE void unpack<GraphicsContext3D::DataFormatRGB8, uint8_t, float>(const uint8_t* source, float* destination, unsigned pixelsPerRow)
+{
+    const float scaleFactor = 1.0f / 255.0f;
+    for (unsigned i = 0; i < pixelsPerRow; ++i) {
+        destination[0] = source[0] * scaleFactor;
+        destination[1] = source[1] * scaleFactor;
+        destination[2] = source[2] * scaleFactor;
+        destination[3] = 1;
+        source += 3;
+        destination += 4;
+    }
+}
+
+template<> ALWAYS_INLINE void unpack<GraphicsContext3D::DataFormatBGR8, uint8_t, float>(const uint8_t* source, float* destination, unsigned pixelsPerRow)
+{
+    const float scaleFactor = 1.0f / 255.0f;
+    for (unsigned i = 0; i < pixelsPerRow; ++i) {
+        destination[0] = source[2] * scaleFactor;
+        destination[1] = source[1] * scaleFactor;
+        destination[2] = source[0] * scaleFactor;
+        destination[3] = 1;
+        source += 3;
+        destination += 4;
+    }
+}
+
 template<> ALWAYS_INLINE void unpack<GraphicsContext3D::DataFormatRGB32F, float, float>(const float* source, float* destination, unsigned pixelsPerRow)
 {
     for (unsigned int i = 0; i < pixelsPerRow; ++i) {
@@ -1239,10 +1291,6 @@ ALWAYS_INLINE void FormatConverter::convert()
         ASSERT_NOT_REACHED();
         return;
     }
-    if (IsFloatFormat<DstFormat>::Value && !IsFloatFormat<SrcFormat>::Value && SrcFormat != GraphicsContext3D::DataFormatRGBA8 && SrcFormat != GraphicsContext3D::DataFormatBGRA8) {
-        ASSERT_NOT_REACHED();
-        return;
-    }
     if (!IsFloatFormat<DstFormat>::Value && IsFloatFormat<SrcFormat>::Value) {
         ASSERT_NOT_REACHED();
         return;