[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-9427-gc2be6fc

kbr at google.com kbr at google.com
Wed Dec 22 13:14:50 UTC 2010


The following commit has been merged in the debian/experimental branch:
commit ce2bab63911433e441b420e24d7c6f2ba991d0ae
Author: kbr at google.com <kbr at google.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Thu Sep 9 19:42:24 2010 +0000

    2010-09-09  Kenneth Russell  <kbr at google.com>
    
            Reviewed by James Robinson.
    
            Add cubic texture coordinate computation
            https://bugs.webkit.org/show_bug.cgi?id=45250
    
            Adding the texture coordinate computation for cubic curves per the
            GPU Gems 3 chapter. No tests yet; will be tested in conjunction
            with later code.
    
            * platform/graphics/gpu/LoopBlinnConstants.h: Added.
            * platform/graphics/gpu/LoopBlinnTextureCoords.cpp: Added.
            (WebCore::LoopBlinnTextureCoords::compute):
            * platform/graphics/gpu/LoopBlinnTextureCoords.h: Added.
            (WebCore::LoopBlinnTextureCoords::Result::Result):
            (WebCore::LoopBlinnTextureCoords::LoopBlinnTextureCoords):
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@67104 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index 47b8a63..a5c86b2 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -2,6 +2,24 @@
 
         Reviewed by James Robinson.
 
+        Add cubic texture coordinate computation
+        https://bugs.webkit.org/show_bug.cgi?id=45250
+
+        Adding the texture coordinate computation for cubic curves per the
+        GPU Gems 3 chapter. No tests yet; will be tested in conjunction
+        with later code.
+
+        * platform/graphics/gpu/LoopBlinnConstants.h: Added.
+        * platform/graphics/gpu/LoopBlinnTextureCoords.cpp: Added.
+        (WebCore::LoopBlinnTextureCoords::compute):
+        * platform/graphics/gpu/LoopBlinnTextureCoords.h: Added.
+        (WebCore::LoopBlinnTextureCoords::Result::Result):
+        (WebCore::LoopBlinnTextureCoords::LoopBlinnTextureCoords):
+
+2010-09-09  Kenneth Russell  <kbr at google.com>
+
+        Reviewed by James Robinson.
+
         Add cubic curve classifier
         https://bugs.webkit.org/show_bug.cgi?id=45249
 
diff --git a/WebCore/platform/graphics/gpu/LoopBlinnConstants.h b/WebCore/platform/graphics/gpu/LoopBlinnConstants.h
new file mode 100644
index 0000000..1997d9f
--- /dev/null
+++ b/WebCore/platform/graphics/gpu/LoopBlinnConstants.h
@@ -0,0 +1,40 @@
+/*
+ * Copyright (C) 2010 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1.  Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer.
+ * 2.  Redistributions in binary form must reproduce the above copyright
+ *     notice, this list of conditions and the following disclaimer in the
+ *     documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef LoopBlinnConstants_h
+#define LoopBlinnConstants_h
+
+namespace WebCore {
+namespace LoopBlinnConstants {
+
+enum FillSide {
+    LeftSide,
+    RightSide
+};
+
+} // namespace LoopBlinnConstants
+} // namespace WebCore
+
+#endif // LoopBlinnConstants_h
diff --git a/WebCore/platform/graphics/gpu/LoopBlinnTextureCoords.cpp b/WebCore/platform/graphics/gpu/LoopBlinnTextureCoords.cpp
new file mode 100644
index 0000000..ac82637
--- /dev/null
+++ b/WebCore/platform/graphics/gpu/LoopBlinnTextureCoords.cpp
@@ -0,0 +1,171 @@
+/*
+ * Copyright (C) 2010 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1.  Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer.
+ * 2.  Redistributions in binary form must reproduce the above copyright
+ *     notice, this list of conditions and the following disclaimer in the
+ *     documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+
+#include "LoopBlinnTextureCoords.h"
+
+#include <math.h>
+#include <wtf/Assertions.h>
+
+namespace WebCore {
+
+LoopBlinnTextureCoords::Result LoopBlinnTextureCoords::compute(const LoopBlinnClassifier::Result& classification, LoopBlinnConstants::FillSide sideToFill)
+{
+    // Loop and Blinn's formulation states that the right side of the
+    // curve is defined to be the inside (filled region), but for some
+    // reason it looks like with the default orientation parameters we
+    // are filling the left side of the curve. Regardless, because we
+    // can receive arbitrarily oriented curves as input, we might have
+    // to reverse the orientation of the cubic texture coordinates even
+    // in cases where the paper doesn't say it is necessary.
+    bool reverseOrientation = false;
+    static const float OneThird = 1.0f / 3.0f;
+    static const float TwoThirds = 2.0f / 3.0f;
+    LoopBlinnClassifier::CurveType curveType = classification.curveType;
+
+    LoopBlinnTextureCoords::Result result;
+
+    switch (curveType) {
+    case LoopBlinnClassifier::kSerpentine: {
+        float t1 = sqrtf(9.0f * classification.d2 * classification.d2 - 12 * classification.d1 * classification.d3);
+        float ls = 3.0f * classification.d2 - t1;
+        float lt = 6.0f * classification.d1;
+        float ms = 3.0f * classification.d2 + t1;
+        float mt = lt;
+        float ltMinusLs = lt - ls;
+        float mtMinusMs = mt - ms;
+        result.klmCoordinates[0] = FloatPoint3D(ls * ms,
+                                                ls * ls * ls,
+                                                ms * ms * ms);
+        result.klmCoordinates[1] = FloatPoint3D(OneThird * (3.0f * ls * ms - ls * mt - lt * ms),
+                                                ls * ls * (ls - lt),
+                                                ms * ms * (ms - mt));
+        result.klmCoordinates[2] = FloatPoint3D(OneThird * (lt * (mt - 2.0f * ms) + ls * (3.0f * ms - 2.0f * mt)),
+                                                ltMinusLs * ltMinusLs * ls,
+                                                mtMinusMs * mtMinusMs * ms);
+        result.klmCoordinates[3] = FloatPoint3D(ltMinusLs * mtMinusMs,
+                                                -(ltMinusLs * ltMinusLs * ltMinusLs),
+                                                -(mtMinusMs * mtMinusMs * mtMinusMs));
+        if (classification.d1 < 0.0f)
+            reverseOrientation = true;
+        break;
+    }
+
+    case LoopBlinnClassifier::kLoop: {
+        float t1 = sqrtf(4.0f * classification.d1 * classification.d3 - 3.0f * classification.d2 * classification.d2);
+        float ls = classification.d2 - t1;
+        float lt = 2.0f * classification.d1;
+        float ms = classification.d2 + t1;
+        float mt = lt;
+
+        // Figure out whether there is a rendering artifact requiring
+        // the curve to be subdivided by the caller.
+        float ql = ls / lt;
+        float qm = ms / mt;
+        if (0.0f < ql && ql < 1.0f) {
+            result.hasRenderingArtifact = true;
+            result.subdivisionParameterValue = ql;
+            return result;
+        }
+
+        if (0.0f < qm && qm < 1.0f) {
+            result.hasRenderingArtifact = true;
+            result.subdivisionParameterValue = qm;
+            return result;
+        }
+
+        float ltMinusLs = lt - ls;
+        float mtMinusMs = mt - ms;
+        result.klmCoordinates[0] = FloatPoint3D(ls * ms,
+                                                ls * ls * ms,
+                                                ls * ms * ms);
+        result.klmCoordinates[1] = FloatPoint3D(OneThird * (-ls * mt - lt * ms + 3.0f * ls * ms),
+                                                -OneThird * ls * (ls * (mt - 3.0f * ms) + 2.0f * lt * ms),
+                                                -OneThird * ms * (ls * (2.0f * mt - 3.0f * ms) + lt * ms));
+        result.klmCoordinates[2] = FloatPoint3D(OneThird * (lt * (mt - 2.0f * ms) + ls * (3.0f * ms - 2.0f * mt)),
+                                                OneThird * (lt - ls) * (ls * (2.0f * mt - 3.0f * ms) + lt * ms),
+                                                OneThird * (mt - ms) * (ls * (mt - 3.0f * ms) + 2.0f * lt * ms));
+        result.klmCoordinates[3] = FloatPoint3D(ltMinusLs * mtMinusMs,
+                                                -(ltMinusLs * ltMinusLs) * mtMinusMs,
+                                                -ltMinusLs * mtMinusMs * mtMinusMs);
+        reverseOrientation = ((classification.d1 > 0.0f && result.klmCoordinates[0].x() < 0.0f)
+                           || (classification.d1 < 0.0f && result.klmCoordinates[0].x() > 0.0f));
+        break;
+    }
+
+    case LoopBlinnClassifier::kCusp: {
+        float ls = classification.d3;
+        float lt = 3.0f * classification.d2;
+        float lsMinusLt = ls - lt;
+        result.klmCoordinates[0] = FloatPoint3D(ls,
+                                                ls * ls * ls,
+                                                1.0f);
+        result.klmCoordinates[1] = FloatPoint3D(ls - OneThird * lt,
+                                                ls * ls * lsMinusLt,
+                                                1.0f);
+        result.klmCoordinates[2] = FloatPoint3D(ls - TwoThirds * lt,
+                                                lsMinusLt * lsMinusLt * ls,
+                                                1.0f);
+        result.klmCoordinates[3] = FloatPoint3D(lsMinusLt,
+                                                lsMinusLt * lsMinusLt * lsMinusLt,
+                                                1.0f);
+        break;
+    }
+
+    case LoopBlinnClassifier::kQuadratic: {
+        result.klmCoordinates[0] = FloatPoint3D(0, 0, 0);
+        result.klmCoordinates[1] = FloatPoint3D(OneThird, 0, OneThird);
+        result.klmCoordinates[2] = FloatPoint3D(TwoThirds, OneThird, TwoThirds);
+        result.klmCoordinates[3] = FloatPoint3D(1, 1, 1);
+        if (classification.d3 < 0)
+            reverseOrientation = true;
+        break;
+    }
+
+    case LoopBlinnClassifier::kLine:
+    case LoopBlinnClassifier::kPoint:
+        result.isLineOrPoint = true;
+        break;
+
+    default:
+        ASSERT_NOT_REACHED();
+        break;
+    }
+
+    if (sideToFill == LoopBlinnConstants::RightSide)
+        reverseOrientation = !reverseOrientation;
+
+    if (reverseOrientation) {
+        for (int i = 0; i < 4; ++i) {
+            result.klmCoordinates[i].setX(-result.klmCoordinates[i].x());
+            result.klmCoordinates[i].setY(-result.klmCoordinates[i].y());
+        }
+    }
+
+    return result;
+}
+
+} // namespace WebCore
diff --git a/WebCore/platform/graphics/gpu/LoopBlinnTextureCoords.h b/WebCore/platform/graphics/gpu/LoopBlinnTextureCoords.h
new file mode 100644
index 0000000..5fdeb3b
--- /dev/null
+++ b/WebCore/platform/graphics/gpu/LoopBlinnTextureCoords.h
@@ -0,0 +1,82 @@
+/*
+ * Copyright (C) 2010 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1.  Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer.
+ * 2.  Redistributions in binary form must reproduce the above copyright
+ *     notice, this list of conditions and the following disclaimer in the
+ *     documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef LoopBlinnTextureCoords_h
+#define LoopBlinnTextureCoords_h
+
+#include "FloatPoint3D.h"
+#include "LoopBlinnClassifier.h"
+#include "LoopBlinnConstants.h"
+
+#include <wtf/Noncopyable.h>
+
+namespace WebCore {
+
+// Computes three-dimensional texture coordinates for the control
+// points of a cubic curve for rendering via the shader in "Rendering
+// Vector Art on the GPU" by Loop and Blinn, GPU Gems 3, Chapter 25.
+class LoopBlinnTextureCoords {
+public:
+    // Container for the cubic texture coordinates and other associated
+    // information.
+    struct Result {
+        Result()
+            : isLineOrPoint(false)
+            , hasRenderingArtifact(false)
+            , subdivisionParameterValue(0.0f) { }
+
+        // The (k, l, m) texture coordinates that are to be associated
+        // with the four control points of the cubic curve.
+        FloatPoint3D klmCoordinates[4];
+
+        // Indicates whether the curve is a line or a point, in which case
+        // we do not need to add its triangles to the mesh.
+        bool isLineOrPoint;
+
+        // For the loop case, indicates whether a rendering artifact was
+        // detected, in which case the curve needs to be further
+        // subdivided.
+        bool hasRenderingArtifact;
+
+        // If a rendering artifact will occur for the given loop curve,
+        // this is the parameter value (0 <= value <= 1) at which the
+        // curve needs to be subdivided to fix the artifact.
+        float subdivisionParameterValue;
+    };
+
+    // Computes the texture coordinates for a cubic curve segment's
+    // control points, given the classification of the curve as well as
+    // an indication of which side is to be filled.
+    static Result compute(const LoopBlinnClassifier::Result& classification,
+                          LoopBlinnConstants::FillSide sideToFill);
+
+private:
+    // This class does not need to be instantiated.
+    LoopBlinnTextureCoords() { }
+};
+
+} // namespace WebCore
+
+#endif // LoopBlinnTextureCoords_h

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list