diff options
author | Mike Reed <reed@google.com> | 2009-04-28 16:37:06 -0400 |
---|---|---|
committer | Mike Reed <reed@google.com> | 2009-04-28 16:51:54 -0400 |
commit | 8ee0eadb00b2146116f05e730a8a5bd025f9b2af (patch) | |
tree | 9bdcc24d5a3ac0054e133fe45f9d4ea47d8283d6 | |
parent | 0296aca4034b6c5c6509ad09d0144405f44c4ba1 (diff) | |
download | external_webkit-8ee0eadb00b2146116f05e730a8a5bd025f9b2af.zip external_webkit-8ee0eadb00b2146116f05e730a8a5bd025f9b2af.tar.gz external_webkit-8ee0eadb00b2146116f05e730a8a5bd025f9b2af.tar.bz2 |
First cut at sharing graphics code with chrome
Introduce (short lived I hope) platform SKIA_SGL, signifying that this code
is used by both platforms (SKIA) and (SGL). This change is meant to be the
foundation for more significant sharing later (e.g. TransformationMatrix,
Pattern, Gradient, etc.)
-rw-r--r-- | JavaScriptCore/wtf/Platform.h | 1 | ||||
-rw-r--r-- | WebCore/Android.mk | 11 | ||||
-rw-r--r-- | WebCore/platform/graphics/FloatPoint.h | 4 | ||||
-rw-r--r-- | WebCore/platform/graphics/FloatRect.h | 4 | ||||
-rw-r--r-- | WebCore/platform/graphics/IntPoint.h | 4 | ||||
-rw-r--r-- | WebCore/platform/graphics/IntRect.h | 4 | ||||
-rw-r--r-- | WebCore/platform/graphics/android/TransformationMatrixAndroid.cpp | 56 | ||||
-rw-r--r-- | WebCore/platform/graphics/skia/SkiaUtils.cpp | 5 |
8 files changed, 22 insertions, 67 deletions
diff --git a/JavaScriptCore/wtf/Platform.h b/JavaScriptCore/wtf/Platform.h index 9ab0af8..b163b8f 100644 --- a/JavaScriptCore/wtf/Platform.h +++ b/JavaScriptCore/wtf/Platform.h @@ -181,6 +181,7 @@ #define WTF_USE_PTHREADS 1 #define WTF_PLATFORM_SGL 1 +#define WTF_PLATFORM_SKIA_SGL 1 #define WTF_PLATFORM_UNIX 1 #define USE_SYSTEM_MALLOC 1 diff --git a/WebCore/Android.mk b/WebCore/Android.mk index b5362bc..c94befc 100644 --- a/WebCore/Android.mk +++ b/WebCore/Android.mk @@ -704,10 +704,15 @@ LOCAL_SRC_FILES := $(LOCAL_SRC_FILES) \ platform/graphics/android/PatternAndroid.cpp \ platform/graphics/android/PlatformGraphicsContext.cpp \ platform/graphics/android/SharedBufferStream.cpp \ - platform/graphics/android/TransformationMatrixAndroid.cpp \ platform/graphics/android/android_graphics.cpp \ \ + platform/graphics/skia/FloatPointSkia.cpp \ + platform/graphics/skia/FloatRectSkia.cpp \ + platform/graphics/skia/IntPointSkia.cpp \ + platform/graphics/skia/IntRectSkia.cpp \ platform/graphics/skia/NativeImageSkia.cpp \ + platform/graphics/skia/SkiaUtils.cpp \ + platform/graphics/skia/TransformationMatrixSkia.cpp \ \ platform/graphics/transforms/Matrix3DTransformOperation.cpp \ platform/graphics/transforms/MatrixTransformOperation.cpp \ @@ -719,8 +724,8 @@ LOCAL_SRC_FILES := $(LOCAL_SRC_FILES) \ platform/graphics/transforms/TransformationMatrix.cpp \ platform/graphics/transforms/TranslateTransformOperation.cpp \ \ - platform/image-decoders/skia/GIFImageDecoder.cpp \ - platform/image-decoders/skia/GIFImageReader.cpp \ + platform/image-decoders/skia/GIFImageDecoder.cpp \ + platform/image-decoders/skia/GIFImageReader.cpp \ \ platform/network/AuthenticationChallengeBase.cpp \ platform/network/Credential.cpp \ diff --git a/WebCore/platform/graphics/FloatPoint.h b/WebCore/platform/graphics/FloatPoint.h index 35b3036..49264d3 100644 --- a/WebCore/platform/graphics/FloatPoint.h +++ b/WebCore/platform/graphics/FloatPoint.h @@ -55,7 +55,7 @@ QT_END_NAMESPACE class TPoint; #endif -#if PLATFORM(SKIA) +#if PLATFORM(SKIA_SGL) struct SkPoint; #endif @@ -99,7 +99,7 @@ public: FloatPoint(const TPoint&); #endif -#if PLATFORM(SKIA) +#if PLATFORM(SKIA_SGL) operator SkPoint() const; FloatPoint(const SkPoint&); #endif diff --git a/WebCore/platform/graphics/FloatRect.h b/WebCore/platform/graphics/FloatRect.h index a87c949..3d225a3 100644 --- a/WebCore/platform/graphics/FloatRect.h +++ b/WebCore/platform/graphics/FloatRect.h @@ -51,7 +51,7 @@ QT_END_NAMESPACE class wxRect2DDouble; #endif -#if PLATFORM(SKIA) +#if PLATFORM(SKIA_SGL) struct SkRect; #endif @@ -143,7 +143,7 @@ public: operator wxRect2DDouble() const; #endif -#if PLATFORM(SKIA) +#if PLATFORM(SKIA_SGL) FloatRect(const SkRect&); operator SkRect() const; #endif diff --git a/WebCore/platform/graphics/IntPoint.h b/WebCore/platform/graphics/IntPoint.h index cb24b4e..779bf34 100644 --- a/WebCore/platform/graphics/IntPoint.h +++ b/WebCore/platform/graphics/IntPoint.h @@ -59,7 +59,7 @@ class TPoint; class wxPoint; #endif -#if PLATFORM(SKIA) +#if PLATFORM(SKIA_SGL) struct SkPoint; struct SkIPoint; #endif @@ -128,7 +128,7 @@ public: operator wxPoint() const; #endif -#if PLATFORM(SKIA) +#if PLATFORM(SKIA_SGL) IntPoint(const SkIPoint&); operator SkIPoint() const; operator SkPoint() const; diff --git a/WebCore/platform/graphics/IntRect.h b/WebCore/platform/graphics/IntRect.h index 03784a3..90864b0 100644 --- a/WebCore/platform/graphics/IntRect.h +++ b/WebCore/platform/graphics/IntRect.h @@ -58,7 +58,7 @@ class TRect; class wxRect; #endif -#if PLATFORM(SKIA) +#if PLATFORM(SKIA_SGL) struct SkRect; struct SkIRect; #endif @@ -158,7 +158,7 @@ public: operator CGRect() const; #endif -#if PLATFORM(SKIA) +#if PLATFORM(SKIA_SGL) IntRect(const SkIRect&); operator SkRect() const; operator SkIRect() const; diff --git a/WebCore/platform/graphics/android/TransformationMatrixAndroid.cpp b/WebCore/platform/graphics/android/TransformationMatrixAndroid.cpp deleted file mode 100644 index a57abc0..0000000 --- a/WebCore/platform/graphics/android/TransformationMatrixAndroid.cpp +++ /dev/null @@ -1,56 +0,0 @@ -// Copyright (c) 2008, 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: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * 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. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT -// OWNER OR 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 "TransformationMatrix.h" - -#include "SkiaUtils.h" - -namespace WebCore { - -TransformationMatrix::operator SkMatrix() const -{ - SkMatrix result; - - result.setScaleX(WebCoreDoubleToSkScalar(a())); - result.setSkewX(WebCoreDoubleToSkScalar(c())); - result.setTranslateX(WebCoreDoubleToSkScalar(e())); - - result.setScaleY(WebCoreDoubleToSkScalar(d())); - result.setSkewY(WebCoreDoubleToSkScalar(b())); - result.setTranslateY(WebCoreDoubleToSkScalar(f())); - - // FIXME: Set perspective properly. - result.setPerspX(0); - result.setPerspY(0); - result.set(SkMatrix::kMPersp2, SK_Scalar1); - return result; -} - -} // namespace WebCore diff --git a/WebCore/platform/graphics/skia/SkiaUtils.cpp b/WebCore/platform/graphics/skia/SkiaUtils.cpp index 6d9ffe2..af168a2 100644 --- a/WebCore/platform/graphics/skia/SkiaUtils.cpp +++ b/WebCore/platform/graphics/skia/SkiaUtils.cpp @@ -151,7 +151,12 @@ bool SkPathContainsPoint(SkPath* originalPath, const FloatPoint& point, SkPath:: int scale = 1; SkRect bounds; +#if PLATFORM(SGL) + // this is the API from skia/trunk + bounds = originalPath->getBounds(); +#else originalPath->computeBounds(&bounds, SkPath::kFast_BoundsType); +#endif // We can immediately return false if the point is outside the bounding rect if (!bounds.contains(SkFloatToScalar(point.x()), SkFloatToScalar(point.y()))) |