diff options
| author | Ben Murdoch <benm@google.com> | 2011-05-16 16:25:10 +0100 |
|---|---|---|
| committer | Ben Murdoch <benm@google.com> | 2011-05-23 18:54:14 +0100 |
| commit | ab9e7a118cf1ea2e3a93dce683b2ded3e7291ddb (patch) | |
| tree | db769fadd053248f85db67434a5b275224defef7 /Source/WebCore/platform/graphics | |
| parent | 52e2557aeb8477967e97fd24f20f8f407a10fa15 (diff) | |
| download | external_webkit-ab9e7a118cf1ea2e3a93dce683b2ded3e7291ddb.zip external_webkit-ab9e7a118cf1ea2e3a93dce683b2ded3e7291ddb.tar.gz external_webkit-ab9e7a118cf1ea2e3a93dce683b2ded3e7291ddb.tar.bz2 | |
Merge WebKit at r76408: Initial merge by git.
Change-Id: I5b91decbd693ccbf5c1b8354b37cd68cc9a1ea53
Diffstat (limited to 'Source/WebCore/platform/graphics')
132 files changed, 1492 insertions, 610 deletions
diff --git a/Source/WebCore/platform/graphics/ANGLEWebKitBridge.cpp b/Source/WebCore/platform/graphics/ANGLEWebKitBridge.cpp index 64f19c4..f416b47 100644 --- a/Source/WebCore/platform/graphics/ANGLEWebKitBridge.cpp +++ b/Source/WebCore/platform/graphics/ANGLEWebKitBridge.cpp @@ -28,29 +28,53 @@ #if ENABLE(3D_CANVAS) #include "ANGLEWebKitBridge.h" +#include <wtf/OwnArrayPtr.h> namespace WebCore { ANGLEWebKitBridge::ANGLEWebKitBridge() : - builtCompilers(false) + builtCompilers(false), + m_fragmentCompiler(0), + m_vertexCompiler(0) { ShInitialize(); } ANGLEWebKitBridge::~ANGLEWebKitBridge() { - if (builtCompilers) { + cleanupCompilers(); +} + +void ANGLEWebKitBridge::cleanupCompilers() +{ + if (m_fragmentCompiler) ShDestruct(m_fragmentCompiler); + m_fragmentCompiler = 0; + if (m_vertexCompiler) ShDestruct(m_vertexCompiler); - } + m_vertexCompiler = 0; + + builtCompilers = false; +} + +void ANGLEWebKitBridge::setResources(ShBuiltInResources resources) +{ + // Resources are (possibly) changing - cleanup compilers if we had them already + cleanupCompilers(); + + m_resources = resources; } bool ANGLEWebKitBridge::validateShaderSource(const char* shaderSource, ANGLEShaderType shaderType, String& translatedShaderSource, String& shaderValidationLog) { if (!builtCompilers) { - m_fragmentCompiler = ShConstructCompiler(EShLangFragment, EShSpecWebGL, &m_resources); - m_vertexCompiler = ShConstructCompiler(EShLangVertex, EShSpecWebGL, &m_resources); + m_fragmentCompiler = ShConstructCompiler(SH_FRAGMENT_SHADER, SH_WEBGL_SPEC, &m_resources); + m_vertexCompiler = ShConstructCompiler(SH_VERTEX_SHADER, SH_WEBGL_SPEC, &m_resources); + if (!m_fragmentCompiler || !m_vertexCompiler) { + cleanupCompilers(); + return false; + } builtCompilers = true; } @@ -64,12 +88,31 @@ bool ANGLEWebKitBridge::validateShaderSource(const char* shaderSource, ANGLEShad const char* const shaderSourceStrings[] = { shaderSource }; - bool validateSuccess = ShCompile(compiler, shaderSourceStrings, 1, EShOptNone, EDebugOpIntermediate); + bool validateSuccess = ShCompile(compiler, shaderSourceStrings, 1, SH_OBJECT_CODE); + if (!validateSuccess) { + int logSize = 0; + ShGetInfo(compiler, SH_INFO_LOG_LENGTH, &logSize); + if (logSize > 1) { + OwnArrayPtr<char> logBuffer(new char[logSize]); + if (logBuffer) { + ShGetInfoLog(compiler, logBuffer.get()); + shaderValidationLog = logBuffer.get(); + } + } + return false; + } - translatedShaderSource = ShGetObjectCode(compiler); - shaderValidationLog = ShGetInfoLog(compiler); + int translationLength = 0; + ShGetInfo(compiler, SH_OBJECT_CODE_LENGTH, &translationLength); + if (translationLength > 1) { + OwnArrayPtr<char> translationBuffer(new char[translationLength]); + if (!translationBuffer) + return false; + ShGetObjectCode(compiler, translationBuffer.get()); + translatedShaderSource = translationBuffer.get(); + } - return validateSuccess; + return true; } } diff --git a/Source/WebCore/platform/graphics/ANGLEWebKitBridge.h b/Source/WebCore/platform/graphics/ANGLEWebKitBridge.h index d01de8f..7bddbf4 100644 --- a/Source/WebCore/platform/graphics/ANGLEWebKitBridge.h +++ b/Source/WebCore/platform/graphics/ANGLEWebKitBridge.h @@ -34,8 +34,8 @@ namespace WebCore { enum ANGLEShaderType { - SHADER_TYPE_VERTEX = EShLangVertex, - SHADER_TYPE_FRAGMENT = EShLangFragment + SHADER_TYPE_VERTEX = SH_VERTEX_SHADER, + SHADER_TYPE_FRAGMENT = SH_FRAGMENT_SHADER, }; class ANGLEWebKitBridge { @@ -44,18 +44,21 @@ public: ANGLEWebKitBridge(); ~ANGLEWebKitBridge(); - void setResources(TBuiltInResource resources) { m_resources = resources; } + ShBuiltInResources getResources() { return m_resources; } + void setResources(ShBuiltInResources); bool validateShaderSource(const char* shaderSource, ANGLEShaderType shaderType, String& translatedShaderSource, String& shaderValidationLog); private: - ShHandle m_fragmentCompiler; - ShHandle m_vertexCompiler; + void cleanupCompilers(); bool builtCompilers; + + ShHandle m_fragmentCompiler; + ShHandle m_vertexCompiler; - TBuiltInResource m_resources; + ShBuiltInResources m_resources; }; } // namespace WebCore diff --git a/Source/WebCore/platform/graphics/BitmapImage.h b/Source/WebCore/platform/graphics/BitmapImage.h index 72f3092..93fc464 100644 --- a/Source/WebCore/platform/graphics/BitmapImage.h +++ b/Source/WebCore/platform/graphics/BitmapImage.h @@ -68,7 +68,9 @@ template <typename T> class Timer; // FrameData Class // ================================================ -struct FrameData : Noncopyable { +struct FrameData { + WTF_MAKE_NONCOPYABLE(FrameData); +public: FrameData() : m_frame(0) , m_haveMetadata(false) diff --git a/Source/WebCore/platform/graphics/Color.h b/Source/WebCore/platform/graphics/Color.h index fa37d32..2a03238 100644 --- a/Source/WebCore/platform/graphics/Color.h +++ b/Source/WebCore/platform/graphics/Color.h @@ -78,7 +78,8 @@ inline int greenChannel(RGBA32 color) { return (color >> 8) & 0xFF; } inline int blueChannel(RGBA32 color) { return color & 0xFF; } inline int alphaChannel(RGBA32 color) { return (color >> 24) & 0xFF; } -class Color : public FastAllocBase { +class Color { + WTF_MAKE_FAST_ALLOCATED; public: Color() : m_color(0), m_valid(false) { } Color(RGBA32 col) : m_color(col), m_valid(true) { } diff --git a/Source/WebCore/platform/graphics/Extensions3D.h b/Source/WebCore/platform/graphics/Extensions3D.h index 0363a48..1a2b7a1 100644 --- a/Source/WebCore/platform/graphics/Extensions3D.h +++ b/Source/WebCore/platform/graphics/Extensions3D.h @@ -51,6 +51,7 @@ public: // GL_EXT_packed_depth_stencil / GL_OES_packed_depth_stencil // GL_ANGLE_framebuffer_blit / GL_ANGLE_framebuffer_multisample // GL_OES_texture_float + // GL_OES_standard_derivatives // Takes full name of extension; for example, // "GL_EXT_texture_format_BGRA8888". @@ -82,7 +83,10 @@ public: // GL_ANGLE_framebuffer_multisample names RENDERBUFFER_SAMPLES = 0x8CAB, FRAMEBUFFER_INCOMPLETE_MULTISAMPLE = 0x8D56, - MAX_SAMPLES = 0x8D57 + MAX_SAMPLES = 0x8D57, + + // GL_OES_standard_derivatives names + FRAGMENT_SHADER_DERIVATIVE_HINT_OES = 0x8B8B, }; // GL_ARB_robustness diff --git a/Source/WebCore/platform/graphics/FloatPoint.cpp b/Source/WebCore/platform/graphics/FloatPoint.cpp index 7e85b52..226ae71 100644 --- a/Source/WebCore/platform/graphics/FloatPoint.cpp +++ b/Source/WebCore/platform/graphics/FloatPoint.cpp @@ -27,6 +27,7 @@ #include "config.h" #include "FloatPoint.h" +#include "AffineTransform.h" #include "TransformationMatrix.h" #include "FloatConversion.h" #include "IntPoint.h" diff --git a/Source/WebCore/platform/graphics/Font.cpp b/Source/WebCore/platform/graphics/Font.cpp index 887e21d..394de35 100644 --- a/Source/WebCore/platform/graphics/Font.cpp +++ b/Source/WebCore/platform/graphics/Font.cpp @@ -29,6 +29,7 @@ #include "FontTranscoder.h" #include "IntPoint.h" #include "GlyphBuffer.h" +#include "TextRun.h" #include "WidthIterator.h" #include <wtf/MathExtras.h> #include <wtf/UnusedParam.h> diff --git a/Source/WebCore/platform/graphics/Font.h b/Source/WebCore/platform/graphics/Font.h index 40a8828..2957c0a 100644 --- a/Source/WebCore/platform/graphics/Font.h +++ b/Source/WebCore/platform/graphics/Font.h @@ -29,7 +29,6 @@ #include "FontDescription.h" #include "FontFallbackList.h" #include "SimpleFontData.h" -#include "TextRun.h" #include "TypesettingFeatures.h" #include <wtf/HashMap.h> #include <wtf/HashSet.h> @@ -51,6 +50,7 @@ class GlyphBuffer; class GlyphPageTreeNode; class GraphicsContext; class SVGFontElement; +class TextRun; struct GlyphData; diff --git a/Source/WebCore/platform/graphics/FontCache.cpp b/Source/WebCore/platform/graphics/FontCache.cpp index 149ea79..cfca980 100644 --- a/Source/WebCore/platform/graphics/FontCache.cpp +++ b/Source/WebCore/platform/graphics/FontCache.cpp @@ -53,7 +53,9 @@ FontCache::FontCache() { } -struct FontPlatformDataCacheKey : FastAllocBase { +struct FontPlatformDataCacheKey { + WTF_MAKE_FAST_ALLOCATED; +public: FontPlatformDataCacheKey(const AtomicString& family = AtomicString(), unsigned size = 0, unsigned weight = 0, bool italic = false, bool isPrinterFont = false, FontRenderingMode renderingMode = NormalRenderingMode, FontOrientation orientation = Horizontal) : m_size(size) diff --git a/Source/WebCore/platform/graphics/FontCache.h b/Source/WebCore/platform/graphics/FontCache.h index e6845d9..86f8c67 100644 --- a/Source/WebCore/platform/graphics/FontCache.h +++ b/Source/WebCore/platform/graphics/FontCache.h @@ -50,7 +50,8 @@ class FontDescription; class FontSelector; class SimpleFontData; -class FontCache : public Noncopyable { +class FontCache { + WTF_MAKE_NONCOPYABLE(FontCache); WTF_MAKE_FAST_ALLOCATED; public: friend FontCache* fontCache(); diff --git a/Source/WebCore/platform/graphics/FontData.h b/Source/WebCore/platform/graphics/FontData.h index ee94a98..3d35d2a 100644 --- a/Source/WebCore/platform/graphics/FontData.h +++ b/Source/WebCore/platform/graphics/FontData.h @@ -26,6 +26,7 @@ #ifndef FontData_h #define FontData_h +#include <wtf/FastAllocBase.h> #include <wtf/Forward.h> #include <wtf/Noncopyable.h> #include <wtf/unicode/Unicode.h> @@ -34,7 +35,8 @@ namespace WebCore { class SimpleFontData; -class FontData : public Noncopyable { +class FontData { + WTF_MAKE_NONCOPYABLE(FontData); WTF_MAKE_FAST_ALLOCATED; public: FontData() : m_maxGlyphPageTreeLevel(0) diff --git a/Source/WebCore/platform/graphics/FontFastPath.cpp b/Source/WebCore/platform/graphics/FontFastPath.cpp index 367c8a2..f927c13 100644 --- a/Source/WebCore/platform/graphics/FontFastPath.cpp +++ b/Source/WebCore/platform/graphics/FontFastPath.cpp @@ -30,6 +30,7 @@ #include "GlyphBuffer.h" #include "GlyphPageTreeNode.h" #include "SimpleFontData.h" +#include "TextRun.h" #include "WidthIterator.h" #include <wtf/MathExtras.h> diff --git a/Source/WebCore/platform/graphics/GlyphMetricsMap.h b/Source/WebCore/platform/graphics/GlyphMetricsMap.h index fa85bcc..3e13fbb 100644 --- a/Source/WebCore/platform/graphics/GlyphMetricsMap.h +++ b/Source/WebCore/platform/graphics/GlyphMetricsMap.h @@ -40,7 +40,8 @@ typedef unsigned short Glyph; const float cGlyphSizeUnknown = -1; -template<class T> class GlyphMetricsMap : public Noncopyable { +template<class T> class GlyphMetricsMap { + WTF_MAKE_NONCOPYABLE(GlyphMetricsMap); public: GlyphMetricsMap() : m_filledPrimaryPage(false) { } ~GlyphMetricsMap() diff --git a/Source/WebCore/platform/graphics/GraphicsContext.cpp b/Source/WebCore/platform/graphics/GraphicsContext.cpp index c9c1f63..9f94ac9 100644 --- a/Source/WebCore/platform/graphics/GraphicsContext.cpp +++ b/Source/WebCore/platform/graphics/GraphicsContext.cpp @@ -31,6 +31,8 @@ #include "Generator.h" #include "ImageBuffer.h" #include "IntRect.h" +#include "RoundedIntRect.h" +#include "TextRun.h" using namespace std; @@ -536,25 +538,23 @@ void GraphicsContext::drawImageBuffer(ImageBuffer* image, ColorSpace styleColorS image->draw(this, styleColorSpace, dest, src, op, useLowQualityScale); } -void GraphicsContext::addRoundedRectClip(const IntRect& rect, const IntSize& topLeft, const IntSize& topRight, - const IntSize& bottomLeft, const IntSize& bottomRight) +void GraphicsContext::addRoundedRectClip(const RoundedIntRect& rect) { if (paintingDisabled()) return; Path path; - path.addRoundedRect(rect, topLeft, topRight, bottomLeft, bottomRight); + path.addRoundedRect(rect.rect(), rect.radii().topLeft(), rect.radii().topRight(), rect.radii().bottomLeft(), rect.radii().bottomRight()); clip(path); } -void GraphicsContext::clipOutRoundedRect(const IntRect& rect, const IntSize& topLeft, const IntSize& topRight, - const IntSize& bottomLeft, const IntSize& bottomRight) +void GraphicsContext::clipOutRoundedRect(const RoundedIntRect& rect) { if (paintingDisabled()) return; Path path; - path.addRoundedRect(rect, topLeft, topRight, bottomLeft, bottomRight); + path.addRoundedRect(rect.rect(), rect.radii().topLeft(), rect.radii().topRight(), rect.radii().bottomLeft(), rect.radii().bottomRight()); clipOut(path); } @@ -585,6 +585,11 @@ void GraphicsContext::fillRect(const FloatRect& rect, Generator& generator) generator.fill(this, rect); } +void GraphicsContext::fillRoundedRect(const RoundedIntRect& rect, const Color& color, ColorSpace colorSpace) +{ + fillRoundedRect(rect.rect(), rect.radii().topLeft(), rect.radii().topRight(), rect.radii().bottomLeft(), rect.radii().bottomRight(), color, colorSpace); +} + void GraphicsContext::setCompositeOperation(CompositeOperator compositeOperation) { m_state.compositeOperator = compositeOperation; diff --git a/Source/WebCore/platform/graphics/GraphicsContext.h b/Source/WebCore/platform/graphics/GraphicsContext.h index a648680..77321e2 100644 --- a/Source/WebCore/platform/graphics/GraphicsContext.h +++ b/Source/WebCore/platform/graphics/GraphicsContext.h @@ -128,6 +128,7 @@ namespace WebCore { class GraphicsContextPlatformPrivate; class ImageBuffer; class IntRect; + class RoundedIntRect; class KURL; class SharedGraphicsContext3D; class TextRun; @@ -213,7 +214,8 @@ namespace WebCore { bool shadowsIgnoreTransforms : 1; }; - class GraphicsContext : public Noncopyable { + class GraphicsContext { + WTF_MAKE_NONCOPYABLE(GraphicsContext); WTF_MAKE_FAST_ALLOCATED; public: GraphicsContext(PlatformGraphicsContext*); ~GraphicsContext(); @@ -317,6 +319,7 @@ namespace WebCore { void fillRect(const FloatRect&, const Color&, ColorSpace); void fillRect(const FloatRect&, Generator&); void fillRoundedRect(const IntRect&, const IntSize& topLeft, const IntSize& topRight, const IntSize& bottomLeft, const IntSize& bottomRight, const Color&, ColorSpace); + void fillRoundedRect(const RoundedIntRect&, const Color&, ColorSpace); void clearRect(const FloatRect&); @@ -345,10 +348,10 @@ namespace WebCore { InterpolationQuality imageInterpolationQuality() const; void clip(const FloatRect&); - void addRoundedRectClip(const IntRect&, const IntSize& topLeft, const IntSize& topRight, const IntSize& bottomLeft, const IntSize& bottomRight); + void addRoundedRectClip(const RoundedIntRect&); void addInnerRoundedRectClip(const IntRect&, int thickness); void clipOut(const IntRect&); - void clipOutRoundedRect(const IntRect&, const IntSize& topLeft, const IntSize& topRight, const IntSize& bottomLeft, const IntSize& bottomRight); + void clipOutRoundedRect(const RoundedIntRect&); void clipPath(const Path&, WindRule); void clipConvexPolygon(size_t numPoints, const FloatPoint*, bool antialias = true); void clipToImageBuffer(ImageBuffer*, const FloatRect&); @@ -457,7 +460,8 @@ namespace WebCore { void setShouldIncludeChildWindows(bool); bool shouldIncludeChildWindows() const; - class WindowsBitmap : public Noncopyable { + class WindowsBitmap { + WTF_MAKE_NONCOPYABLE(WindowsBitmap); public: WindowsBitmap(HDC, IntSize); ~WindowsBitmap(); diff --git a/Source/WebCore/platform/graphics/GraphicsContext3D.h b/Source/WebCore/platform/graphics/GraphicsContext3D.h index 10aa0d7..24827e5 100644 --- a/Source/WebCore/platform/graphics/GraphicsContext3D.h +++ b/Source/WebCore/platform/graphics/GraphicsContext3D.h @@ -883,6 +883,7 @@ public: } ShaderSourceEntry; HashMap<Platform3DObject, ShaderSourceEntry> m_shaderSourceMap; + friend class Extensions3DOpenGL; ANGLEWebKitBridge m_compiler; OwnPtr<Extensions3DOpenGL> m_extensions; diff --git a/Source/WebCore/platform/graphics/GraphicsLayer.h b/Source/WebCore/platform/graphics/GraphicsLayer.h index 8943f6c..e3a62b6 100644 --- a/Source/WebCore/platform/graphics/GraphicsLayer.h +++ b/Source/WebCore/platform/graphics/GraphicsLayer.h @@ -100,7 +100,8 @@ class TimingFunction; // Base class for animation values (also used for transitions). Here to // represent values for properties being animated via the GraphicsLayer, // without pulling in style-related data from outside of the platform directory. -class AnimationValue : public Noncopyable { +class AnimationValue { + WTF_MAKE_NONCOPYABLE(AnimationValue); WTF_MAKE_FAST_ALLOCATED; public: AnimationValue(float keyTime, PassRefPtr<TimingFunction> timingFunction = 0) : m_keyTime(keyTime) @@ -152,7 +153,8 @@ private: // Used to store a series of values in a keyframe list. Values will all be of the same type, // which can be inferred from the property. -class KeyframeValueList : public Noncopyable { +class KeyframeValueList { + WTF_MAKE_NONCOPYABLE(KeyframeValueList); WTF_MAKE_FAST_ALLOCATED; public: KeyframeValueList(AnimatedPropertyID property) @@ -184,8 +186,8 @@ protected: // which may have associated transformation and animations. class GraphicsLayer { + WTF_MAKE_NONCOPYABLE(GraphicsLayer); WTF_MAKE_FAST_ALLOCATED; public: - static PassOwnPtr<GraphicsLayer> create(GraphicsLayerClient*); virtual ~GraphicsLayer(); diff --git a/Source/WebCore/platform/graphics/ImageBuffer.h b/Source/WebCore/platform/graphics/ImageBuffer.h index 338e3f8..48878da 100644 --- a/Source/WebCore/platform/graphics/ImageBuffer.h +++ b/Source/WebCore/platform/graphics/ImageBuffer.h @@ -31,7 +31,7 @@ #include "AffineTransform.h" #include "ColorSpace.h" #include "FloatRect.h" -#include "Image.h" +#include "GraphicsTypes.h" #include "IntSize.h" #include "ImageBufferData.h" #include <wtf/ByteArray.h> @@ -39,6 +39,7 @@ #include <wtf/OwnPtr.h> #include <wtf/PassOwnPtr.h> #include <wtf/PassRefPtr.h> +#include <wtf/Vector.h> #if (PLATFORM(MAC) && PLATFORM(CA) && !defined(BUILDING_ON_TIGER) && !defined(BUILDING_ON_LEOPARD) && !defined(BUILDING_ON_SNOW_LEOPARD)) #define WTF_USE_IOSURFACE_CANVAS_BACKING_STORE 1 @@ -47,6 +48,7 @@ namespace WebCore { class GraphicsContext; + class Image; class ImageData; class IntPoint; class IntRect; @@ -61,7 +63,8 @@ namespace WebCore { Accelerated }; - class ImageBuffer : public Noncopyable { + class ImageBuffer { + WTF_MAKE_NONCOPYABLE(ImageBuffer); WTF_MAKE_FAST_ALLOCATED; public: // Will return a null pointer on allocation failure. static PassOwnPtr<ImageBuffer> create(const IntSize& size, ColorSpace colorSpace = ColorSpaceDeviceRGB, RenderingMode renderingMode = Unaccelerated) @@ -79,6 +82,8 @@ namespace WebCore { int width() const { return m_size.width(); } int height() const { return m_size.height(); } + size_t dataSize() const; + GraphicsContext* context() const; bool drawsUsingCopy() const; // If the image buffer has to render using a copied image, it will return true. diff --git a/Source/WebCore/platform/graphics/ImageSource.h b/Source/WebCore/platform/graphics/ImageSource.h index 1452b71..70b2cf5 100644 --- a/Source/WebCore/platform/graphics/ImageSource.h +++ b/Source/WebCore/platform/graphics/ImageSource.h @@ -136,7 +136,8 @@ const int cAnimationLoopOnce = 0; const int cAnimationLoopInfinite = -1; const int cAnimationNone = -2; -class ImageSource : public Noncopyable { +class ImageSource { + WTF_MAKE_NONCOPYABLE(ImageSource); public: enum AlphaOption { AlphaPremultiplied, diff --git a/Source/WebCore/platform/graphics/MediaPlayer.cpp b/Source/WebCore/platform/graphics/MediaPlayer.cpp index 4a39e9e..60f55a5 100644 --- a/Source/WebCore/platform/graphics/MediaPlayer.cpp +++ b/Source/WebCore/platform/graphics/MediaPlayer.cpp @@ -150,7 +150,9 @@ static MediaPlayerPrivateInterface* createNullMediaPlayer(MediaPlayer* player) // engine support -struct MediaPlayerFactory : Noncopyable { +struct MediaPlayerFactory { + WTF_MAKE_NONCOPYABLE(MediaPlayerFactory); WTF_MAKE_FAST_ALLOCATED; +public: MediaPlayerFactory(CreateMediaEnginePlayer constructor, MediaEngineSupportedTypes getSupportedTypes, MediaEngineSupportsType supportsTypeAndCodecs) : constructor(constructor) , getSupportedTypes(getSupportedTypes) diff --git a/Source/WebCore/platform/graphics/MediaPlayer.h b/Source/WebCore/platform/graphics/MediaPlayer.h index 6525ca6..ef0b3eb 100644 --- a/Source/WebCore/platform/graphics/MediaPlayer.h +++ b/Source/WebCore/platform/graphics/MediaPlayer.h @@ -149,7 +149,8 @@ public: #endif }; -class MediaPlayer : public Noncopyable { +class MediaPlayer { + WTF_MAKE_NONCOPYABLE(MediaPlayer); WTF_MAKE_FAST_ALLOCATED; public: static PassOwnPtr<MediaPlayer> create(MediaPlayerClient* client) diff --git a/Source/WebCore/platform/graphics/MediaPlayerPrivate.h b/Source/WebCore/platform/graphics/MediaPlayerPrivate.h index d956286..6abe258 100644 --- a/Source/WebCore/platform/graphics/MediaPlayerPrivate.h +++ b/Source/WebCore/platform/graphics/MediaPlayerPrivate.h @@ -36,8 +36,10 @@ namespace WebCore { class IntRect; class IntSize; -class MediaPlayerPrivateInterface : public Noncopyable { +class MediaPlayerPrivateInterface { + WTF_MAKE_NONCOPYABLE(MediaPlayerPrivateInterface); WTF_MAKE_FAST_ALLOCATED; public: + MediaPlayerPrivateInterface() { } virtual ~MediaPlayerPrivateInterface() { } virtual void load(const String& url) = 0; diff --git a/Source/WebCore/platform/graphics/Path.h b/Source/WebCore/platform/graphics/Path.h index 423a792..852d88e 100644 --- a/Source/WebCore/platform/graphics/Path.h +++ b/Source/WebCore/platform/graphics/Path.h @@ -100,7 +100,8 @@ namespace WebCore { typedef void (*PathApplierFunction)(void* info, const PathElement*); - class Path : public FastAllocBase { + class Path { + WTF_MAKE_FAST_ALLOCATED; public: Path(); ~Path(); diff --git a/Source/WebCore/platform/graphics/RoundedIntRect.cpp b/Source/WebCore/platform/graphics/RoundedIntRect.cpp new file mode 100644 index 0000000..4e80c9a --- /dev/null +++ b/Source/WebCore/platform/graphics/RoundedIntRect.cpp @@ -0,0 +1,141 @@ +/* + * Copyright (C) 2003, 2006, 2009 Apple Inc. All rights reserved. + * 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 "RoundedIntRect.h" + +#include "IntRect.h" +#include <algorithm> + +namespace WebCore { + +bool RoundedIntRect::Radii::isZero() const +{ + return m_topLeft.isZero() && m_topRight.isZero() && m_bottomLeft.isZero() && m_bottomRight.isZero(); +} + +void RoundedIntRect::Radii::scale(float factor) +{ + if (factor == 1) + return; + + // If either radius on a corner becomes zero, reset both radii on that corner. + m_topLeft.scale(factor); + if (!m_topLeft.width() || !m_topLeft.height()) + m_topLeft = IntSize(); + m_topRight.scale(factor); + if (!m_topRight.width() || !m_topRight.height()) + m_topRight = IntSize(); + m_bottomLeft.scale(factor); + if (!m_bottomLeft.width() || !m_bottomLeft.height()) + m_bottomLeft = IntSize(); + m_bottomRight.scale(factor); + if (!m_bottomRight.width() || !m_bottomRight.height()) + m_bottomRight = IntSize(); + +} + +void RoundedIntRect::Radii::expand(int topWidth, int bottomWidth, int leftWidth, int rightWidth) +{ + m_topLeft.setWidth(std::max(0, m_topLeft.width() + leftWidth)); + m_topLeft.setHeight(std::max(0, m_topLeft.height() + topWidth)); + + m_topRight.setWidth(std::max(0, m_topRight.width() + rightWidth)); + m_topRight.setHeight(std::max(0, m_topRight.height() + topWidth)); + + m_bottomLeft.setWidth(std::max(0, m_bottomLeft.width() + leftWidth)); + m_bottomLeft.setHeight(std::max(0, m_bottomLeft.height() + bottomWidth)); + + m_bottomRight.setWidth(std::max(0, m_bottomRight.width() + rightWidth)); + m_bottomRight.setHeight(std::max(0, m_bottomRight.height() + bottomWidth)); +} + +void RoundedIntRect::Radii::includeLogicalEdges(const RoundedIntRect::Radii& edges, bool isHorizontal, bool includeLogicalLeftEdge, bool includeLogicalRightEdge) +{ + if (includeLogicalLeftEdge) { + if (isHorizontal) + m_bottomLeft = edges.bottomLeft(); + else + m_topRight = edges.topRight(); + m_topLeft = edges.topLeft(); + } + + if (includeLogicalRightEdge) { + if (isHorizontal) + m_topRight = edges.topRight(); + else + m_bottomLeft = edges.bottomLeft(); + m_bottomRight = edges.bottomRight(); + } +} + +void RoundedIntRect::Radii::excludeLogicalEdges(bool isHorizontal, bool excludeLogicalLeftEdge, bool excludeLogicalRightEdge) +{ + if (excludeLogicalLeftEdge) { + if (isHorizontal) + m_bottomLeft = IntSize(); + else + m_topRight = IntSize(); + m_topLeft = IntSize(); + } + + if (excludeLogicalRightEdge) { + if (isHorizontal) + m_topRight = IntSize(); + else + m_bottomLeft = IntSize(); + m_bottomRight = IntSize(); + } +} + +RoundedIntRect::RoundedIntRect(int x, int y, int width, int height) + : m_rect(x, y, width, height) +{ +} + +RoundedIntRect::RoundedIntRect(const IntRect& rect, const Radii& radii) + : m_rect(rect) + , m_radii(radii) +{ +} + +RoundedIntRect::RoundedIntRect(const IntRect& rect, const IntSize& topLeft, const IntSize& topRight, const IntSize& bottomLeft, const IntSize& bottomRight) + : m_rect(rect) + , m_radii(topLeft, topRight, bottomLeft, bottomRight) +{ +} + +void RoundedIntRect::includeLogicalEdges(const Radii& edges, bool isHorizontal, bool includeLogicalLeftEdge, bool includeLogicalRightEdge) +{ + m_radii.includeLogicalEdges(edges, isHorizontal, includeLogicalLeftEdge, includeLogicalRightEdge); +} + +void RoundedIntRect::excludeLogicalEdges(bool isHorizontal, bool excludeLogicalLeftEdge, bool excludeLogicalRightEdge) +{ + m_radii.excludeLogicalEdges(isHorizontal, excludeLogicalLeftEdge, excludeLogicalRightEdge); +} + +} // namespace WebCore diff --git a/Source/WebCore/platform/graphics/RoundedIntRect.h b/Source/WebCore/platform/graphics/RoundedIntRect.h new file mode 100644 index 0000000..c3c972f --- /dev/null +++ b/Source/WebCore/platform/graphics/RoundedIntRect.h @@ -0,0 +1,103 @@ +/* + * Copyright (C) 2003, 2006, 2009 Apple Inc. All rights reserved. + * 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 RoundedIntRect_h +#define RoundedIntRect_h + +#include "IntRect.h" + +namespace WebCore { + + +class RoundedIntRect { +public: + class Radii { + public: + Radii() {} + Radii(const IntSize& topLeft, const IntSize& topRight, const IntSize& bottomLeft, const IntSize& bottomRight) + : m_topLeft(topLeft) + , m_topRight(topRight) + , m_bottomLeft(bottomLeft) + , m_bottomRight(bottomRight) + { + } + + void setTopLeft(const IntSize& size) { m_topLeft = size; } + void setTopRight(const IntSize& size) { m_topRight = size; } + void setBottomLeft(const IntSize& size) { m_bottomLeft = size; } + void setBottomRight(const IntSize& size) { m_bottomRight = size; } + const IntSize& topLeft() const { return m_topLeft; } + const IntSize& topRight() const { return m_topRight; } + const IntSize& bottomLeft() const { return m_bottomLeft; } + const IntSize& bottomRight() const { return m_bottomRight; } + + bool isZero() const; + + void includeLogicalEdges(const Radii& edges, bool isHorizontal, bool includeLogicalLeftEdge, bool includeLogicalRightEdge); + void excludeLogicalEdges(bool isHorizontal, bool excludeLogicalLeftEdge, bool excludeLogicalRightEdge); + + void scale(float factor); + void expand(int topWidth, int bottomWidth, int leftWidth, int rightWidth); + void expand(int size) { expand(size, size, size, size); } + void shrink(int topWidth, int bottomWidth, int leftWidth, int rightWidth) { expand(-topWidth, -bottomWidth, -leftWidth, -rightWidth); } + void shrink(int size) { shrink(size, size, size, size); } + + private: + IntSize m_topLeft; + IntSize m_topRight; + IntSize m_bottomLeft; + IntSize m_bottomRight; + }; + + explicit RoundedIntRect(const IntRect&, const Radii& = Radii()); + RoundedIntRect(int x, int y, int width, int height); + RoundedIntRect(const IntRect&, const IntSize& topLeft, const IntSize& topRight, const IntSize& bottomLeft, const IntSize& bottomRight); + + const IntRect& rect() const { return m_rect; } + const Radii& radii() const { return m_radii; } + bool isRounded() const { return !m_radii.isZero(); } + bool isEmpty() const { return m_rect.isEmpty(); } + + void setRect(const IntRect& rect) { m_rect = rect; } + void setRadii(const Radii& radii) { m_radii = radii; } + + void move(const IntSize& size) { m_rect.move(size); } + void inflate(int size) { m_rect.inflate(size); } + void inflateWithRadii(int size) { m_rect.inflate(size); m_radii.expand(size); } + void expandRadii(int size) { m_radii.expand(size); } + void shrinkRadii(int size) { m_radii.shrink(size); } + + void includeLogicalEdges(const Radii& edges, bool isHorizontal, bool includeLogicalLeftEdge, bool includeLogicalRightEdge); + void excludeLogicalEdges(bool isHorizontal, bool excludeLogicalLeftEdge, bool excludeLogicalRightEdge); + +private: + IntRect m_rect; + Radii m_radii; +}; + +} // namespace WebCore + +#endif // RoundedIntRect_h diff --git a/Source/WebCore/platform/graphics/StringTruncator.cpp b/Source/WebCore/platform/graphics/StringTruncator.cpp index b6c86ce..65325f0 100644 --- a/Source/WebCore/platform/graphics/StringTruncator.cpp +++ b/Source/WebCore/platform/graphics/StringTruncator.cpp @@ -32,6 +32,7 @@ #include "CharacterNames.h" #include "Font.h" #include "TextBreakIterator.h" +#include "TextRun.h" #include <wtf/Assertions.h> #include <wtf/Vector.h> diff --git a/Source/WebCore/platform/graphics/TiledBackingStore.h b/Source/WebCore/platform/graphics/TiledBackingStore.h index 58477db..06c7fe1 100644 --- a/Source/WebCore/platform/graphics/TiledBackingStore.h +++ b/Source/WebCore/platform/graphics/TiledBackingStore.h @@ -36,7 +36,8 @@ namespace WebCore { class GraphicsContext; class TiledBackingStoreClient; -class TiledBackingStore : public Noncopyable { +class TiledBackingStore { + WTF_MAKE_NONCOPYABLE(TiledBackingStore); WTF_MAKE_FAST_ALLOCATED; public: TiledBackingStore(TiledBackingStoreClient*); ~TiledBackingStore(); diff --git a/Source/WebCore/platform/graphics/WidthIterator.cpp b/Source/WebCore/platform/graphics/WidthIterator.cpp index 2a951e8..412c86e 100644 --- a/Source/WebCore/platform/graphics/WidthIterator.cpp +++ b/Source/WebCore/platform/graphics/WidthIterator.cpp @@ -25,6 +25,7 @@ #include "Font.h" #include "GlyphBuffer.h" #include "SimpleFontData.h" +#include "TextRun.h" #include <wtf/MathExtras.h> #if USE(ICU_UNICODE) diff --git a/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.cpp b/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.cpp index b72d761..01e25e9 100644 --- a/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.cpp +++ b/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.cpp @@ -1105,6 +1105,10 @@ void GraphicsLayerCA::ensureStructuralLayer(StructuralLayerPurpose purpose) if (m_structuralLayer) { // Replace the transformLayer in the parent with this layer. m_layer->removeFromSuperlayer(); + + // If m_layer doesn't have a parent, it means it's the root layer and + // is likely hosted by something that is not expecting to be changed + ASSERT(m_structuralLayer->superlayer()); m_structuralLayer->superlayer()->replaceSublayer(m_structuralLayer.get(), m_layer.get()); moveOrCopyAnimationsForProperty(Move, AnimatedPropertyWebkitTransform, m_structuralLayer.get(), m_layer.get()); @@ -1178,6 +1182,9 @@ void GraphicsLayerCA::ensureStructuralLayer(StructuralLayerPurpose purpose) } // Move this layer to be a child of the transform layer. + // If m_layer doesn't have a parent, it means it's the root layer and + // is likely hosted by something that is not expecting to be changed + ASSERT(m_layer->superlayer()); m_layer->superlayer()->replaceSublayer(m_layer.get(), m_structuralLayer.get()); m_structuralLayer->appendSublayer(m_layer.get()); @@ -2013,6 +2020,9 @@ void GraphicsLayerCA::swapFromOrToTiledLayer(bool useTiledLayer) m_layer->adoptSublayers(oldLayer.get()); + // If m_layer doesn't have a parent, it means it's the root layer and + // is likely hosted by something that is not expecting to be changed + ASSERT(oldLayer->superlayer()); oldLayer->superlayer()->replaceSublayer(oldLayer.get(), m_layer.get()); updateContentsTransform(); diff --git a/Source/WebCore/platform/graphics/win/WKCACFLayerRenderer.cpp b/Source/WebCore/platform/graphics/ca/win/CACFLayerTreeHost.cpp index 7c83f86..1d27608 100644 --- a/Source/WebCore/platform/graphics/win/WKCACFLayerRenderer.cpp +++ b/Source/WebCore/platform/graphics/ca/win/CACFLayerTreeHost.cpp @@ -24,17 +24,12 @@ */ #include "config.h" +#include "CACFLayerTreeHost.h" #if USE(ACCELERATED_COMPOSITING) -#ifndef NDEBUG -#define D3D_DEBUG_INFO -#endif - -#include "WKCACFLayerRenderer.h" - +#include "LayerChangesFlusher.h" #include "PlatformCALayer.h" -#include "WKCACFContextFlusher.h" #include "WebCoreInstanceHandle.h" #include <WebKitSystemInterface/WebKitSystemInterface.h> #include <limits.h> @@ -44,6 +39,11 @@ #include <wtf/OwnPtr.h> #include <wtf/PassOwnPtr.h> #include <wtf/StdLibExtras.h> + +#ifndef NDEBUG +#define D3D_DEBUG_INFO +#endif + #include <d3d9.h> #include <d3dx9.h> @@ -117,7 +117,7 @@ static bool hardwareCapabilitiesIndicateCoreAnimationSupport(const D3DCAPS9& cap return true; } -bool WKCACFLayerRenderer::acceleratedCompositingAvailable() +bool CACFLayerTreeHost::acceleratedCompositingAvailable() { static bool available; static bool tested; @@ -165,30 +165,31 @@ bool WKCACFLayerRenderer::acceleratedCompositingAvailable() return available; } - OwnPtr<WKCACFLayerRenderer> testLayerRenderer = WKCACFLayerRenderer::create(0); - testLayerRenderer->setHostWindow(testWindow); - available = testLayerRenderer->createRenderer(); + RefPtr<CACFLayerTreeHost> host = CACFLayerTreeHost::create(); + host->setWindow(testWindow); + available = host->createRenderer(); ::DestroyWindow(testWindow); return available; } -PassOwnPtr<WKCACFLayerRenderer> WKCACFLayerRenderer::create(WKCACFLayerRendererClient* client) +PassRefPtr<CACFLayerTreeHost> CACFLayerTreeHost::create() { if (!acceleratedCompositingAvailable()) return 0; - return new WKCACFLayerRenderer(client); + return adoptRef(new CACFLayerTreeHost()); } -WKCACFLayerRenderer::WKCACFLayerRenderer(WKCACFLayerRendererClient* client) - : m_client(client) +CACFLayerTreeHost::CACFLayerTreeHost() + : m_client(0) , m_mightBeAbleToCreateDeviceLater(true) , m_rootLayer(PlatformCALayer::create(PlatformCALayer::LayerTypeRootLayer, 0)) , m_context(wkCACFContextCreate()) - , m_hostWindow(0) - , m_renderTimer(this, &WKCACFLayerRenderer::renderTimerFired) + , m_window(0) + , m_renderTimer(this, &CACFLayerTreeHost::renderTimerFired) , m_mustResetLostDeviceBeforeRendering(false) - , m_syncLayerChanges(false) + , m_shouldFlushPendingGraphicsLayerChanges(false) + , m_isFlushingLayerChanges(false) { // Point the CACFContext to this wkCACFContextSetUserData(m_context, this); @@ -202,7 +203,7 @@ WKCACFLayerRenderer::WKCACFLayerRenderer(WKCACFLayerRendererClient* client) // cause any repositioning. // Scrolling will affect only the position of the scroll layer without affecting the bounds. - m_rootLayer->setName("WKCACFLayerRenderer rootLayer"); + m_rootLayer->setName("CACFLayerTreeHost rootLayer"); m_rootLayer->setAnchorPoint(FloatPoint3D(0, 0, 0)); m_rootLayer->setGeometryFlipped(true); @@ -221,38 +222,37 @@ WKCACFLayerRenderer::WKCACFLayerRenderer(WKCACFLayerRendererClient* client) #endif } -WKCACFLayerRenderer::~WKCACFLayerRenderer() +CACFLayerTreeHost::~CACFLayerTreeHost() { - setHostWindow(0); - WKCACFContextFlusher::shared().removeContext(m_context); + setWindow(0); wkCACFContextDestroy(m_context); } -void WKCACFLayerRenderer::setHostWindow(HWND window) +void CACFLayerTreeHost::setWindow(HWND window) { - if (window == m_hostWindow) + if (window == m_window) return; - if (m_hostWindow) + if (m_window) destroyRenderer(); - m_hostWindow = window; + m_window = window; - if (m_hostWindow) + if (m_window) createRenderer(); } -PlatformCALayer* WKCACFLayerRenderer::rootLayer() const +PlatformCALayer* CACFLayerTreeHost::rootLayer() const { return m_rootLayer.get(); } -void WKCACFLayerRenderer::addPendingAnimatedLayer(PassRefPtr<PlatformCALayer> layer) +void CACFLayerTreeHost::addPendingAnimatedLayer(PassRefPtr<PlatformCALayer> layer) { m_pendingAnimatedLayers.add(layer); } -void WKCACFLayerRenderer::setRootChildLayer(PlatformCALayer* layer) +void CACFLayerTreeHost::setRootChildLayer(PlatformCALayer* layer) { m_rootLayer->removeAllSublayers(); m_rootChildLayer = layer; @@ -260,13 +260,22 @@ void WKCACFLayerRenderer::setRootChildLayer(PlatformCALayer* layer) m_rootLayer->appendSublayer(m_rootChildLayer.get()); } -void WKCACFLayerRenderer::layerTreeDidChange() +void CACFLayerTreeHost::layerTreeDidChange() { - WKCACFContextFlusher::shared().addContext(m_context); - renderSoon(); + if (m_isFlushingLayerChanges) { + // The layer tree is changing as a result of flushing GraphicsLayer changes to their + // underlying PlatformCALayers. We'll flush those changes to the context as part of that + // process, so there's no need to schedule another flush here. + return; + } + + // The layer tree is changing as a result of someone modifying a PlatformCALayer that doesn't + // have a corresponding GraphicsLayer. Schedule a flush since we won't schedule one through the + // normal GraphicsLayer mechanisms. + LayerChangesFlusher::shared().flushPendingLayerChangesSoon(this); } -bool WKCACFLayerRenderer::createRenderer() +bool CACFLayerTreeHost::createRenderer() { if (m_d3dDevice || !m_mightBeAbleToCreateDeviceLater) return m_d3dDevice; @@ -274,14 +283,14 @@ bool WKCACFLayerRenderer::createRenderer() m_mightBeAbleToCreateDeviceLater = false; D3DPRESENT_PARAMETERS parameters = initialPresentationParameters(); - if (!d3d() || !::IsWindow(m_hostWindow)) + if (!d3d() || !::IsWindow(m_window)) return false; // D3D doesn't like to make back buffers for 0 size windows. We skirt this problem if we make the // passed backbuffer width and height non-zero. The window will necessarily get set to a non-zero // size eventually, and then the backbuffer size will get reset. RECT rect; - GetClientRect(m_hostWindow, &rect); + GetClientRect(m_window, &rect); if (rect.left-rect.right == 0 || rect.bottom-rect.top == 0) { parameters.BackBufferWidth = 1; @@ -299,7 +308,7 @@ bool WKCACFLayerRenderer::createRenderer() behaviorFlags |= D3DCREATE_SOFTWARE_VERTEXPROCESSING; COMPtr<IDirect3DDevice9> device; - if (FAILED(d3d()->CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, m_hostWindow, behaviorFlags, ¶meters, &device))) { + if (FAILED(d3d()->CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, m_window, behaviorFlags, ¶meters, &device))) { // In certain situations (e.g., shortly after waking from sleep), Direct3DCreate9() will // return an IDirect3D9 for which IDirect3D9::CreateDevice will always fail. In case we // have one of these bad IDirect3D9s, get rid of it so we'll fetch a new one the next time @@ -332,15 +341,17 @@ bool WKCACFLayerRenderer::createRenderer() wkCACFContextSetD3DDevice(m_context, m_d3dDevice.get()); - if (IsWindow(m_hostWindow)) + if (IsWindow(m_window)) m_rootLayer->setBounds(bounds()); return true; } -void WKCACFLayerRenderer::destroyRenderer() +void CACFLayerTreeHost::destroyRenderer() { - wkCACFContextSetLayer(m_context, m_rootLayer->platformLayer()); + LayerChangesFlusher::shared().cancelPendingFlush(this); + + wkCACFContextSetLayer(m_context, 0); wkCACFContextSetD3DDevice(m_context, 0); m_d3dDevice = 0; @@ -354,7 +365,7 @@ void WKCACFLayerRenderer::destroyRenderer() m_mightBeAbleToCreateDeviceLater = true; } -void WKCACFLayerRenderer::resize() +void CACFLayerTreeHost::resize() { if (!m_d3dDevice) return; @@ -365,7 +376,7 @@ void WKCACFLayerRenderer::resize() if (m_rootLayer) { m_rootLayer->setBounds(bounds()); - WKCACFContextFlusher::shared().flushAllContexts(); + wkCACFContextFlush(m_context); } } @@ -399,12 +410,12 @@ static void getDirtyRects(HWND window, Vector<CGRect>& outRects) outRects[i] = winRectToCGRect(*rect, clientRect); } -void WKCACFLayerRenderer::renderTimerFired(Timer<WKCACFLayerRenderer>*) +void CACFLayerTreeHost::renderTimerFired(Timer<CACFLayerTreeHost>*) { paint(); } -void WKCACFLayerRenderer::paint() +void CACFLayerTreeHost::paint() { createRenderer(); if (!m_d3dDevice) { @@ -414,11 +425,11 @@ void WKCACFLayerRenderer::paint() } Vector<CGRect> dirtyRects; - getDirtyRects(m_hostWindow, dirtyRects); + getDirtyRects(m_window, dirtyRects); render(dirtyRects); } -void WKCACFLayerRenderer::render(const Vector<CGRect>& windowDirtyRects) +void CACFLayerTreeHost::render(const Vector<CGRect>& windowDirtyRects) { ASSERT(m_d3dDevice); @@ -428,20 +439,6 @@ void WKCACFLayerRenderer::render(const Vector<CGRect>& windowDirtyRects) return; } - if (m_client && !m_client->shouldRender()) { - renderSoon(); - return; - } - - // Sync the layer if needed - if (m_syncLayerChanges) { - m_client->syncCompositingState(); - m_syncLayerChanges = false; - } - - // Flush the root layer to the render tree. - wkCACFContextFlush(m_context); - // All pending animations will have been started with the flush. Fire the animationStarted calls double currentTime = WTF::currentTime(); double currentMediaTime = CACurrentMediaTime(); @@ -521,27 +518,49 @@ void WKCACFLayerRenderer::render(const Vector<CGRect>& windowDirtyRects) renderSoon(); } -void WKCACFLayerRenderer::renderSoon() +void CACFLayerTreeHost::renderSoon() { if (!m_renderTimer.isActive()) m_renderTimer.startOneShot(0); } -void WKCACFLayerRenderer::syncCompositingStateSoon() +void CACFLayerTreeHost::flushPendingGraphicsLayerChangesSoon() +{ + m_shouldFlushPendingGraphicsLayerChanges = true; + LayerChangesFlusher::shared().flushPendingLayerChangesSoon(this); +} + +void CACFLayerTreeHost::flushPendingLayerChangesNow() { - m_syncLayerChanges = true; + // Calling out to the client could cause our last reference to go away. + RefPtr<CACFLayerTreeHost> protector(this); + + m_isFlushingLayerChanges = true; + + // Flush changes stored up in GraphicsLayers to their underlying PlatformCALayers, if + // requested. + if (m_client && m_shouldFlushPendingGraphicsLayerChanges) { + m_shouldFlushPendingGraphicsLayerChanges = false; + m_client->flushPendingGraphicsLayerChanges(); + } + + // Flush changes stored up in PlatformCALayers to the context so they will be rendered. + wkCACFContextFlush(m_context); + renderSoon(); + + m_isFlushingLayerChanges = false; } -CGRect WKCACFLayerRenderer::bounds() const +CGRect CACFLayerTreeHost::bounds() const { RECT clientRect; - GetClientRect(m_hostWindow, &clientRect); + GetClientRect(m_window, &clientRect); return winRectToCGRect(clientRect); } -void WKCACFLayerRenderer::initD3DGeometry() +void CACFLayerTreeHost::initD3DGeometry() { ASSERT(m_d3dDevice); @@ -558,7 +577,7 @@ void WKCACFLayerRenderer::initD3DGeometry() m_d3dDevice->SetTransform(D3DTS_PROJECTION, &projection); } -bool WKCACFLayerRenderer::resetDevice(ResetReason reason) +bool CACFLayerTreeHost::resetDevice(ResetReason reason) { ASSERT(m_d3dDevice); ASSERT(m_context); diff --git a/Source/WebCore/platform/graphics/win/WKCACFLayerRenderer.h b/Source/WebCore/platform/graphics/ca/win/CACFLayerTreeHost.h index 02cdbdb..fc61f39 100644 --- a/Source/WebCore/platform/graphics/win/WKCACFLayerRenderer.h +++ b/Source/WebCore/platform/graphics/ca/win/CACFLayerTreeHost.h @@ -23,8 +23,8 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef WKCACFLayerRenderer_h -#define WKCACFLayerRenderer_h +#ifndef CACFLayerTreeHost_h +#define CACFLayerTreeHost_h #if USE(ACCELERATED_COMPOSITING) @@ -32,9 +32,8 @@ #include "Timer.h" #include <wtf/HashSet.h> -#include <wtf/Noncopyable.h> -#include <wtf/PassOwnPtr.h> #include <wtf/PassRefPtr.h> +#include <wtf/RefCounted.h> #include <wtf/RefPtr.h> #include <wtf/RetainPtr.h> #include <wtf/Vector.h> @@ -50,43 +49,45 @@ namespace WebCore { class PlatformCALayer; -class WKCACFLayerRendererClient { +class CACFLayerTreeHostClient { public: - virtual ~WKCACFLayerRendererClient() { } - virtual bool shouldRender() const = 0; - virtual void syncCompositingState() { } + virtual ~CACFLayerTreeHostClient() { } + virtual void flushPendingGraphicsLayerChanges() { } }; -// FIXME: Currently there is a WKCACFLayerRenderer for each WebView and each +// FIXME: Currently there is a CACFLayerTreeHost for each WebView and each // has its own CARenderOGLContext and Direct3DDevice9, which is inefficient. // (https://bugs.webkit.org/show_bug.cgi?id=31855) -class WKCACFLayerRenderer : public Noncopyable { +class CACFLayerTreeHost : public RefCounted<CACFLayerTreeHost> { friend PlatformCALayer; public: - static PassOwnPtr<WKCACFLayerRenderer> create(WKCACFLayerRendererClient*); - ~WKCACFLayerRenderer(); + static PassRefPtr<CACFLayerTreeHost> create(); + ~CACFLayerTreeHost(); static bool acceleratedCompositingAvailable(); + void setClient(CACFLayerTreeHostClient* client) { m_client = client; } + void setRootChildLayer(PlatformCALayer*); void layerTreeDidChange(); - void setHostWindow(HWND); + void setWindow(HWND); void paint(); void resize(); - void syncCompositingStateSoon(); + void flushPendingGraphicsLayerChangesSoon(); + void flushPendingLayerChangesNow(); protected: PlatformCALayer* rootLayer() const; void addPendingAnimatedLayer(PassRefPtr<PlatformCALayer>); private: - WKCACFLayerRenderer(WKCACFLayerRendererClient*); + CACFLayerTreeHost(); bool createRenderer(); void destroyRenderer(); void renderSoon(); - void renderTimerFired(Timer<WKCACFLayerRenderer>*); + void renderTimerFired(Timer<CACFLayerTreeHost>*); CGRect bounds() const; @@ -100,16 +101,17 @@ private: void render(const Vector<CGRect>& dirtyRects = Vector<CGRect>()); - WKCACFLayerRendererClient* m_client; + CACFLayerTreeHostClient* m_client; bool m_mightBeAbleToCreateDeviceLater; COMPtr<IDirect3DDevice9> m_d3dDevice; RefPtr<PlatformCALayer> m_rootLayer; RefPtr<PlatformCALayer> m_rootChildLayer; WKCACFContext* m_context; - HWND m_hostWindow; - Timer<WKCACFLayerRenderer> m_renderTimer; + HWND m_window; + Timer<CACFLayerTreeHost> m_renderTimer; bool m_mustResetLostDeviceBeforeRendering; - bool m_syncLayerChanges; + bool m_shouldFlushPendingGraphicsLayerChanges; + bool m_isFlushingLayerChanges; HashSet<RefPtr<PlatformCALayer> > m_pendingAnimatedLayers; #ifndef NDEBUG @@ -121,4 +123,4 @@ private: #endif // USE(ACCELERATED_COMPOSITING) -#endif // WKCACFLayerRenderer_h +#endif // CACFLayerTreeHost_h diff --git a/Source/WebCore/platform/graphics/ca/win/LayerChangesFlusher.cpp b/Source/WebCore/platform/graphics/ca/win/LayerChangesFlusher.cpp new file mode 100644 index 0000000..3fd857b --- /dev/null +++ b/Source/WebCore/platform/graphics/ca/win/LayerChangesFlusher.cpp @@ -0,0 +1,132 @@ +/* + * Copyright (C) 2011 Apple 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 INC. ``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 COMPUTER, INC. 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 "LayerChangesFlusher.h" + +#if USE(ACCELERATED_COMPOSITING) + +#include "CACFLayerTreeHost.h" +#include "WebCoreInstanceHandle.h" +#include <wtf/StdLibExtras.h> +#include <wtf/Vector.h> + +namespace WebCore { + +LayerChangesFlusher& LayerChangesFlusher::shared() +{ + DEFINE_STATIC_LOCAL(LayerChangesFlusher, flusher, ()); + return flusher; +} + +LayerChangesFlusher::LayerChangesFlusher() + : m_hook(0) + , m_isCallingHosts(false) +{ +} + +void LayerChangesFlusher::flushPendingLayerChangesSoon(CACFLayerTreeHost* host) +{ + if (!m_hostsWithChangesToFlush.add(host).second || m_hook) + return; + + setHook(); +} + +void LayerChangesFlusher::cancelPendingFlush(CACFLayerTreeHost* host) +{ + m_hostsWithChangesToFlush.remove(host); + + if (!m_hostsWithChangesToFlush.isEmpty() || !m_hook) + return; + + // We handle removing the hook when we finish calling out to the hosts, so we shouldn't + // mess with it while we're in the process of calling them. + if (m_isCallingHosts) + return; + + removeHook(); +} + +LRESULT LayerChangesFlusher::hookCallback(int code, WPARAM wParam, LPARAM lParam) +{ + return shared().hookFired(code, wParam, lParam); +} + +LRESULT LayerChangesFlusher::hookFired(int code, WPARAM wParam, LPARAM lParam) +{ + ASSERT(m_hook); + + // Calling out to the hosts can cause m_hostsWithChangesToFlush to be modified, so we copy it + // into a Vector first. We have to hold a reference to them because otherwise they could be + // destroyed while we're calling out to them. + Vector<RefPtr<CACFLayerTreeHost> > hosts; + copyToVector(m_hostsWithChangesToFlush, hosts); + m_hostsWithChangesToFlush.clear(); + + m_isCallingHosts = true; + for (size_t i = 0; i < hosts.size(); ++i) + hosts[i]->flushPendingLayerChangesNow(); + m_isCallingHosts = false; + + LRESULT result = ::CallNextHookEx(m_hook, code, wParam, lParam); + + if (m_hostsWithChangesToFlush.isEmpty()) { + // We won't have any work to do next time around, so just remove our hook. + removeHook(); + } + + return result; +} + +void LayerChangesFlusher::setHook() +{ + ASSERT(!m_hook); + ASSERT(!m_isCallingHosts); + + DWORD threadID = ::GetCurrentThreadId(); + + m_hook = ::SetWindowsHookExW(WH_GETMESSAGE, hookCallback, instanceHandle(), threadID); + ASSERT_WITH_MESSAGE(m_hook, "::SetWindowsHookExW failed with error %lu", ::GetLastError()); + + // Post a message to the message queue to prevent ::GetMessage from blocking, which will ensure + // our hook is called soon. + ::PostThreadMessageW(threadID, WM_NULL, 0, 0); +} + +void LayerChangesFlusher::removeHook() +{ + ASSERT(m_hook); + ASSERT(!m_isCallingHosts); + + if (!::UnhookWindowsHookEx(m_hook)) + ASSERT_WITH_MESSAGE(false, "::UnhookWindowsHookEx failed with error %lu", ::GetLastError()); + + m_hook = 0; +} + +} // namespace WebCore + +#endif // USE(ACCELERATED_COMPOSITING) diff --git a/Source/WebCore/platform/graphics/win/WKCACFContextFlusher.h b/Source/WebCore/platform/graphics/ca/win/LayerChangesFlusher.h index 17ec41d..6a98a99 100644 --- a/Source/WebCore/platform/graphics/win/WKCACFContextFlusher.h +++ b/Source/WebCore/platform/graphics/ca/win/LayerChangesFlusher.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2009 Apple Inc. All rights reserved. + * Copyright (C) 2011 Apple Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -20,41 +20,46 @@ * 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. + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef WKCACFContextFlusher_h -#define WKCACFContextFlusher_h +#ifndef LayerChangesFlusher_h +#define LayerChangesFlusher_h #if USE(ACCELERATED_COMPOSITING) -#include <wtf/Noncopyable.h> - +#include <windows.h> #include <wtf/HashSet.h> - -struct WKCACFContext; +#include <wtf/Noncopyable.h> namespace WebCore { -class WKCACFContextFlusher : public Noncopyable { -public: - static WKCACFContextFlusher& shared(); +class CACFLayerTreeHost; - void addContext(WKCACFContext*); - void removeContext(WKCACFContext*); +class LayerChangesFlusher { + WTF_MAKE_NONCOPYABLE(LayerChangesFlusher); +public: + static LayerChangesFlusher& shared(); - void flushAllContexts(); + void flushPendingLayerChangesSoon(CACFLayerTreeHost*); + void cancelPendingFlush(CACFLayerTreeHost*); private: - WKCACFContextFlusher(); - ~WKCACFContextFlusher(); + LayerChangesFlusher(); + ~LayerChangesFlusher(); + + static LRESULT CALLBACK hookCallback(int code, WPARAM, LPARAM); + LRESULT hookFired(int code, WPARAM, LPARAM); + void setHook(); + void removeHook(); - typedef HashSet<WKCACFContext*> ContextSet; - ContextSet m_contexts; + HashSet<CACFLayerTreeHost*> m_hostsWithChangesToFlush; + HHOOK m_hook; + bool m_isCallingHosts; }; -} +} // namespace WebCore #endif // USE(ACCELERATED_COMPOSITING) -#endif // WKCACFContextFlusher_h +#endif // LayerChangesFlusher_h diff --git a/Source/WebCore/platform/graphics/ca/win/PlatformCAAnimationWin.cpp b/Source/WebCore/platform/graphics/ca/win/PlatformCAAnimationWin.cpp index 7230cfc..228bb01 100644 --- a/Source/WebCore/platform/graphics/ca/win/PlatformCAAnimationWin.cpp +++ b/Source/WebCore/platform/graphics/ca/win/PlatformCAAnimationWin.cpp @@ -41,7 +41,7 @@ using namespace WebCore; -static String toCACFFillModeType(PlatformCAAnimation::FillModeType type) +static CFStringRef toCACFFillModeType(PlatformCAAnimation::FillModeType type) { switch (type) { case PlatformCAAnimation::NoFillMode: @@ -49,10 +49,11 @@ static String toCACFFillModeType(PlatformCAAnimation::FillModeType type) case PlatformCAAnimation::Backwards: return kCACFFillModeBackwards; case PlatformCAAnimation::Both: return kCACFFillModeBoth; } - return ""; + ASSERT_NOT_REACHED(); + return 0; } -static PlatformCAAnimation::FillModeType fromCACFFillModeType(const String& string) +static PlatformCAAnimation::FillModeType fromCACFFillModeType(CFStringRef string) { if (string == kCACFFillModeBackwards) return PlatformCAAnimation::Backwards; @@ -63,10 +64,10 @@ static PlatformCAAnimation::FillModeType fromCACFFillModeType(const String& stri return PlatformCAAnimation::Forwards; } -static String toCACFValueFunctionType(PlatformCAAnimation::ValueFunctionType type) +static CFStringRef toCACFValueFunctionType(PlatformCAAnimation::ValueFunctionType type) { switch (type) { - case PlatformCAAnimation::NoValueFunction: return ""; + case PlatformCAAnimation::NoValueFunction: return 0; case PlatformCAAnimation::RotateX: return kCACFValueFunctionRotateX; case PlatformCAAnimation::RotateY: return kCACFValueFunctionRotateY; case PlatformCAAnimation::RotateZ: return kCACFValueFunctionRotateZ; @@ -79,10 +80,11 @@ static String toCACFValueFunctionType(PlatformCAAnimation::ValueFunctionType typ case PlatformCAAnimation::TranslateZ: return kCACFValueFunctionTranslateZ; case PlatformCAAnimation::Translate: return kCACFValueFunctionTranslate; } - return ""; + ASSERT_NOT_REACHED(); + return 0; } -static PlatformCAAnimation::ValueFunctionType fromCACFValueFunctionType(const String string) +static PlatformCAAnimation::ValueFunctionType fromCACFValueFunctionType(CFStringRef string) { if (string == kCACFValueFunctionRotateX) return PlatformCAAnimation::RotateX; @@ -120,14 +122,14 @@ static PlatformCAAnimation::ValueFunctionType fromCACFValueFunctionType(const St return PlatformCAAnimation::NoValueFunction; } -static CACFTimingFunctionRef toCACFTimingFunction(const TimingFunction* timingFunction) +static RetainPtr<CACFTimingFunctionRef> toCACFTimingFunction(const TimingFunction* timingFunction) { if (!timingFunction) - return CACFTimingFunctionCreate(0.25f, 0.1f, 0.25f, 0.1f); + return RetainPtr<CACFTimingFunctionRef>(AdoptCF, CACFTimingFunctionCreate(0.25f, 0.1f, 0.25f, 0.1f)); if (timingFunction->isCubicBezierTimingFunction()) { const CubicBezierTimingFunction* ctf = static_cast<const CubicBezierTimingFunction*>(timingFunction); - return CACFTimingFunctionCreate(static_cast<float>(ctf->x1()), static_cast<float>(ctf->y1()), static_cast<float>(ctf->x2()), static_cast<float>(ctf->y2())); + return RetainPtr<CACFTimingFunctionRef>(AdoptCF, CACFTimingFunctionCreate(static_cast<float>(ctf->x1()), static_cast<float>(ctf->y1()), static_cast<float>(ctf->x2()), static_cast<float>(ctf->y2()))); } return CACFTimingFunctionGetFunctionWithName(kCACFTimingFunctionLinear); @@ -162,12 +164,12 @@ PlatformCAAnimation::PlatformCAAnimation(AnimationType type, const String& keyPa PlatformCAAnimation::PlatformCAAnimation(PlatformAnimationRef animation) { - if (String(CACFAnimationGetClass(animation)) == kCACFBasicAnimation) + if (CACFAnimationGetClass(animation) == kCACFBasicAnimation) m_type = Basic; - else if (String(CACFAnimationGetClass(animation)) == kCACFKeyframeAnimation) + else if (CACFAnimationGetClass(animation) == kCACFKeyframeAnimation) m_type = Keyframe; else { - ASSERT(0); + ASSERT_NOT_REACHED(); return; } @@ -289,13 +291,12 @@ PlatformCAAnimation::FillModeType PlatformCAAnimation::fillMode() const void PlatformCAAnimation::setFillMode(FillModeType value) { - RetainPtr<CFStringRef> keyPath(AdoptCF, toCACFFillModeType(value).createCFString()); - CACFAnimationSetFillMode(m_animation.get(), keyPath.get()); + CACFAnimationSetFillMode(m_animation.get(), toCACFFillModeType(value)); } void PlatformCAAnimation::setTimingFunction(const TimingFunction* value) { - CACFAnimationSetTimingFunction(m_animation.get(), toCACFTimingFunction(value)); + CACFAnimationSetTimingFunction(m_animation.get(), toCACFTimingFunction(value).get()); } void PlatformCAAnimation::copyTimingFunctionFrom(const PlatformCAAnimation* value) @@ -330,8 +331,7 @@ PlatformCAAnimation::ValueFunctionType PlatformCAAnimation::valueFunction() cons void PlatformCAAnimation::setValueFunction(ValueFunctionType value) { - RetainPtr<CFStringRef> keyPath(AdoptCF, toCACFValueFunctionType(value).createCFString()); - CACFAnimationSetValueFunction(m_animation.get(), CACFValueFunctionGetFunctionWithName(keyPath.get())); + CACFAnimationSetValueFunction(m_animation.get(), CACFValueFunctionGetFunctionWithName(toCACFValueFunctionType(value))); } void PlatformCAAnimation::setFromValue(float value) @@ -524,7 +524,7 @@ void PlatformCAAnimation::setTimingFunctions(const Vector<const TimingFunction*> RetainPtr<CFMutableArrayRef> array(AdoptCF, CFArrayCreateMutable(0, value.size(), &kCFTypeArrayCallBacks)); for (size_t i = 0; i < value.size(); ++i) { RetainPtr<CFNumberRef> v(AdoptCF, CFNumberCreate(0, kCFNumberFloatType, &value[i])); - CFArrayAppendValue(array.get(), toCACFTimingFunction(value[i])); + CFArrayAppendValue(array.get(), toCACFTimingFunction(value[i]).get()); } CACFAnimationSetTimingFunctions(m_animation.get(), array.get()); diff --git a/Source/WebCore/platform/graphics/ca/win/PlatformCALayerWin.cpp b/Source/WebCore/platform/graphics/ca/win/PlatformCALayerWin.cpp index 66d0732..b5a26f4 100644 --- a/Source/WebCore/platform/graphics/ca/win/PlatformCALayerWin.cpp +++ b/Source/WebCore/platform/graphics/ca/win/PlatformCALayerWin.cpp @@ -29,10 +29,10 @@ #include "PlatformCALayer.h" +#include "CACFLayerTreeHost.h" #include "Font.h" #include "GraphicsContext.h" #include "PlatformCALayerWinInternal.h" -#include "WKCACFLayerRenderer.h" #include <QuartzCore/CoreAnimationCF.h> #include <WebKitSystemInterface/WebKitSystemInterface.h> #include <wtf/CurrentTime.h> @@ -65,14 +65,14 @@ static CFStringRef toCACFFilterType(PlatformCALayer::FilterType type) } } -static WKCACFLayerRenderer* rendererForLayer(const PlatformCALayer* layer) +static CACFLayerTreeHost* layerTreeHostForLayer(const PlatformCALayer* layer) { - // We need the WKCACFLayerRenderer associated with this layer, which is stored in the UserData of the CACFContext + // We need the CACFLayerTreeHost associated with this layer, which is stored in the UserData of the CACFContext void* userData = wkCACFLayerGetContextUserData(layer->platformLayer()); if (!userData) return 0; - return static_cast<WKCACFLayerRenderer*>(userData); + return static_cast<CACFLayerTreeHost*>(userData); } static PlatformCALayerWinInternal* intern(const PlatformCALayer* layer) @@ -156,8 +156,8 @@ PlatformLayer* PlatformCALayer::platformLayer() const PlatformCALayer* PlatformCALayer::rootLayer() const { - WKCACFLayerRenderer* renderer = rendererForLayer(this); - return renderer ? renderer->rootLayer() : 0; + CACFLayerTreeHost* host = layerTreeHostForLayer(this); + return host ? host->rootLayer() : 0; } void PlatformCALayer::setNeedsDisplay(const FloatRect* dirtyRect) @@ -167,9 +167,9 @@ void PlatformCALayer::setNeedsDisplay(const FloatRect* dirtyRect) void PlatformCALayer::setNeedsCommit() { - WKCACFLayerRenderer* renderer = rendererForLayer(this); - if (renderer) - renderer->layerTreeDidChange(); + CACFLayerTreeHost* host = layerTreeHostForLayer(this); + if (host) + host->layerTreeDidChange(); } void PlatformCALayer::setContentsChanged() @@ -269,10 +269,10 @@ void PlatformCALayer::addAnimationForKey(const String& key, PlatformCAAnimation* CACFLayerAddAnimation(m_layer.get(), s.get(), animation->platformAnimation()); setNeedsCommit(); - // Tell the renderer about it so we can fire the start animation event - WKCACFLayerRenderer* renderer = rendererForLayer(this); - if (renderer) - renderer->addPendingAnimatedLayer(this); + // Tell the host about it so we can fire the start animation event + CACFLayerTreeHost* host = layerTreeHostForLayer(this); + if (host) + host->addPendingAnimatedLayer(this); } void PlatformCALayer::removeAnimationForKey(const String& key) @@ -283,7 +283,7 @@ void PlatformCALayer::removeAnimationForKey(const String& key) RetainPtr<CFStringRef> s(AdoptCF, key.createCFString()); CACFLayerRemoveAnimation(m_layer.get(), s.get()); - // We don't "remove" a layer from WKCACFLayerRenderer when it loses an animation. + // We don't "remove" a layer from CACFLayerTreeHost when it loses an animation. // There may be other active animations on the layer and if an animation // callback is fired on a layer without any animations no harm is done. diff --git a/Source/WebCore/platform/graphics/ca/win/PlatformCALayerWinInternal.cpp b/Source/WebCore/platform/graphics/ca/win/PlatformCALayerWinInternal.cpp index cdf90db..1697122 100644 --- a/Source/WebCore/platform/graphics/ca/win/PlatformCALayerWinInternal.cpp +++ b/Source/WebCore/platform/graphics/ca/win/PlatformCALayerWinInternal.cpp @@ -31,6 +31,7 @@ #include "Font.h" #include "PlatformCALayer.h" +#include "TextRun.h" #include <QuartzCore/CACFLayer.h> using namespace std; diff --git a/Source/WebCore/platform/graphics/cairo/FontCustomPlatformData.h b/Source/WebCore/platform/graphics/cairo/FontCustomPlatformData.h index dac31f8..50ea00f 100644 --- a/Source/WebCore/platform/graphics/cairo/FontCustomPlatformData.h +++ b/Source/WebCore/platform/graphics/cairo/FontCustomPlatformData.h @@ -35,7 +35,8 @@ namespace WebCore { class FontPlatformData; class SharedBuffer; -struct FontCustomPlatformData : Noncopyable { +struct FontCustomPlatformData { + WTF_MAKE_NONCOPYABLE(FontCustomPlatformData); public: FontCustomPlatformData(FT_Face, SharedBuffer*); ~FontCustomPlatformData(); diff --git a/Source/WebCore/platform/graphics/cairo/ImageBufferCairo.cpp b/Source/WebCore/platform/graphics/cairo/ImageBufferCairo.cpp index ac5da3d..51b5ee6 100644 --- a/Source/WebCore/platform/graphics/cairo/ImageBufferCairo.cpp +++ b/Source/WebCore/platform/graphics/cairo/ImageBufferCairo.cpp @@ -91,6 +91,11 @@ ImageBuffer::~ImageBuffer() cairo_surface_destroy(m_data.m_surface); } +size_t ImageBuffer::dataSize() const +{ + return m_size.width() * m_size.height() * 4; +} + GraphicsContext* ImageBuffer::context() const { return m_context.get(); diff --git a/Source/WebCore/platform/graphics/cg/GraphicsContextCG.cpp b/Source/WebCore/platform/graphics/cg/GraphicsContextCG.cpp index eddf735..bcfc37b 100644 --- a/Source/WebCore/platform/graphics/cg/GraphicsContextCG.cpp +++ b/Source/WebCore/platform/graphics/cg/GraphicsContextCG.cpp @@ -625,8 +625,8 @@ void GraphicsContext::fillRect(const FloatRect& rect) if (m_state.fillGradient) { CGContextSaveGState(context); - CGContextConcatCTM(context, m_state.fillGradient->gradientSpaceTransform()); if (hasShadow()) { + CGContextConcatCTM(context, m_state.fillGradient->gradientSpaceTransform()); CGLayerRef layer = CGLayerCreateWithContext(context, CGSizeMake(rect.width(), rect.height()), 0); CGContextRef layerContext = CGLayerGetContext(layer); m_state.fillGradient->paint(layerContext); @@ -634,6 +634,7 @@ void GraphicsContext::fillRect(const FloatRect& rect) CGLayerRelease(layer); } else { CGContextClipToRect(context, rect); + CGContextConcatCTM(context, m_state.fillGradient->gradientSpaceTransform()); m_state.fillGradient->paint(this); } CGContextRestoreGState(context); diff --git a/Source/WebCore/platform/graphics/cg/ImageBufferCG.cpp b/Source/WebCore/platform/graphics/cg/ImageBufferCG.cpp index 023d098..295f632 100644 --- a/Source/WebCore/platform/graphics/cg/ImageBufferCG.cpp +++ b/Source/WebCore/platform/graphics/cg/ImageBufferCG.cpp @@ -173,6 +173,11 @@ ImageBuffer::~ImageBuffer() { } +size_t ImageBuffer::dataSize() const +{ + return m_size.height() * m_data.m_bytesPerRow; +} + GraphicsContext* ImageBuffer::context() const { return m_context.get(); diff --git a/Source/WebCore/platform/graphics/cg/PatternCG.cpp b/Source/WebCore/platform/graphics/cg/PatternCG.cpp index 94f37b2..cfac15c 100644 --- a/Source/WebCore/platform/graphics/cg/PatternCG.cpp +++ b/Source/WebCore/platform/graphics/cg/PatternCG.cpp @@ -54,8 +54,7 @@ CGPatternRef Pattern::createPlatformPattern(const AffineTransform& userSpaceTran { IntRect tileRect = tileImage()->rect(); - AffineTransform patternTransform = m_patternSpaceTransformation; - patternTransform.multiply(userSpaceTransformation); + AffineTransform patternTransform = userSpaceTransformation * m_patternSpaceTransformation; patternTransform.scaleNonUniform(1, -1); patternTransform.translate(0, -tileRect.height()); diff --git a/Source/WebCore/platform/graphics/chromium/ComplexTextControllerLinux.cpp b/Source/WebCore/platform/graphics/chromium/ComplexTextControllerLinux.cpp index 99159e6..92861fc 100644 --- a/Source/WebCore/platform/graphics/chromium/ComplexTextControllerLinux.cpp +++ b/Source/WebCore/platform/graphics/chromium/ComplexTextControllerLinux.cpp @@ -32,6 +32,7 @@ #include "ComplexTextControllerLinux.h" #include "Font.h" +#include "TextRun.h" #include <unicode/normlzr.h> @@ -47,8 +48,6 @@ static int truncateFixedPointToInteger(HB_Fixed value) ComplexTextController::ComplexTextController(const TextRun& run, unsigned startingX, const Font* font) : m_font(font) - , m_startingX(startingX) - , m_offsetX(m_startingX) , m_run(getNormalizedTextRun(run, m_normalizedRun, m_normalizedBuffer)) , m_wordSpacingAdjustment(0) , m_padding(0) @@ -75,7 +74,7 @@ ComplexTextController::ComplexTextController(const TextRun& run, unsigned starti m_item.string = m_run.characters(); m_item.stringLength = m_run.length(); - reset(); + reset(startingX); } ComplexTextController::~ComplexTextController() @@ -137,10 +136,10 @@ void ComplexTextController::setPadding(int padding) m_padPerWordBreak = 0; } -void ComplexTextController::reset() +void ComplexTextController::reset(unsigned offset) { m_indexOfNextScriptRun = 0; - m_offsetX = m_startingX; + m_offsetX = offset; } // Advance to the next script run, returning false when the end of the @@ -277,8 +276,7 @@ void ComplexTextController::setGlyphXPositions(bool isRTL) int logClustersIndex = 0; // Iterate through the glyphs in logical order, flipping for RTL where necessary. - // In RTL mode all variables are positive except m_xPositions, which starts from m_offsetX and runs negative. - // It is fixed up in a second pass below. + // Glyphs are positioned starting from m_offsetX; in RTL mode they go leftwards from there. for (size_t i = 0; i < m_item.num_glyphs; ++i) { while (static_cast<unsigned>(logClustersIndex) < m_item.item.length && logClusters()[logClustersIndex] < i) logClustersIndex++; @@ -303,16 +301,8 @@ void ComplexTextController::setGlyphXPositions(bool isRTL) position += advance; } - const double width = position; - - // Now that we've computed the total width, do another pass to fix positioning for RTL. - if (isRTL) { - for (size_t i = 0; i < m_item.num_glyphs; ++i) - m_xPositions[i] += width; - } - - m_pixelWidth = std::max(width, 0.0); - m_offsetX += m_pixelWidth; + m_pixelWidth = std::max(position, 0.0); + m_offsetX += m_pixelWidth * rtlFlip; } void ComplexTextController::normalizeSpacesAndMirrorChars(const UChar* source, bool rtl, UChar* destination, int length) diff --git a/Source/WebCore/platform/graphics/chromium/ComplexTextControllerLinux.h b/Source/WebCore/platform/graphics/chromium/ComplexTextControllerLinux.h index e264b99..a2aea60 100644 --- a/Source/WebCore/platform/graphics/chromium/ComplexTextControllerLinux.h +++ b/Source/WebCore/platform/graphics/chromium/ComplexTextControllerLinux.h @@ -68,7 +68,7 @@ public: // setPadding sets a number of pixels to be distributed across the TextRun. // WebKit uses this to justify text. void setPadding(int); - void reset(); + void reset(unsigned offset); // Advance to the next script run, returning false when the end of the // TextRun has been reached. bool nextScriptRun(); @@ -86,7 +86,6 @@ public: // Set the x offset for the next script run. This affects the values in // |xPositions| - void setXOffsetToZero() { m_offsetX = 0; } bool rtl() const { return m_run.rtl(); } const uint16_t* glyphs() const { return m_glyphs16; } @@ -114,6 +113,9 @@ public: // return the number of code points in the current script run const unsigned numCodePoints() const { return m_numCodePoints; } + // Return the current pixel position of the controller. + const unsigned offsetX() const { return m_offsetX; } + const FontPlatformData* fontPlatformDataForScriptRun() { return reinterpret_cast<FontPlatformData*>(m_item.font->userData); } private: @@ -137,7 +139,6 @@ private: uint16_t* m_glyphs16; // A vector of 16-bit glyph ids. SkScalar* m_xPositions; // A vector of x positions for each glyph. ssize_t m_indexOfNextScriptRun; // Indexes the script run in |m_run|. - const unsigned m_startingX; // Offset in pixels of the first script run. unsigned m_offsetX; // Offset in pixels to the start of the next script run. unsigned m_pixelWidth; // Width (in px) of the current script run. unsigned m_numCodePoints; // Code points in current script run. diff --git a/Source/WebCore/platform/graphics/chromium/CrossProcessFontLoading.mm b/Source/WebCore/platform/graphics/chromium/CrossProcessFontLoading.mm index 72e3369..227fbe4 100644 --- a/Source/WebCore/platform/graphics/chromium/CrossProcessFontLoading.mm +++ b/Source/WebCore/platform/graphics/chromium/CrossProcessFontLoading.mm @@ -30,7 +30,7 @@ #import "CrossProcessFontLoading.h" #import "../graphics/cocoa/FontPlatformData.h" -#import "ChromiumBridge.h" +#import "PlatformBridge.h" #import <AppKit/NSFont.h> #import <wtf/HashMap.h> @@ -87,7 +87,7 @@ PassRefPtr<MemoryActivatedFont> loadFontFromBrowserProcess(NSFont* nsFont) { ATSFontContainerRef container; // Send cross-process request to load font. - if (!ChromiumBridge::loadFont(nsFont, &container)) + if (!PlatformBridge::loadFont(nsFont, &container)) return 0; ATSFontContainerRef srcFontContainerRef = fontContainerRefFromNSFont(nsFont); diff --git a/Source/WebCore/platform/graphics/chromium/DrawingBufferChromium.cpp b/Source/WebCore/platform/graphics/chromium/DrawingBufferChromium.cpp index 569dff4..2d4ca41 100644 --- a/Source/WebCore/platform/graphics/chromium/DrawingBufferChromium.cpp +++ b/Source/WebCore/platform/graphics/chromium/DrawingBufferChromium.cpp @@ -72,15 +72,16 @@ DrawingBuffer::DrawingBuffer(GraphicsContext3D* context, bool multisampleExtensionSupported, bool packedDepthStencilExtensionSupported) : m_context(context) - , m_size(size) + , m_size(-1, -1) , m_multisampleExtensionSupported(multisampleExtensionSupported) , m_packedDepthStencilExtensionSupported(packedDepthStencilExtensionSupported) , m_fbo(0) , m_colorBuffer(0) , m_depthStencilBuffer(0) + , m_depthBuffer(0) + , m_stencilBuffer(0) , m_multisampleFBO(0) , m_multisampleColorBuffer(0) - , m_multisampleDepthStencilBuffer(0) , m_internal(new DrawingBufferInternal) { if (!m_context->getExtensions()->supports("GL_CHROMIUM_copy_texture_to_parent_texture")) { @@ -91,6 +92,7 @@ DrawingBuffer::DrawingBuffer(GraphicsContext3D* context, context->bindFramebuffer(GraphicsContext3D::FRAMEBUFFER, m_fbo); m_colorBuffer = generateColorTexture(context, size); createSecondaryBuffers(); + reset(size); } DrawingBuffer::~DrawingBuffer() diff --git a/Source/WebCore/platform/graphics/chromium/FontCacheChromiumWin.cpp b/Source/WebCore/platform/graphics/chromium/FontCacheChromiumWin.cpp index 2c79815..f4c0dee 100644 --- a/Source/WebCore/platform/graphics/chromium/FontCacheChromiumWin.cpp +++ b/Source/WebCore/platform/graphics/chromium/FontCacheChromiumWin.cpp @@ -32,11 +32,11 @@ #include "config.h" #include "FontCache.h" -#include "ChromiumBridge.h" #include "Font.h" #include "FontUtilsChromiumWin.h" #include "HashMap.h" #include "HashSet.h" +#include "PlatformBridge.h" #include "SimpleFontData.h" #include <unicode/uniset.h> #include <wtf/text/StringHash.h> @@ -288,9 +288,9 @@ static bool fontContainsCharacter(const FontPlatformData* fontData, HDC hdc = GetDC(0); HGDIOBJ oldFont = static_cast<HFONT>(SelectObject(hdc, hfont)); int count = GetFontUnicodeRanges(hdc, 0); - if (count == 0 && ChromiumBridge::ensureFontLoaded(hfont)) + if (!count && PlatformBridge::ensureFontLoaded(hfont)) count = GetFontUnicodeRanges(hdc, 0); - if (count == 0) { + if (!count) { LOG_ERROR("Unable to get the font unicode range after second attempt"); SelectObject(hdc, oldFont); ReleaseDC(0, hdc); @@ -362,7 +362,7 @@ static void FillLogFont(const FontDescription& fontDescription, LOGFONT* winfont winfont->lfStrikeOut = false; winfont->lfCharSet = DEFAULT_CHARSET; winfont->lfOutPrecision = OUT_TT_ONLY_PRECIS; - winfont->lfQuality = ChromiumBridge::layoutTestMode() ? NONANTIALIASED_QUALITY : DEFAULT_QUALITY; // Honor user's desktop settings. + winfont->lfQuality = PlatformBridge::layoutTestMode() ? NONANTIALIASED_QUALITY : DEFAULT_QUALITY; // Honor user's desktop settings. winfont->lfPitchAndFamily = DEFAULT_PITCH | FF_DONTCARE; winfont->lfItalic = fontDescription.italic(); winfont->lfWeight = toGDIFontWeight(fontDescription.weight()); diff --git a/Source/WebCore/platform/graphics/chromium/FontCacheLinux.cpp b/Source/WebCore/platform/graphics/chromium/FontCacheLinux.cpp index bd33927..a849a6c 100644 --- a/Source/WebCore/platform/graphics/chromium/FontCacheLinux.cpp +++ b/Source/WebCore/platform/graphics/chromium/FontCacheLinux.cpp @@ -31,12 +31,12 @@ #include "config.h" #include "FontCache.h" -#include "ChromiumBridge.h" #include "Font.h" #include "FontDescription.h" #include "FontPlatformData.h" #include "Logging.h" #include "NotImplemented.h" +#include "PlatformBridge.h" #include "SimpleFontData.h" #include "SkPaint.h" @@ -57,7 +57,7 @@ const SimpleFontData* FontCache::getFontDataForCharacters(const Font& font, const UChar* characters, int length) { - String family = ChromiumBridge::getFontFamilyForCharacters(characters, length); + String family = PlatformBridge::getFontFamilyForCharacters(characters, length); if (family.isEmpty()) return 0; diff --git a/Source/WebCore/platform/graphics/chromium/FontChromiumWin.cpp b/Source/WebCore/platform/graphics/chromium/FontChromiumWin.cpp index 1a00833..5da4d5a 100644 --- a/Source/WebCore/platform/graphics/chromium/FontChromiumWin.cpp +++ b/Source/WebCore/platform/graphics/chromium/FontChromiumWin.cpp @@ -32,10 +32,10 @@ #include "config.h" #include "Font.h" -#include "ChromiumBridge.h" #include "FontFallbackList.h" #include "GlyphBuffer.h" #include "NotImplemented.h" +#include "PlatformBridge.h" #include "PlatformContextSkia.h" #include "SimpleFontData.h" #include "SkiaFontWin.h" @@ -424,7 +424,7 @@ void Font::drawGlyphs(GraphicsContext* graphicsContext, success = painter.drawGlyphs(curLen, &glyphs[0], &advances[0], curAdvance); if (!success && executions == 0) { // Ask the browser to load the font for us and retry. - ChromiumBridge::ensureFontLoaded(font->platformData().hfont()); + PlatformBridge::ensureFontLoaded(font->platformData().hfont()); continue; } break; diff --git a/Source/WebCore/platform/graphics/chromium/FontLinux.cpp b/Source/WebCore/platform/graphics/chromium/FontLinux.cpp index f1eadf2..822bbbb 100644 --- a/Source/WebCore/platform/graphics/chromium/FontLinux.cpp +++ b/Source/WebCore/platform/graphics/chromium/FontLinux.cpp @@ -206,6 +206,16 @@ void Font::drawComplexText(GraphicsContext* gc, const TextRun& run, controller.setLetterSpacingAdjustment(letterSpacing()); controller.setPadding(run.padding()); + if (run.rtl()) { + // FIXME: this causes us to shape the text twice -- once to compute the width and then again + // below when actually rendering. Change ComplexTextController to match platform/mac and + // platform/chromium/win by having it store the shaped runs, so we can reuse the results. + controller.reset(point.x() + controller.widthOfFullRun()); + // We need to set the padding again because ComplexTextController layout consumed the value. + // Fixing the above problem would help here too. + controller.setPadding(run.padding()); + } + while (controller.nextScriptRun()) { if (fill) { controller.fontPlatformDataForScriptRun()->setupPaint(&fillPaint); @@ -231,6 +241,7 @@ float Font::floatWidthForComplexText(const TextRun& run, HashSet<const SimpleFon ComplexTextController controller(run, 0, this); controller.setWordSpacingAdjustment(wordSpacing()); controller.setLetterSpacingAdjustment(letterSpacing()); + controller.setPadding(run.padding()); return controller.widthOfFullRun(); } @@ -239,7 +250,7 @@ static int glyphIndexForXPositionInScriptRun(const ComplexTextController& contro // Iterate through the glyphs in logical order, seeing whether targetX falls between the previous // position and halfway through the current glyph. // FIXME: this code probably belongs in ComplexTextController. - int lastX = controller.rtl() ? controller.width() : 0; + int lastX = controller.offsetX() - (controller.rtl() ? -controller.width() : controller.width()); for (int glyphIndex = 0; static_cast<unsigned>(glyphIndex) < controller.length(); ++glyphIndex) { int advance = truncateFixedPointToInteger(controller.advances()[glyphIndex]); int nextX = static_cast<int>(controller.xPositions()[glyphIndex]) + advance / 2; @@ -257,53 +268,29 @@ int Font::offsetForPositionForComplexText(const TextRun& run, float xFloat, { // FIXME: This truncation is not a problem for HTML, but only affects SVG, which passes floating-point numbers // to Font::offsetForPosition(). Bug http://webkit.org/b/40673 tracks fixing this problem. - int x = static_cast<int>(xFloat); + int targetX = static_cast<int>(xFloat); // (Mac code ignores includePartialGlyphs, and they don't know what it's // supposed to do, so we just ignore it as well.) ComplexTextController controller(run, 0, this); controller.setWordSpacingAdjustment(wordSpacing()); controller.setLetterSpacingAdjustment(letterSpacing()); - - // If this is RTL text, the first glyph from the left is actually the last - // code point. So we need to know how many code points there are total in - // order to subtract. This is different from the length of the TextRun - // because UTF-16 surrogate pairs are a single code point, but 32-bits long. - // In LTR we leave this as 0 so that we get the correct value for - // |basePosition|, below. - unsigned totalCodePoints = 0; - if (controller.rtl()) { - ssize_t offset = 0; - while (offset < run.length()) { - utf16_to_code_point(run.characters(), run.length(), &offset); - totalCodePoints++; - } + controller.setPadding(run.padding()); + if (run.rtl()) { + // See FIXME in drawComplexText. + controller.reset(controller.widthOfFullRun()); + controller.setPadding(run.padding()); } - unsigned basePosition = totalCodePoints; - - // For RTL: - // code-point order: abcd efg hijkl - // on screen: lkjih gfe dcba - // ^ ^ - // | | - // basePosition--| | - // totalCodePoints----| - // Since basePosition is currently the total number of code-points, the - // first thing we do is decrement it so that it's pointing to the start of - // the current script-run. - // - // For LTR, basePosition is zero so it already points to the start of the - // first script run. + unsigned basePosition = 0; + + int x = controller.offsetX(); while (controller.nextScriptRun()) { - if (controller.rtl()) - basePosition -= controller.numCodePoints(); + int nextX = controller.offsetX(); - if (x >= 0 && static_cast<unsigned>(x) < controller.width()) { - // The x value in question is within this script run. We consider - // each glyph in presentation order and stop when we find the one - // covering this position. - const int glyphIndex = glyphIndexForXPositionInScriptRun(controller, x); + if (std::min(x, nextX) <= targetX && targetX <= std::max(x, nextX)) { + // The x value in question is within this script run. + const int glyphIndex = glyphIndexForXPositionInScriptRun(controller, targetX); // Now that we have a glyph index, we have to turn that into a // code-point index. Because of ligatures, several code-points may @@ -324,10 +311,7 @@ int Font::offsetForPositionForComplexText(const TextRun& run, float xFloat, return basePosition + controller.numCodePoints() - 1; } - x -= controller.width(); - - if (!controller.rtl()) - basePosition += controller.numCodePoints(); + basePosition += controller.numCodePoints(); } return basePosition; @@ -342,27 +326,21 @@ FloatRect Font::selectionRectForComplexText(const TextRun& run, ComplexTextController controller(run, 0, this); controller.setWordSpacingAdjustment(wordSpacing()); controller.setLetterSpacingAdjustment(letterSpacing()); + controller.setPadding(run.padding()); + if (run.rtl()) { + // See FIXME in drawComplexText. + controller.reset(controller.widthOfFullRun()); + controller.setPadding(run.padding()); + } - // Base will point to the x offset for the start of the current script run. Note that, in - // the LTR case, width will be 0. - int base = controller.rtl() ? controller.widthOfFullRun() : 0; - - controller.reset(); + // Iterate through the script runs in logical order, searching for the run covering the positions of interest. while (controller.nextScriptRun() && (fromX == -1 || toX == -1)) { - // ComplexTextController will helpfully accululate the x offsets for different - // script runs for us. For this code, however, we always want the x offsets - // to start from zero so we call this before each script run. - controller.setXOffsetToZero(); - - if (controller.rtl()) - base -= controller.width(); - if (fromX == -1 && from >= 0 && static_cast<unsigned>(from) < controller.numCodePoints()) { // |from| is within this script run. So we index the clusters log to // find which glyph this code-point contributed to and find its x // position. int glyph = controller.logClusters()[from]; - fromX = base + controller.xPositions()[glyph]; + fromX = controller.xPositions()[glyph]; if (controller.rtl()) fromX += truncateFixedPointToInteger(controller.advances()[glyph]); } else @@ -370,22 +348,18 @@ FloatRect Font::selectionRectForComplexText(const TextRun& run, if (toX == -1 && to >= 0 && static_cast<unsigned>(to) < controller.numCodePoints()) { int glyph = controller.logClusters()[to]; - toX = base + controller.xPositions()[glyph]; + toX = controller.xPositions()[glyph]; if (controller.rtl()) toX += truncateFixedPointToInteger(controller.advances()[glyph]); } else to -= controller.numCodePoints(); - - if (!controller.rtl()) - base += controller.width(); } // The position in question might be just after the text. - const int endEdge = base; - if (fromX == -1 && !from) - fromX = endEdge; - if (toX == -1 && !to) - toX = endEdge; + if (fromX == -1) + fromX = controller.offsetX(); + if (toX == -1) + toX = controller.offsetX(); ASSERT(fromX != -1 && toX != -1); diff --git a/Source/WebCore/platform/graphics/chromium/FontPlatformDataChromiumWin.cpp b/Source/WebCore/platform/graphics/chromium/FontPlatformDataChromiumWin.cpp index d6c83ec..1022a9f 100644 --- a/Source/WebCore/platform/graphics/chromium/FontPlatformDataChromiumWin.cpp +++ b/Source/WebCore/platform/graphics/chromium/FontPlatformDataChromiumWin.cpp @@ -36,7 +36,7 @@ #include <objidl.h> #include <mlang.h> -#include "ChromiumBridge.h" +#include "PlatformBridge.h" #include "SkiaFontWin.h" namespace WebCore { @@ -136,7 +136,7 @@ SCRIPT_FONTPROPERTIES* FontPlatformData::scriptFontProperties() const HRESULT hr = ScriptGetFontProperties(dc, scriptCache(), m_scriptFontProperties); if (S_OK != hr) { - if (ChromiumBridge::ensureFontLoaded(hfont())) { + if (PlatformBridge::ensureFontLoaded(hfont())) { // FIXME: Handle gracefully the error if this call also fails. hr = ScriptGetFontProperties(dc, scriptCache(), m_scriptFontProperties); diff --git a/Source/WebCore/platform/graphics/chromium/FontPlatformDataLinux.cpp b/Source/WebCore/platform/graphics/chromium/FontPlatformDataLinux.cpp index 42942cc..a1ea012 100644 --- a/Source/WebCore/platform/graphics/chromium/FontPlatformDataLinux.cpp +++ b/Source/WebCore/platform/graphics/chromium/FontPlatformDataLinux.cpp @@ -31,9 +31,9 @@ #include "config.h" #include "FontPlatformData.h" -#include "ChromiumBridge.h" #include "HarfbuzzSkia.h" #include "NotImplemented.h" +#include "PlatformBridge.h" #include "PlatformString.h" #include "SkPaint.h" @@ -229,7 +229,7 @@ void FontPlatformData::querySystemForRenderStyle() return; } - ChromiumBridge::getRenderStyleForStrike(m_family.data(), (((int)m_textSize) << 2) | (m_typeface->style() & 3), &m_style); + PlatformBridge::getRenderStyleForStrike(m_family.data(), (((int)m_textSize) << 2) | (m_typeface->style() & 3), &m_style); } } // namespace WebCore diff --git a/Source/WebCore/platform/graphics/chromium/GLES2Canvas.cpp b/Source/WebCore/platform/graphics/chromium/GLES2Canvas.cpp index 697cf5e..4393f97 100644 --- a/Source/WebCore/platform/graphics/chromium/GLES2Canvas.cpp +++ b/Source/WebCore/platform/graphics/chromium/GLES2Canvas.cpp @@ -34,12 +34,16 @@ #include "DrawingBuffer.h" #include "FloatRect.h" +#include "FloatSize.h" #include "GraphicsContext3D.h" +#include "internal_glu.h" #include "IntRect.h" +#include "Path.h" #include "PlatformString.h" #include "SharedGraphicsContext3D.h" -#include "SolidFillShader.h" -#include "TexShader.h" +#if PLATFORM(SKIA) +#include "SkPath.h" +#endif #include "Texture.h" #define _USE_MATH_DEFINES @@ -50,17 +54,99 @@ namespace WebCore { +// Number of line segments used to approximate bezier curves. +const int pathTesselation = 30; +typedef void (GLAPIENTRY *TESSCB)(); +typedef WTF::Vector<float> FloatVector; +typedef WTF::Vector<double> DoubleVector; + struct GLES2Canvas::State { State() : m_fillColor(0, 0, 0, 255) , m_alpha(1.0f) , m_compositeOp(CompositeSourceOver) + , m_clippingEnabled(false) + { + } + State(const State& other) + : m_fillColor(other.m_fillColor) + , m_alpha(other.m_alpha) + , m_compositeOp(other.m_compositeOp) + , m_ctm(other.m_ctm) + , m_clippingPaths() // Don't copy; clipping paths are tracked per-state. + , m_clippingEnabled(other.m_clippingEnabled) { } Color m_fillColor; float m_alpha; CompositeOperator m_compositeOp; AffineTransform m_ctm; + WTF::Vector<Path> m_clippingPaths; + bool m_clippingEnabled; +}; + +static inline FloatPoint operator*(const FloatPoint& f, float scale) +{ + return FloatPoint(f.x() * scale, f.y() * scale); +} + +static inline FloatPoint operator*(float scale, const FloatPoint& f) +{ + return FloatPoint(f.x() * scale, f.y() * scale); +} + +static inline FloatSize operator*(const FloatSize& f, float scale) +{ + return FloatSize(f.width() * scale, f.height() * scale); +} + +static inline FloatSize operator*(float scale, const FloatSize& f) +{ + return FloatSize(f.width() * scale, f.height() * scale); +} + +class Quadratic { + public: + Quadratic(FloatPoint a, FloatPoint b, FloatPoint c) : + m_a(a), m_b(b), m_c(c) + { + } + static Quadratic fromBezier(FloatPoint p0, FloatPoint p1, FloatPoint p2) + { + FloatSize p1s(p1.x(), p1.y()); + FloatSize p2s(p2.x(), p2.y()); + FloatPoint b = -2.0f * p0 + 2.0f * p1s; + FloatPoint c = p0 - 2.0f * p1s + p2s; + return Quadratic(p0, b, c); + } + inline FloatPoint evaluate(float t) + { + return m_a + t * (m_b + t * m_c); + } + FloatPoint m_a, m_b, m_c, m_d; +}; + +class Cubic { + public: + Cubic(FloatPoint a, FloatPoint b, FloatPoint c, FloatPoint d) : + m_a(a), m_b(b), m_c(c), m_d(d) + { + } + static Cubic fromBezier(FloatPoint p0, FloatPoint p1, FloatPoint p2, FloatPoint p3) + { + FloatSize p1s(p1.x(), p1.y()); + FloatSize p2s(p2.x(), p2.y()); + FloatSize p3s(p3.x(), p3.y()); + FloatPoint b = -3.0f * p0 + 3.0f * p1s; + FloatPoint c = 3.0f * p0 - 6.0f * p1s + 3.0f * p2s; + FloatPoint d = -1.0f * p0 + 3.0f * p1s - 3.0f * p2s + p3s; + return Cubic(p0, b, c, d); + } + FloatPoint evaluate(float t) + { + return m_a + t * (m_b + t * (m_c + t * m_d)); + } + FloatPoint m_a, m_b, m_c, m_d; }; GLES2Canvas::GLES2Canvas(SharedGraphicsContext3D* context, DrawingBuffer* drawingBuffer, const IntSize& size) @@ -88,7 +174,7 @@ void GLES2Canvas::bindFramebuffer() void GLES2Canvas::clearRect(const FloatRect& rect) { bindFramebuffer(); - if (m_state->m_ctm.isIdentity()) { + if (m_state->m_ctm.isIdentity() && !m_state->m_clippingEnabled) { m_context->scissor(rect); m_context->enable(GraphicsContext3D::SCISSOR_TEST); m_context->clearColor(Color(RGBA32(0))); @@ -102,13 +188,21 @@ void GLES2Canvas::clearRect(const FloatRect& rect) } } +void GLES2Canvas::fillPath(const Path& path) +{ + m_context->applyCompositeOperator(m_state->m_compositeOp); + applyClipping(m_state->m_clippingEnabled); + fillPath(path, m_state->m_fillColor); +} + void GLES2Canvas::fillRect(const FloatRect& rect, const Color& color, ColorSpace colorSpace) { m_context->applyCompositeOperator(m_state->m_compositeOp); + applyClipping(m_state->m_clippingEnabled); m_context->useQuadVertices(); AffineTransform matrix(m_flipMatrix); - matrix.multLeft(m_state->m_ctm); + matrix *= m_state->m_ctm; matrix.translate(rect.x(), rect.y()); matrix.scale(rect.width(), rect.height()); @@ -150,7 +244,24 @@ void GLES2Canvas::scale(const FloatSize& size) void GLES2Canvas::concatCTM(const AffineTransform& affine) { - m_state->m_ctm.multLeft(affine); + m_state->m_ctm *= affine; +} + +void GLES2Canvas::clipPath(const Path& path) +{ + bindFramebuffer(); + checkGLError("bindFramebuffer"); + beginStencilDraw(); + // Red is used so we can see it if it ends up in the color buffer. + Color red(255, 0, 0, 255); + fillPath(path, red); + m_state->m_clippingPaths.append(path); + m_state->m_clippingEnabled = true; +} + +void GLES2Canvas::clipOut(const Path& path) +{ + ASSERT(!"clipOut is unsupported in GLES2Canvas.\n"); } void GLES2Canvas::save() @@ -162,13 +273,30 @@ void GLES2Canvas::save() void GLES2Canvas::restore() { ASSERT(!m_stateStack.isEmpty()); + bool hadClippingPaths = !m_state->m_clippingPaths.isEmpty(); m_stateStack.removeLast(); m_state = &m_stateStack.last(); + if (hadClippingPaths) { + m_context->clear(GraphicsContext3D::STENCIL_BUFFER_BIT); + beginStencilDraw(); + StateVector::const_iterator iter; + for (iter = m_stateStack.begin(); iter < m_stateStack.end(); ++iter) { + const State& state = *iter; + const Vector<Path>& clippingPaths = state.m_clippingPaths; + Vector<Path>::const_iterator pathIter; + for (pathIter = clippingPaths.begin(); pathIter < clippingPaths.end(); ++pathIter) { + // Red is used so we can see it if it ends up in the color buffer. + Color red(255, 0, 0, 255); + fillPath(*pathIter, red); + } + } + } } void GLES2Canvas::drawTexturedRect(unsigned texture, const IntSize& textureSize, const FloatRect& srcRect, const FloatRect& dstRect, ColorSpace colorSpace, CompositeOperator compositeOp) { m_context->applyCompositeOperator(compositeOp); + applyClipping(false); m_context->useQuadVertices(); m_context->setActiveTexture(GraphicsContext3D::TEXTURE0); @@ -180,13 +308,14 @@ void GLES2Canvas::drawTexturedRect(unsigned texture, const IntSize& textureSize, void GLES2Canvas::drawTexturedRect(Texture* texture, const FloatRect& srcRect, const FloatRect& dstRect, ColorSpace colorSpace, CompositeOperator compositeOp) { - drawTexturedRect(texture, srcRect, dstRect, m_state->m_ctm, m_state->m_alpha, colorSpace, compositeOp); + drawTexturedRect(texture, srcRect, dstRect, m_state->m_ctm, m_state->m_alpha, colorSpace, compositeOp, m_state->m_clippingEnabled); } -void GLES2Canvas::drawTexturedRect(Texture* texture, const FloatRect& srcRect, const FloatRect& dstRect, const AffineTransform& transform, float alpha, ColorSpace colorSpace, CompositeOperator compositeOp) +void GLES2Canvas::drawTexturedRect(Texture* texture, const FloatRect& srcRect, const FloatRect& dstRect, const AffineTransform& transform, float alpha, ColorSpace colorSpace, CompositeOperator compositeOp, bool clip) { m_context->applyCompositeOperator(compositeOp); + applyClipping(clip); const TilingData& tiles = texture->tiles(); IntRect tileIdxRect = tiles.overlappedTileIndices(srcRect); @@ -220,7 +349,7 @@ void GLES2Canvas::drawTexturedRectTile(Texture* texture, int tile, const FloatRe void GLES2Canvas::drawQuad(const IntSize& textureSize, const FloatRect& srcRect, const FloatRect& dstRect, const AffineTransform& transform, float alpha) { AffineTransform matrix(m_flipMatrix); - matrix.multLeft(transform); + matrix *= transform; matrix.translate(dstRect.x(), dstRect.y()); matrix.scale(dstRect.width(), dstRect.height()); @@ -251,6 +380,214 @@ Texture* GLES2Canvas::getTexture(NativeImagePtr ptr) return m_context->getTexture(ptr); } +#if PLATFORM(SKIA) +// This is actually cross-platform code, but since its only caller is inside a +// PLATFORM(SKIA), it will cause a warning-as-error on Chrome/Mac. +static void interpolateQuadratic(DoubleVector* vertices, const FloatPoint& p0, const FloatPoint& p1, const FloatPoint& p2) +{ + float tIncrement = 1.0f / pathTesselation, t = tIncrement; + Quadratic c = Quadratic::fromBezier(p0, p1, p2); + for (int i = 0; i < pathTesselation; ++i, t += tIncrement) { + FloatPoint p = c.evaluate(t); + vertices->append(p.x()); + vertices->append(p.y()); + vertices->append(1.0); + } +} + +static void interpolateCubic(DoubleVector* vertices, const FloatPoint& p0, const FloatPoint& p1, const FloatPoint& p2, const FloatPoint& p3) +{ + float tIncrement = 1.0f / pathTesselation, t = tIncrement; + Cubic c = Cubic::fromBezier(p0, p1, p2, p3); + for (int i = 0; i < pathTesselation; ++i, t += tIncrement) { + FloatPoint p = c.evaluate(t); + vertices->append(p.x()); + vertices->append(p.y()); + vertices->append(1.0); + } +} +#endif + +struct PolygonData { + PolygonData(FloatVector* vertices, WTF::Vector<short>* indices) + : m_vertices(vertices) + , m_indices(indices) + { + } + FloatVector* m_vertices; + WTF::Vector<short>* m_indices; +}; + +static void beginData(GLenum type, void* data) +{ + ASSERT(type == GL_TRIANGLES); +} + +static void edgeFlagData(GLboolean flag, void* data) +{ +} + +static void vertexData(void* vertexData, void* data) +{ + static_cast<PolygonData*>(data)->m_indices->append(reinterpret_cast<long>(vertexData)); +} + +static void endData(void* data) +{ +} + +static void combineData(GLdouble coords[3], void* vertexData[4], + GLfloat weight[4], void **outData, void* data) +{ + PolygonData* polygonData = static_cast<PolygonData*>(data); + int index = polygonData->m_vertices->size() / 3; + polygonData->m_vertices->append(static_cast<float>(coords[0])); + polygonData->m_vertices->append(static_cast<float>(coords[1])); + polygonData->m_vertices->append(1.0f); + *outData = reinterpret_cast<void*>(index); +} + +typedef void (*TESSCB)(); + +void GLES2Canvas::createVertexBufferFromPath(const Path& path, int* count, unsigned* vertexBuffer, unsigned* indexBuffer) +{ + *vertexBuffer = m_context->graphicsContext3D()->createBuffer(); + checkGLError("createVertexBufferFromPath, createBuffer"); + *indexBuffer = m_context->graphicsContext3D()->createBuffer(); + checkGLError("createVertexBufferFromPath, createBuffer"); + DoubleVector inVertices; + WTF::Vector<size_t> contours; +#if PLATFORM(SKIA) + const SkPath* skPath = path.platformPath(); + SkPoint pts[4]; + SkPath::Iter iter(*skPath, true); + SkPath::Verb verb; + while ((verb = iter.next(pts)) != SkPath::kDone_Verb) { + switch (verb) { + case SkPath::kMove_Verb: + inVertices.append(pts[0].fX); + inVertices.append(pts[0].fY); + inVertices.append(1.0); + break; + case SkPath::kLine_Verb: + inVertices.append(pts[1].fX); + inVertices.append(pts[1].fY); + inVertices.append(1.0); + break; + case SkPath::kQuad_Verb: + interpolateQuadratic(&inVertices, pts[0], pts[1], pts[2]); + break; + case SkPath::kCubic_Verb: + interpolateCubic(&inVertices, pts[0], pts[1], pts[2], pts[3]); + break; + case SkPath::kClose_Verb: + contours.append(inVertices.size() / 3); + break; + case SkPath::kDone_Verb: + break; + } + } +#else + ASSERT(!"Path extraction not implemented on this platform."); +#endif + + GLUtesselator* tess = internal_gluNewTess(); + internal_gluTessProperty(tess, GLU_TESS_WINDING_RULE, GLU_TESS_WINDING_NONZERO); + internal_gluTessCallback(tess, GLU_TESS_BEGIN_DATA, (TESSCB) &beginData); + internal_gluTessCallback(tess, GLU_TESS_VERTEX_DATA, (TESSCB) &vertexData); + internal_gluTessCallback(tess, GLU_TESS_END_DATA, (TESSCB) &endData); + internal_gluTessCallback(tess, GLU_TESS_EDGE_FLAG_DATA, (TESSCB) &edgeFlagData); + internal_gluTessCallback(tess, GLU_TESS_COMBINE_DATA, (TESSCB) &combineData); + WTF::Vector<short> indices; + FloatVector vertices; + vertices.reserveInitialCapacity(inVertices.size()); + PolygonData data(&vertices, &indices); + internal_gluTessBeginPolygon(tess, &data); + WTF::Vector<size_t>::const_iterator contour; + size_t i = 0; + for (contour = contours.begin(); contour != contours.end(); ++contour) { + internal_gluTessBeginContour(tess); + for (; i < *contour; ++i) { + vertices.append(inVertices[i * 3]); + vertices.append(inVertices[i * 3 + 1]); + vertices.append(1.0f); + internal_gluTessVertex(tess, &inVertices[i * 3], reinterpret_cast<void*>(i)); + } + internal_gluTessEndContour(tess); + } + internal_gluTessEndPolygon(tess); + internal_gluDeleteTess(tess); + + m_context->graphicsContext3D()->bindBuffer(GraphicsContext3D::ARRAY_BUFFER, *vertexBuffer); + checkGLError("createVertexBufferFromPath, bindBuffer ARRAY_BUFFER"); + m_context->graphicsContext3D()->bufferData(GraphicsContext3D::ARRAY_BUFFER, vertices.size() * sizeof(float), vertices.data(), GraphicsContext3D::STREAM_DRAW); + checkGLError("createVertexBufferFromPath, bufferData ARRAY_BUFFER"); + + m_context->graphicsContext3D()->bindBuffer(GraphicsContext3D::ELEMENT_ARRAY_BUFFER, *indexBuffer); + checkGLError("createVertexBufferFromPath, bindBuffer ELEMENT_ARRAY_BUFFER"); + m_context->graphicsContext3D()->bufferData(GraphicsContext3D::ELEMENT_ARRAY_BUFFER, indices.size() * sizeof(short), indices.data(), GraphicsContext3D::STREAM_DRAW); + checkGLError("createVertexBufferFromPath, bufferData ELEMENT_ARRAY_BUFFER"); + *count = indices.size(); +} + +void GLES2Canvas::fillPath(const Path& path, const Color& color) +{ + int count; + unsigned vertexBuffer, indexBuffer; + createVertexBufferFromPath(path, &count, &vertexBuffer, &indexBuffer); + m_context->graphicsContext3D()->bindBuffer(GraphicsContext3D::ARRAY_BUFFER, vertexBuffer); + checkGLError("bindBuffer"); + m_context->graphicsContext3D()->bindBuffer(GraphicsContext3D::ELEMENT_ARRAY_BUFFER, indexBuffer); + checkGLError("bindBuffer"); + + AffineTransform matrix(m_flipMatrix); + matrix *= m_state->m_ctm; + + m_context->useFillSolidProgram(matrix, color); + checkGLError("useFillSolidProgram"); + + m_context->graphicsContext3D()->drawElements(GraphicsContext3D::TRIANGLES, count, GraphicsContext3D::UNSIGNED_SHORT, 0); + checkGLError("drawArrays"); + + m_context->graphicsContext3D()->deleteBuffer(vertexBuffer); + checkGLError("deleteBuffer"); + + m_context->graphicsContext3D()->deleteBuffer(indexBuffer); + checkGLError("deleteBuffer"); +} + +void GLES2Canvas::beginStencilDraw() +{ + // Turn on stencil test. + m_context->enableStencil(true); + checkGLError("enable STENCIL_TEST"); + + // Stencil test never passes, so colorbuffer is not drawn. + m_context->graphicsContext3D()->stencilFunc(GraphicsContext3D::NEVER, 1, 1); + checkGLError("stencilFunc"); + + // All writes incremement the stencil buffer. + m_context->graphicsContext3D()->stencilOp(GraphicsContext3D::INCR, + GraphicsContext3D::INCR, + GraphicsContext3D::INCR); + checkGLError("stencilOp"); +} + +void GLES2Canvas::applyClipping(bool enable) +{ + m_context->enableStencil(enable); + if (enable) { + // Enable drawing only where stencil is non-zero. + m_context->graphicsContext3D()->stencilFunc(GraphicsContext3D::EQUAL, m_state->m_clippingPaths.size() % 256, 1); + checkGLError("stencilFunc"); + // Keep all stencil values the same. + m_context->graphicsContext3D()->stencilOp(GraphicsContext3D::KEEP, + GraphicsContext3D::KEEP, + GraphicsContext3D::KEEP); + checkGLError("stencilOp"); + } +} + void GLES2Canvas::checkGLError(const char* header) { #ifndef NDEBUG @@ -283,4 +620,3 @@ void GLES2Canvas::checkGLError(const char* header) } } - diff --git a/Source/WebCore/platform/graphics/chromium/GLES2Canvas.h b/Source/WebCore/platform/graphics/chromium/GLES2Canvas.h index 6fc1a0e..605f86f 100644 --- a/Source/WebCore/platform/graphics/chromium/GLES2Canvas.h +++ b/Source/WebCore/platform/graphics/chromium/GLES2Canvas.h @@ -48,13 +48,16 @@ class Color; class DrawingBuffer; class FloatRect; class GraphicsContext3D; +class Path; class SharedGraphicsContext3D; -class GLES2Canvas : public Noncopyable { +class GLES2Canvas { + WTF_MAKE_NONCOPYABLE(GLES2Canvas); public: GLES2Canvas(SharedGraphicsContext3D*, DrawingBuffer*, const IntSize&); ~GLES2Canvas(); + void fillPath(const Path&); void fillRect(const FloatRect&, const Color&, ColorSpace); void fillRect(const FloatRect&); void clearRect(const FloatRect&); @@ -65,6 +68,8 @@ public: void rotate(float angleInRadians); void scale(const FloatSize&); void concatCTM(const AffineTransform&); + void clipPath(const Path&); + void clipOut(const Path&); void save(); void restore(); @@ -72,9 +77,13 @@ public: // non-standard functions // These are not standard GraphicsContext functions, and should be pushed // down into a PlatformContextGLES2 at some point. + + // This version is called by the canvas->canvas draws. void drawTexturedRect(unsigned texture, const IntSize& textureSize, const FloatRect& srcRect, const FloatRect& dstRect, ColorSpace, CompositeOperator); - void drawTexturedRect(Texture*, const FloatRect& srcRect, const FloatRect& dstRect, const AffineTransform&, float alpha, ColorSpace, CompositeOperator); + // This version is called by BitmapImage::draw(). void drawTexturedRect(Texture*, const FloatRect& srcRect, const FloatRect& dstRect, ColorSpace, CompositeOperator); + // This version is called by the above, and by the software->hardware uploads. + void drawTexturedRect(Texture*, const FloatRect& srcRect, const FloatRect& dstRect, const AffineTransform&, float alpha, ColorSpace, CompositeOperator, bool clip); Texture* createTexture(NativeImagePtr, Texture::Format, int width, int height); Texture* getTexture(NativeImagePtr); @@ -88,6 +97,10 @@ private: void drawTexturedRectTile(Texture* texture, int tile, const FloatRect& srcRect, const FloatRect& dstRect, const AffineTransform&, float alpha); void drawQuad(const IntSize& textureSize, const FloatRect& srcRect, const FloatRect& dstRect, const AffineTransform&, float alpha); void applyCompositeOperator(CompositeOperator); + void createVertexBufferFromPath(const Path&, int* count, unsigned* vertexBuffer, unsigned* indexBuffer); + void fillPath(const Path&, const Color&); + void beginStencilDraw(); + void applyClipping(bool enable); void checkGLError(const char* header); IntSize m_size; @@ -96,7 +109,8 @@ private: DrawingBuffer* m_drawingBuffer; struct State; - WTF::Vector<State> m_stateStack; + typedef WTF::Vector<State> StateVector; + StateVector m_stateStack; State* m_state; AffineTransform m_flipMatrix; }; diff --git a/Source/WebCore/platform/graphics/chromium/GlyphPageTreeNodeChromiumWin.cpp b/Source/WebCore/platform/graphics/chromium/GlyphPageTreeNodeChromiumWin.cpp index e71f66a..ee2b5ab 100644 --- a/Source/WebCore/platform/graphics/chromium/GlyphPageTreeNodeChromiumWin.cpp +++ b/Source/WebCore/platform/graphics/chromium/GlyphPageTreeNodeChromiumWin.cpp @@ -32,9 +32,9 @@ #include <windows.h> #include <vector> -#include "ChromiumBridge.h" #include "Font.h" #include "GlyphPageTreeNode.h" +#include "PlatformBridge.h" #include "SimpleFontData.h" #include "UniscribeHelperTextRun.h" #include "WindowsVersion.h" @@ -80,12 +80,11 @@ static bool fillBMPGlyphs(unsigned offset, ReleaseDC(0, dc); if (recurse) { - if (ChromiumBridge::ensureFontLoaded(fontData->platformData().hfont())) + if (PlatformBridge::ensureFontLoaded(fontData->platformData().hfont())) return fillBMPGlyphs(offset, length, buffer, page, fontData, false); - else { - fillEmptyGlyphs(page); - return false; - } + + fillEmptyGlyphs(page); + return false; } else { // FIXME: Handle gracefully the error if this call also fails. // See http://crbug.com/6401 diff --git a/Source/WebCore/platform/graphics/chromium/ImageChromium.cpp b/Source/WebCore/platform/graphics/chromium/ImageChromium.cpp index e90d566..e2b6f7a 100644 --- a/Source/WebCore/platform/graphics/chromium/ImageChromium.cpp +++ b/Source/WebCore/platform/graphics/chromium/ImageChromium.cpp @@ -31,7 +31,7 @@ #include "config.h" #include "Image.h" -#include "ChromiumBridge.h" +#include "PlatformBridge.h" namespace WebCore { @@ -39,7 +39,7 @@ namespace WebCore { PassRefPtr<Image> Image::loadPlatformResource(const char *name) { - return ChromiumBridge::loadPlatformImageResource(name); + return PlatformBridge::loadPlatformImageResource(name); } } // namespace WebCore diff --git a/Source/WebCore/platform/graphics/chromium/ImageChromiumMac.mm b/Source/WebCore/platform/graphics/chromium/ImageChromiumMac.mm index 073a409..f003894 100644 --- a/Source/WebCore/platform/graphics/chromium/ImageChromiumMac.mm +++ b/Source/WebCore/platform/graphics/chromium/ImageChromiumMac.mm @@ -33,14 +33,14 @@ #include "config.h" #include "BitmapImage.h" -#include "ChromiumBridge.h" #include "Image.h" +#include "PlatformBridge.h" namespace WebCore { PassRefPtr<Image> Image::loadPlatformResource(const char* name) { - return ChromiumBridge::loadPlatformImageResource(name); + return PlatformBridge::loadPlatformImageResource(name); } // FIXME: These are temporary stubs, we need real implementations which diff --git a/Source/WebCore/platform/graphics/chromium/LayerRendererChromium.cpp b/Source/WebCore/platform/graphics/chromium/LayerRendererChromium.cpp index 8d77bea..90eac74 100644 --- a/Source/WebCore/platform/graphics/chromium/LayerRendererChromium.cpp +++ b/Source/WebCore/platform/graphics/chromium/LayerRendererChromium.cpp @@ -119,12 +119,6 @@ LayerRendererChromium::LayerRendererChromium(PassRefPtr<GraphicsContext3D> conte LayerRendererChromium::~LayerRendererChromium() { cleanupSharedObjects(); - - // Because the tilers need to clean up textures, clean them up explicitly - // before the GraphicsContext3D is destroyed. - m_rootLayerTiler.clear(); - m_horizontalScrollbarTiler.clear(); - m_verticalScrollbarTiler.clear(); } GraphicsContext3D* LayerRendererChromium::context() @@ -269,6 +263,9 @@ void LayerRendererChromium::drawLayers(const IntRect& visibleRect, const IntRect updateAndDrawRootLayer(tilePaint, scrollbarPaint, visibleRect, contentRect); + // Re-enable color writes to layers, which may be partially transparent. + m_context->colorMask(true, true, true, true); + // Set the root visible/content rects --- used by subsequent drawLayers calls. m_rootVisibleRect = visibleRect; m_rootContentRect = contentRect; @@ -795,6 +792,11 @@ void LayerRendererChromium::cleanupSharedObjects() if (m_offscreenFramebufferId) GLC(m_context.get(), m_context->deleteFramebuffer(m_offscreenFramebufferId)); + // Clear tilers before the texture manager, as they have references to textures. + m_rootLayerTiler.clear(); + m_horizontalScrollbarTiler.clear(); + m_verticalScrollbarTiler.clear(); + m_textureManager.clear(); } diff --git a/Source/WebCore/platform/graphics/chromium/LayerTexture.h b/Source/WebCore/platform/graphics/chromium/LayerTexture.h index 711e687..b60dff2 100644 --- a/Source/WebCore/platform/graphics/chromium/LayerTexture.h +++ b/Source/WebCore/platform/graphics/chromium/LayerTexture.h @@ -28,6 +28,7 @@ #include "IntSize.h" #include "TextureManager.h" +#include <wtf/FastAllocBase.h> #include <wtf/Noncopyable.h> #include <wtf/PassOwnPtr.h> #include <wtf/RefPtr.h> @@ -37,7 +38,8 @@ namespace WebCore { class GraphicsContext3D; class TextureManager; -class LayerTexture : public Noncopyable { +class LayerTexture { + WTF_MAKE_NONCOPYABLE(LayerTexture); WTF_MAKE_FAST_ALLOCATED; public: static PassOwnPtr<LayerTexture> create(GraphicsContext3D* context, TextureManager* manager) { diff --git a/Source/WebCore/platform/graphics/chromium/LayerTilerChromium.cpp b/Source/WebCore/platform/graphics/chromium/LayerTilerChromium.cpp index b4b4a72..6b65e66 100644 --- a/Source/WebCore/platform/graphics/chromium/LayerTilerChromium.cpp +++ b/Source/WebCore/platform/graphics/chromium/LayerTilerChromium.cpp @@ -33,6 +33,7 @@ #include "GraphicsContext.h" #include "GraphicsContext3D.h" #include "LayerRendererChromium.h" +#include "LayerTexture.h" #if PLATFORM(SKIA) #include "NativeImageSkia.h" @@ -54,7 +55,8 @@ PassOwnPtr<LayerTilerChromium> LayerTilerChromium::create(LayerRendererChromium* } LayerTilerChromium::LayerTilerChromium(LayerRendererChromium* layerRenderer, const IntSize& tileSize) - : m_layerRenderer(layerRenderer) + : m_skipsDraw(false) + , m_layerRenderer(layerRenderer) { setTileSize(tileSize); } @@ -83,17 +85,7 @@ void LayerTilerChromium::setTileSize(const IntSize& size) void LayerTilerChromium::reset() { - for (size_t i = 0; i < m_tiles.size(); ++i) { - if (!m_tiles[i]) - continue; - layerRenderer()->deleteLayerTexture(m_tiles[i]->releaseTextureId()); - } m_tiles.clear(); - for (size_t i = 0; i < m_unusedTiles.size(); ++i) { - if (!m_unusedTiles[i]) - continue; - layerRenderer()->deleteLayerTexture(m_unusedTiles[i]->releaseTextureId()); - } m_unusedTiles.clear(); m_layerSize = IntSize(); @@ -110,12 +102,9 @@ LayerTilerChromium::Tile* LayerTilerChromium::createTile(int i, int j) m_tiles[index] = m_unusedTiles.last().release(); m_unusedTiles.removeLast(); } else { - const unsigned int textureId = layerRenderer()->createLayerTexture(); - OwnPtr<Tile> tile = adoptPtr(new Tile(textureId)); - GraphicsContext3D* context = layerRendererContext(); - GLC(context, context->texImage2DResourceSafe(GraphicsContext3D::TEXTURE_2D, 0, GraphicsContext3D::RGBA, m_tileSize.width(), m_tileSize.height(), 0, GraphicsContext3D::RGBA, GraphicsContext3D::UNSIGNED_BYTE)); - + TextureManager* manager = layerRenderer()->textureManager(); + OwnPtr<Tile> tile = adoptPtr(new Tile(LayerTexture::create(context, manager))); m_tiles[index] = tile.release(); } @@ -238,6 +227,9 @@ void LayerTilerChromium::invalidateEntireLayer() void LayerTilerChromium::update(TilePaintInterface& painter, const IntRect& contentRect) { + if (m_skipsDraw) + return; + // Invalidate old tiles that were previously used but aren't in use this // frame so that they can get reused for new tiles. IntRect layerRect = contentRectToLayerRect(contentRect); @@ -256,6 +248,8 @@ void LayerTilerChromium::update(TilePaintInterface& painter, const IntRect& cont Tile* tile = m_tiles[tileIndex(i, j)].get(); if (!tile) tile = createTile(i, j); + if (!tile->texture()->isValid(m_tileSize, GraphicsContext3D::RGBA)) + tile->m_dirtyLayerRect = tileLayerRect(i, j); dirtyLayerRect.unite(tile->m_dirtyLayerRect); } } @@ -318,6 +312,12 @@ void LayerTilerChromium::update(TilePaintInterface& painter, const IntRect& cont if (sourceRect.isEmpty()) continue; + if (!tile->texture()->reserve(m_tileSize, GraphicsContext3D::RGBA)) { + m_skipsDraw = true; + reset(); + return; + } + // Calculate tile-space rectangle to upload into. IntRect destRect(IntPoint(sourceRect.x() - anchor.x(), sourceRect.y() - anchor.y()), sourceRect.size()); ASSERT(destRect.x() >= 0); @@ -342,7 +342,7 @@ void LayerTilerChromium::update(TilePaintInterface& painter, const IntRect& cont pixelSource = &m_tilePixels[0]; } - GLC(context, context->bindTexture(GraphicsContext3D::TEXTURE_2D, tile->textureId())); + tile->texture()->bindTexture(); GLC(context, context->texSubImage2D(GraphicsContext3D::TEXTURE_2D, 0, destRect.x(), destRect.y(), destRect.width(), destRect.height(), GraphicsContext3D::RGBA, GraphicsContext3D::UNSIGNED_BYTE, pixelSource)); tile->clearDirty(); @@ -357,6 +357,9 @@ void LayerTilerChromium::setLayerPosition(const IntPoint& layerPosition) void LayerTilerChromium::draw(const IntRect& contentRect) { + if (m_skipsDraw) + return; + // We reuse the shader program used by ContentLayerChromium. GraphicsContext3D* context = layerRendererContext(); const ContentLayerChromium::SharedValues* contentLayerValues = layerRenderer()->contentLayerSharedValues(); @@ -370,13 +373,15 @@ void LayerTilerChromium::draw(const IntRect& contentRect) Tile* tile = m_tiles[tileIndex(i, j)].get(); ASSERT(tile); - GLC(context, context->bindTexture(GraphicsContext3D::TEXTURE_2D, tile->textureId())); + tile->texture()->bindTexture(); TransformationMatrix tileMatrix; IntRect tileRect = tileContentRect(i, j); tileMatrix.translate3d(tileRect.x() - contentRect.x() + tileRect.width() / 2.0, tileRect.y() - contentRect.y() + tileRect.height() / 2.0, 0); LayerChromium::drawTexturedQuad(context, layerRenderer()->projectionMatrix(), tileMatrix, m_tileSize.width(), m_tileSize.height(), 1, contentLayerValues->shaderMatrixLocation(), contentLayerValues->shaderAlphaLocation()); + + tile->texture()->unreserve(); } } } @@ -410,21 +415,6 @@ void LayerTilerChromium::growLayerToContain(const IntRect& contentRect) resizeLayer(newSize); } -LayerTilerChromium::Tile::~Tile() -{ - // Each tile doesn't have a reference to the context, so can't clean up - // its own texture. If this assert is hit, then the LayerTilerChromium - // destructor didn't clean this up. - ASSERT(!m_textureId); -} - -unsigned int LayerTilerChromium::Tile::releaseTextureId() -{ - unsigned int id = m_textureId; - m_textureId = 0; - return id; -} - } // namespace WebCore #endif // USE(ACCELERATED_COMPOSITING) diff --git a/Source/WebCore/platform/graphics/chromium/LayerTilerChromium.h b/Source/WebCore/platform/graphics/chromium/LayerTilerChromium.h index c066fdf..e09693d 100644 --- a/Source/WebCore/platform/graphics/chromium/LayerTilerChromium.h +++ b/Source/WebCore/platform/graphics/chromium/LayerTilerChromium.h @@ -30,6 +30,7 @@ #if USE(ACCELERATED_COMPOSITING) #include "LayerChromium.h" +#include "LayerTexture.h" #include <wtf/OwnArrayPtr.h> namespace WebCore { @@ -42,7 +43,8 @@ public: virtual void paint(GraphicsContext& context, const IntRect& contentRect) = 0; }; -class LayerTilerChromium : public Noncopyable { +class LayerTilerChromium { + WTF_MAKE_NONCOPYABLE(LayerTilerChromium); public: static PassOwnPtr<LayerTilerChromium> create(LayerRendererChromium* layerRenderer, const IntSize& tileSize); @@ -62,12 +64,11 @@ private: LayerTilerChromium(LayerRendererChromium* layerRenderer, const IntSize& tileSize); class Tile { + WTF_MAKE_NONCOPYABLE(Tile); public: - explicit Tile(unsigned int textureId) : m_textureId(textureId) { } - ~Tile(); + explicit Tile(PassOwnPtr<LayerTexture> tex) : m_tex(tex) {} - unsigned int textureId() const { return m_textureId; } - unsigned int releaseTextureId(); + LayerTexture* texture() { return m_tex.get(); } bool dirty() const { return !m_dirtyLayerRect.isEmpty(); } void clearDirty() { m_dirtyLayerRect = IntRect(); } @@ -75,7 +76,7 @@ private: // Layer-space dirty rectangle that needs to be repainted. IntRect m_dirtyLayerRect; private: - unsigned int m_textureId; + OwnPtr<LayerTexture> m_tex; }; void resizeLayer(const IntSize& size); @@ -105,6 +106,8 @@ private: IntRect m_lastUpdateLayerRect; IntPoint m_layerPosition; + bool m_skipsDraw; + // Logical 2D array of tiles (dimensions of m_layerTileSize) Vector<OwnPtr<Tile> > m_tiles; // Linear array of unused tiles. diff --git a/Source/WebCore/platform/graphics/chromium/RenderSurfaceChromium.h b/Source/WebCore/platform/graphics/chromium/RenderSurfaceChromium.h index a93218f..689a6eb 100644 --- a/Source/WebCore/platform/graphics/chromium/RenderSurfaceChromium.h +++ b/Source/WebCore/platform/graphics/chromium/RenderSurfaceChromium.h @@ -41,7 +41,8 @@ class LayerChromium; class LayerRendererChromium; class LayerTexture; -class RenderSurfaceChromium : public Noncopyable { +class RenderSurfaceChromium { + WTF_MAKE_NONCOPYABLE(RenderSurfaceChromium); friend class LayerRendererChromium; public: explicit RenderSurfaceChromium(LayerChromium*); diff --git a/Source/WebCore/platform/graphics/chromium/SimpleFontDataChromiumWin.cpp b/Source/WebCore/platform/graphics/chromium/SimpleFontDataChromiumWin.cpp index 204c565..c23c586 100644 --- a/Source/WebCore/platform/graphics/chromium/SimpleFontDataChromiumWin.cpp +++ b/Source/WebCore/platform/graphics/chromium/SimpleFontDataChromiumWin.cpp @@ -32,11 +32,11 @@ #include "config.h" #include "SimpleFontData.h" -#include "ChromiumBridge.h" +#include "FloatRect.h" #include "Font.h" #include "FontCache.h" -#include "FloatRect.h" #include "FontDescription.h" +#include "PlatformBridge.h" #include <wtf/MathExtras.h> #include <unicode/uchar.h> @@ -70,7 +70,7 @@ void SimpleFontData::platformInit() TEXTMETRIC textMetric = {0}; if (!GetTextMetrics(dc, &textMetric)) { - if (ChromiumBridge::ensureFontLoaded(m_platformData.hfont())) { + if (PlatformBridge::ensureFontLoaded(m_platformData.hfont())) { // Retry GetTextMetrics. // FIXME: Handle gracefully the error if this call also fails. // See http://crbug.com/6401. @@ -159,7 +159,7 @@ void SimpleFontData::determinePitch() // is *not* fixed pitch. Unbelievable but true. TEXTMETRIC textMetric = {0}; if (!GetTextMetrics(dc, &textMetric)) { - if (ChromiumBridge::ensureFontLoaded(m_platformData.hfont())) { + if (PlatformBridge::ensureFontLoaded(m_platformData.hfont())) { // Retry GetTextMetrics. // FIXME: Handle gracefully the error if this call also fails. // See http://crbug.com/6401. @@ -190,7 +190,7 @@ float SimpleFontData::platformWidthForGlyph(Glyph glyph) const int width = 0; if (!GetCharWidthI(dc, glyph, 1, 0, &width)) { // Ask the browser to preload the font and retry. - if (ChromiumBridge::ensureFontLoaded(m_platformData.hfont())) { + if (PlatformBridge::ensureFontLoaded(m_platformData.hfont())) { // FIXME: Handle gracefully the error if this call also fails. // See http://crbug.com/6401. if (!GetCharWidthI(dc, glyph, 1, 0, &width)) diff --git a/Source/WebCore/platform/graphics/chromium/TextureManager.h b/Source/WebCore/platform/graphics/chromium/TextureManager.h index 4891cc7..83104a9 100644 --- a/Source/WebCore/platform/graphics/chromium/TextureManager.h +++ b/Source/WebCore/platform/graphics/chromium/TextureManager.h @@ -29,6 +29,7 @@ #include "IntRect.h" #include "IntSize.h" +#include <wtf/FastAllocBase.h> #include <wtf/HashMap.h> #include <wtf/ListHashSet.h> @@ -36,7 +37,8 @@ namespace WebCore { typedef int TextureToken; -class TextureManager : public Noncopyable { +class TextureManager { + WTF_MAKE_NONCOPYABLE(TextureManager); public: static PassOwnPtr<TextureManager> create(GraphicsContext3D* context, size_t memoryLimitBytes, int maxTextureSize) { diff --git a/Source/WebCore/platform/graphics/chromium/TransparencyWin.cpp b/Source/WebCore/platform/graphics/chromium/TransparencyWin.cpp index 4dc2157..ba66eae 100644 --- a/Source/WebCore/platform/graphics/chromium/TransparencyWin.cpp +++ b/Source/WebCore/platform/graphics/chromium/TransparencyWin.cpp @@ -252,7 +252,7 @@ void TransparencyWin::setupLayerForOpaqueCompositeLayer() if (m_transformMode == Untransform){ // Compute the inverse mapping from the canvas space to the // coordinate space of our bitmap. - mapping = m_orgTransform.inverse() * mapping; + mapping *= m_orgTransform.inverse(); } compositeToCopy(*m_destContext, *m_drawContext, mapping); @@ -313,7 +313,7 @@ void TransparencyWin::setupTransformForKeepTransform(const IntRect& region) // We're making a layer, so apply the old transform to the new one // so it's maintained. We know the new layer has the identity // transform now, we we can just multiply it. - xform = m_orgTransform * xform; + xform *= m_orgTransform; m_drawContext->concatCTM(xform); } m_drawRect = m_sourceRect; diff --git a/Source/WebCore/platform/graphics/chromium/TransparencyWin.h b/Source/WebCore/platform/graphics/chromium/TransparencyWin.h index b6bef91..535cbaa 100644 --- a/Source/WebCore/platform/graphics/chromium/TransparencyWin.h +++ b/Source/WebCore/platform/graphics/chromium/TransparencyWin.h @@ -54,7 +54,8 @@ class TransparencyWin_OpaqueCompositeLayer_Test; // that is composited later manually. This is to get around Windows' inability // to handle the alpha channel, semitransparent text, and transformed form // controls. -class TransparencyWin : public Noncopyable { +class TransparencyWin { + WTF_MAKE_NONCOPYABLE(TransparencyWin); public: enum LayerMode { // No extra layer is created. Drawing will happen to the source. diff --git a/Source/WebCore/platform/graphics/chromium/UniscribeHelperTextRun.cpp b/Source/WebCore/platform/graphics/chromium/UniscribeHelperTextRun.cpp index f801c13..aa18b4a 100644 --- a/Source/WebCore/platform/graphics/chromium/UniscribeHelperTextRun.cpp +++ b/Source/WebCore/platform/graphics/chromium/UniscribeHelperTextRun.cpp @@ -31,9 +31,10 @@ #include "config.h" #include "UniscribeHelperTextRun.h" -#include "ChromiumBridge.h" #include "Font.h" +#include "PlatformBridge.h" #include "SimpleFontData.h" +#include "TextRun.h" namespace WebCore { @@ -79,7 +80,7 @@ void UniscribeHelperTextRun::tryToPreloadFont(HFONT font) // Ask the browser to get the font metrics for this font. // That will preload the font and it should now be accessible // from the renderer. - ChromiumBridge::ensureFontLoaded(font); + PlatformBridge::ensureFontLoaded(font); } bool UniscribeHelperTextRun::nextWinFontData( diff --git a/Source/WebCore/platform/graphics/chromium/VideoLayerChromium.cpp b/Source/WebCore/platform/graphics/chromium/VideoLayerChromium.cpp index 81264b3..776b83f 100644 --- a/Source/WebCore/platform/graphics/chromium/VideoLayerChromium.cpp +++ b/Source/WebCore/platform/graphics/chromium/VideoLayerChromium.cpp @@ -264,6 +264,7 @@ unsigned VideoLayerChromium::determineTextureFormat(VideoFrameChromium* frame) { switch (frame->format()) { case VideoFrameChromium::YV12: + case VideoFrameChromium::YV16: return GraphicsContext3D::LUMINANCE; case VideoFrameChromium::RGBA: return GraphicsContext3D::RGBA; @@ -330,6 +331,7 @@ void VideoLayerChromium::draw() switch (m_frameFormat) { case VideoFrameChromium::YV12: + case VideoFrameChromium::YV16: drawYUV(sv); break; case VideoFrameChromium::RGBA: diff --git a/Source/WebCore/platform/graphics/gpu/DrawingBuffer.cpp b/Source/WebCore/platform/graphics/gpu/DrawingBuffer.cpp index c283068..dae83a2 100644 --- a/Source/WebCore/platform/graphics/gpu/DrawingBuffer.cpp +++ b/Source/WebCore/platform/graphics/gpu/DrawingBuffer.cpp @@ -67,16 +67,21 @@ void DrawingBuffer::clear() m_multisampleColorBuffer = 0; } - if (m_multisampleDepthStencilBuffer) { - m_context->deleteRenderbuffer(m_multisampleDepthStencilBuffer); - m_multisampleDepthStencilBuffer = 0; - } - if (m_depthStencilBuffer) { m_context->deleteRenderbuffer(m_depthStencilBuffer); m_depthStencilBuffer = 0; } + if (m_depthBuffer) { + m_context->deleteRenderbuffer(m_depthBuffer); + m_depthBuffer = 0; + } + + if (m_stencilBuffer) { + m_context->deleteRenderbuffer(m_stencilBuffer); + m_stencilBuffer = 0; + } + if (m_multisampleFBO) { m_context->bindFramebuffer(GraphicsContext3D::FRAMEBUFFER, m_multisampleFBO); m_context->deleteFramebuffer(m_multisampleFBO); @@ -92,22 +97,52 @@ void DrawingBuffer::clear() void DrawingBuffer::createSecondaryBuffers() { - const GraphicsContext3D::Attributes& attributes = m_context->getContextAttributes(); - - // Create the stencil and depth buffer if needed - if (!multisample() && (attributes.stencil || attributes.depth)) - m_depthStencilBuffer = m_context->createRenderbuffer(); - // create a multisample FBO if (multisample()) { m_multisampleFBO = m_context->createFramebuffer(); m_context->bindFramebuffer(GraphicsContext3D::FRAMEBUFFER, m_multisampleFBO); m_multisampleColorBuffer = m_context->createRenderbuffer(); - if (attributes.stencil || attributes.depth) - m_multisampleDepthStencilBuffer = m_context->createRenderbuffer(); } } +void DrawingBuffer::resizeDepthStencil(int sampleCount) +{ + const GraphicsContext3D::Attributes& attributes = m_context->getContextAttributes(); + if (attributes.depth && attributes.stencil && m_packedDepthStencilExtensionSupported) { + if (!m_depthStencilBuffer) + m_depthStencilBuffer = m_context->createRenderbuffer(); + m_context->bindRenderbuffer(GraphicsContext3D::RENDERBUFFER, m_depthStencilBuffer); + if (multisample()) + m_context->getExtensions()->renderbufferStorageMultisample(GraphicsContext3D::RENDERBUFFER, sampleCount, Extensions3D::DEPTH24_STENCIL8, m_size.width(), m_size.height()); + else + m_context->renderbufferStorage(GraphicsContext3D::RENDERBUFFER, Extensions3D::DEPTH24_STENCIL8, m_size.width(), m_size.height()); + m_context->framebufferRenderbuffer(GraphicsContext3D::FRAMEBUFFER, GraphicsContext3D::STENCIL_ATTACHMENT, GraphicsContext3D::RENDERBUFFER, m_depthStencilBuffer); + m_context->framebufferRenderbuffer(GraphicsContext3D::FRAMEBUFFER, GraphicsContext3D::DEPTH_ATTACHMENT, GraphicsContext3D::RENDERBUFFER, m_depthStencilBuffer); + } else { + if (attributes.depth) { + if (!m_depthBuffer) + m_depthBuffer = m_context->createRenderbuffer(); + m_context->bindRenderbuffer(GraphicsContext3D::RENDERBUFFER, m_depthBuffer); + if (multisample()) + m_context->getExtensions()->renderbufferStorageMultisample(GraphicsContext3D::RENDERBUFFER, sampleCount, GraphicsContext3D::DEPTH_COMPONENT16, m_size.width(), m_size.height()); + else + m_context->renderbufferStorage(GraphicsContext3D::RENDERBUFFER, GraphicsContext3D::DEPTH_COMPONENT16, m_size.width(), m_size.height()); + m_context->framebufferRenderbuffer(GraphicsContext3D::FRAMEBUFFER, GraphicsContext3D::DEPTH_ATTACHMENT, GraphicsContext3D::RENDERBUFFER, m_depthBuffer); + } + if (attributes.stencil) { + if (!m_stencilBuffer) + m_stencilBuffer = m_context->createRenderbuffer(); + m_context->bindRenderbuffer(GraphicsContext3D::RENDERBUFFER, m_stencilBuffer); + if (multisample()) + m_context->getExtensions()->renderbufferStorageMultisample(GraphicsContext3D::RENDERBUFFER, sampleCount, GraphicsContext3D::STENCIL_INDEX8, m_size.width(), m_size.height()); + else + m_context->renderbufferStorage(GraphicsContext3D::RENDERBUFFER, GraphicsContext3D::STENCIL_INDEX8, m_size.width(), m_size.height()); + m_context->framebufferRenderbuffer(GraphicsContext3D::FRAMEBUFFER, GraphicsContext3D::STENCIL_ATTACHMENT, GraphicsContext3D::RENDERBUFFER, m_stencilBuffer); + } + } + m_context->bindRenderbuffer(GraphicsContext3D::RENDERBUFFER, 0); +} + void DrawingBuffer::reset(const IntSize& newSize) { if (m_size == newSize) @@ -120,7 +155,7 @@ void DrawingBuffer::reset(const IntSize& newSize) m_context->makeContextCurrent(); const GraphicsContext3D::Attributes& attributes = m_context->getContextAttributes(); - unsigned long internalColorFormat, colorFormat, internalDepthStencilFormat = 0; + unsigned long internalColorFormat, colorFormat; if (attributes.alpha) { internalColorFormat = GraphicsContext3D::RGBA; colorFormat = GraphicsContext3D::RGBA; @@ -128,17 +163,7 @@ void DrawingBuffer::reset(const IntSize& newSize) internalColorFormat = GraphicsContext3D::RGB; colorFormat = GraphicsContext3D::RGB; } - if (attributes.stencil || attributes.depth) { - // We don't allow the logic where stencil is required and depth is not. - // See GraphicsContext3D constructor. - // FIXME: If packed depth/stencil is not supported, we should - // create separate renderbuffers for depth and stencil. - if (attributes.stencil && attributes.depth && m_packedDepthStencilExtensionSupported) - internalDepthStencilFormat = Extensions3D::DEPTH24_STENCIL8; - else - internalDepthStencilFormat = GraphicsContext3D::DEPTH_COMPONENT16; - } // resize multisample FBO if (multisample()) { @@ -152,15 +177,7 @@ void DrawingBuffer::reset(const IntSize& newSize) m_context->bindRenderbuffer(GraphicsContext3D::RENDERBUFFER, m_multisampleColorBuffer); m_context->getExtensions()->renderbufferStorageMultisample(GraphicsContext3D::RENDERBUFFER, sampleCount, internalColorFormat, m_size.width(), m_size.height()); m_context->framebufferRenderbuffer(GraphicsContext3D::FRAMEBUFFER, GraphicsContext3D::COLOR_ATTACHMENT0, GraphicsContext3D::RENDERBUFFER, m_multisampleColorBuffer); - if (attributes.stencil || attributes.depth) { - m_context->bindRenderbuffer(GraphicsContext3D::RENDERBUFFER, m_multisampleDepthStencilBuffer); - m_context->getExtensions()->renderbufferStorageMultisample(GraphicsContext3D::RENDERBUFFER, sampleCount, internalDepthStencilFormat, m_size.width(), m_size.height()); - if (attributes.stencil) - m_context->framebufferRenderbuffer(GraphicsContext3D::FRAMEBUFFER, GraphicsContext3D::STENCIL_ATTACHMENT, GraphicsContext3D::RENDERBUFFER, m_multisampleDepthStencilBuffer); - if (attributes.depth) - m_context->framebufferRenderbuffer(GraphicsContext3D::FRAMEBUFFER, GraphicsContext3D::DEPTH_ATTACHMENT, GraphicsContext3D::RENDERBUFFER, m_multisampleDepthStencilBuffer); - } - m_context->bindRenderbuffer(GraphicsContext3D::RENDERBUFFER, 0); + resizeDepthStencil(sampleCount); if (m_context->checkFramebufferStatus(GraphicsContext3D::FRAMEBUFFER) != GraphicsContext3D::FRAMEBUFFER_COMPLETE) { // Cleanup clear(); @@ -175,15 +192,7 @@ void DrawingBuffer::reset(const IntSize& newSize) m_context->texImage2DResourceSafe(GraphicsContext3D::TEXTURE_2D, 0, internalColorFormat, m_size.width(), m_size.height(), 0, colorFormat, GraphicsContext3D::UNSIGNED_BYTE); m_context->framebufferTexture2D(GraphicsContext3D::FRAMEBUFFER, GraphicsContext3D::COLOR_ATTACHMENT0, GraphicsContext3D::TEXTURE_2D, m_colorBuffer, 0); m_context->bindTexture(GraphicsContext3D::TEXTURE_2D, 0); - if (!multisample() && (attributes.stencil || attributes.depth)) { - m_context->bindRenderbuffer(GraphicsContext3D::RENDERBUFFER, m_depthStencilBuffer); - m_context->renderbufferStorage(GraphicsContext3D::RENDERBUFFER, internalDepthStencilFormat, m_size.width(), m_size.height()); - if (attributes.stencil) - m_context->framebufferRenderbuffer(GraphicsContext3D::FRAMEBUFFER, GraphicsContext3D::STENCIL_ATTACHMENT, GraphicsContext3D::RENDERBUFFER, m_depthStencilBuffer); - if (attributes.depth) - m_context->framebufferRenderbuffer(GraphicsContext3D::FRAMEBUFFER, GraphicsContext3D::DEPTH_ATTACHMENT, GraphicsContext3D::RENDERBUFFER, m_depthStencilBuffer); - m_context->bindRenderbuffer(GraphicsContext3D::RENDERBUFFER, 0); - } + resizeDepthStencil(0); if (m_context->checkFramebufferStatus(GraphicsContext3D::FRAMEBUFFER) != GraphicsContext3D::FRAMEBUFFER_COMPLETE) { // Cleanup clear(); diff --git a/Source/WebCore/platform/graphics/gpu/DrawingBuffer.h b/Source/WebCore/platform/graphics/gpu/DrawingBuffer.h index e0e0ee1..49ae114 100644 --- a/Source/WebCore/platform/graphics/gpu/DrawingBuffer.h +++ b/Source/WebCore/platform/graphics/gpu/DrawingBuffer.h @@ -67,6 +67,8 @@ public: // Create the depth/stencil and multisample buffers, if needed. void createSecondaryBuffers(); + void resizeDepthStencil(int sampleCount); + // Copies the multisample color buffer to the normal color buffer and leaves m_fbo bound void commit(long x = 0, long y = 0, long width = -1, long height = -1); @@ -80,8 +82,10 @@ public: #endif #if PLATFORM(CHROMIUM) - class WillPublishCallback : public Noncopyable { + class WillPublishCallback { + WTF_MAKE_NONCOPYABLE(WillPublishCallback); public: + WillPublishCallback() { } virtual ~WillPublishCallback() { } virtual void willPublish() = 0; @@ -106,13 +110,18 @@ private: bool m_packedDepthStencilExtensionSupported; Platform3DObject m_fbo; Platform3DObject m_colorBuffer; + + // This is used when we have OES_packed_depth_stencil. Platform3DObject m_depthStencilBuffer; + // These are used when we don't. + Platform3DObject m_depthBuffer; + Platform3DObject m_stencilBuffer; + // For multisampling Platform3DObject m_multisampleFBO; Platform3DObject m_multisampleColorBuffer; - Platform3DObject m_multisampleDepthStencilBuffer; - + #if PLATFORM(CHROMIUM) OwnPtr<WillPublishCallback> m_callback; OwnPtr<DrawingBufferInternal> m_internal; diff --git a/Source/WebCore/platform/graphics/gpu/LoopBlinnClassifier.h b/Source/WebCore/platform/graphics/gpu/LoopBlinnClassifier.h index c665844..1bd67b8 100644 --- a/Source/WebCore/platform/graphics/gpu/LoopBlinnClassifier.h +++ b/Source/WebCore/platform/graphics/gpu/LoopBlinnClassifier.h @@ -30,14 +30,14 @@ #ifndef LoopBlinnClassifier_h #define LoopBlinnClassifier_h -#include <wtf/Noncopyable.h> namespace WebCore { class FloatPoint; // Classifies cubic curves into specific types. -class LoopBlinnClassifier : public Noncopyable { +class LoopBlinnClassifier { + WTF_MAKE_NONCOPYABLE(LoopBlinnClassifier); public: // The types of cubic curves. enum CurveType { diff --git a/Source/WebCore/platform/graphics/gpu/LoopBlinnLocalTriangulator.h b/Source/WebCore/platform/graphics/gpu/LoopBlinnLocalTriangulator.h index ea3d7e3..d01e6c9 100644 --- a/Source/WebCore/platform/graphics/gpu/LoopBlinnLocalTriangulator.h +++ b/Source/WebCore/platform/graphics/gpu/LoopBlinnLocalTriangulator.h @@ -30,19 +30,20 @@ #include "FloatPoint3D.h" #include "LoopBlinnConstants.h" #include <wtf/Assertions.h> -#include <wtf/Noncopyable.h> namespace WebCore { // Performs a localized triangulation of the triangle mesh // corresponding to the four control point vertices of a cubic curve // segment. -class LoopBlinnLocalTriangulator : public Noncopyable { +class LoopBlinnLocalTriangulator { + WTF_MAKE_NONCOPYABLE(LoopBlinnLocalTriangulator); public: // The vertices that the triangulator operates upon, containing both // the position information as well as the cubic texture // coordinates. - class Vertex : public Noncopyable { + class Vertex { + WTF_MAKE_NONCOPYABLE(Vertex); public: Vertex() { diff --git a/Source/WebCore/platform/graphics/gpu/PODArena.h b/Source/WebCore/platform/graphics/gpu/PODArena.h index f68baef..6edc1db 100644 --- a/Source/WebCore/platform/graphics/gpu/PODArena.h +++ b/Source/WebCore/platform/graphics/gpu/PODArena.h @@ -158,7 +158,8 @@ private: } // Manages a chunk of memory and individual allocations out of it. - class Chunk : public Noncopyable { + class Chunk { + WTF_MAKE_NONCOPYABLE(Chunk); public: // Allocates a block of memory of the given size from the passed // Allocator. diff --git a/Source/WebCore/platform/graphics/gpu/PODIntervalTree.h b/Source/WebCore/platform/graphics/gpu/PODIntervalTree.h index 320ce60..5bf3de0 100644 --- a/Source/WebCore/platform/graphics/gpu/PODIntervalTree.h +++ b/Source/WebCore/platform/graphics/gpu/PODIntervalTree.h @@ -44,8 +44,8 @@ struct ValueToString; // supports efficient (O(lg n)) insertion, removal and querying of // intervals in the tree. template<class T, class UserData = void*> -class PODIntervalTree : public Noncopyable, - public PODRedBlackTree<PODInterval<T, UserData> > { +class PODIntervalTree : public PODRedBlackTree<PODInterval<T, UserData> > { + WTF_MAKE_NONCOPYABLE(PODIntervalTree); public: // Typedef to reduce typing when declaring intervals to be stored in // this tree. diff --git a/Source/WebCore/platform/graphics/gpu/PODRedBlackTree.h b/Source/WebCore/platform/graphics/gpu/PODRedBlackTree.h index 6d5954c..bd08988 100644 --- a/Source/WebCore/platform/graphics/gpu/PODRedBlackTree.h +++ b/Source/WebCore/platform/graphics/gpu/PODRedBlackTree.h @@ -198,7 +198,8 @@ protected: // The base Node class which is stored in the tree. Nodes are only // an internal concept; users of the tree deal only with the data // they store in it. - class Node : public Noncopyable { + class Node { + WTF_MAKE_NONCOPYABLE(Node); public: // Constructor. Newly-created nodes are colored red. explicit Node(const T& data) @@ -659,7 +660,8 @@ private: // Helper class for size() // A Visitor which simply counts the number of visited elements. - class Counter : public Visitor, public Noncopyable { + class Counter : public Visitor { + WTF_MAKE_NONCOPYABLE(Counter); public: Counter() : m_count(0) { } diff --git a/Source/WebCore/platform/graphics/gpu/Shader.h b/Source/WebCore/platform/graphics/gpu/Shader.h index e5bd8de..4f62ca9 100644 --- a/Source/WebCore/platform/graphics/gpu/Shader.h +++ b/Source/WebCore/platform/graphics/gpu/Shader.h @@ -40,7 +40,8 @@ class AffineTransform; class GraphicsContext3D; class Color; -class Shader : public Noncopyable { +class Shader { + WTF_MAKE_NONCOPYABLE(Shader); protected: Shader(GraphicsContext3D*, unsigned program); ~Shader(); diff --git a/Source/WebCore/platform/graphics/gpu/SharedGraphicsContext3D.cpp b/Source/WebCore/platform/graphics/gpu/SharedGraphicsContext3D.cpp index 9d1298f..9c59077 100644 --- a/Source/WebCore/platform/graphics/gpu/SharedGraphicsContext3D.cpp +++ b/Source/WebCore/platform/graphics/gpu/SharedGraphicsContext3D.cpp @@ -51,6 +51,9 @@ namespace WebCore { PassRefPtr<SharedGraphicsContext3D> SharedGraphicsContext3D::create(HostWindow* hostWindow) { GraphicsContext3D::Attributes attr; + attr.depth = false; + attr.stencil = true; + attr.antialias = false; attr.canRecoverFromContextLoss = false; // Canvas contexts can not handle lost contexts. RefPtr<GraphicsContext3D> context = GraphicsContext3D::create(attr, hostWindow); if (!context) @@ -293,6 +296,14 @@ void SharedGraphicsContext3D::applyCompositeOperator(CompositeOperator op) } } +void SharedGraphicsContext3D::enableStencil(bool enable) +{ + if (enable) + m_context->enable(GraphicsContext3D::STENCIL_TEST); + else + m_context->disable(GraphicsContext3D::STENCIL_TEST); +} + void SharedGraphicsContext3D::useQuadVertices() { if (!m_quadVertices) { diff --git a/Source/WebCore/platform/graphics/gpu/SharedGraphicsContext3D.h b/Source/WebCore/platform/graphics/gpu/SharedGraphicsContext3D.h index ea1810d..1e032d7 100644 --- a/Source/WebCore/platform/graphics/gpu/SharedGraphicsContext3D.h +++ b/Source/WebCore/platform/graphics/gpu/SharedGraphicsContext3D.h @@ -90,6 +90,7 @@ public: // Shared logic for canvas 2d void applyCompositeOperator(CompositeOperator); + void enableStencil(bool enable); void useQuadVertices(); void useFillSolidProgram(const AffineTransform&, const Color&); diff --git a/Source/WebCore/platform/graphics/gpu/TilingData.h b/Source/WebCore/platform/graphics/gpu/TilingData.h index 1bdc51a..d1140bd 100644 --- a/Source/WebCore/platform/graphics/gpu/TilingData.h +++ b/Source/WebCore/platform/graphics/gpu/TilingData.h @@ -38,7 +38,8 @@ namespace WebCore { class FloatRect; class IntRect; -class TilingData : public Noncopyable { +class TilingData { + WTF_MAKE_NONCOPYABLE(TilingData); public: TilingData(int maxTextureSize, int totalSizeX, int totalSizeY, bool hasBorderTexels); int maxTextureSize() const { return m_maxTextureSize; } diff --git a/Source/WebCore/platform/graphics/gpu/mac/DrawingBufferMac.mm b/Source/WebCore/platform/graphics/gpu/mac/DrawingBufferMac.mm index 601454e..e6dfdb8 100644 --- a/Source/WebCore/platform/graphics/gpu/mac/DrawingBufferMac.mm +++ b/Source/WebCore/platform/graphics/gpu/mac/DrawingBufferMac.mm @@ -41,15 +41,16 @@ DrawingBuffer::DrawingBuffer(GraphicsContext3D* context, bool multisampleExtensionSupported, bool packedDepthStencilExtensionSupported) : m_context(context) - , m_size(size) + , m_size(-1, -1) , m_multisampleExtensionSupported(multisampleExtensionSupported) , m_packedDepthStencilExtensionSupported(packedDepthStencilExtensionSupported) , m_fbo(context->createFramebuffer()) , m_colorBuffer(0) , m_depthStencilBuffer(0) + , m_depthBuffer(0) + , m_stencilBuffer(0) , m_multisampleFBO(0) , m_multisampleColorBuffer(0) - , m_multisampleDepthStencilBuffer(0) { ASSERT(m_fbo); if (!m_fbo) { diff --git a/Source/WebCore/platform/graphics/gstreamer/WebKitWebSourceGStreamer.cpp b/Source/WebCore/platform/graphics/gstreamer/WebKitWebSourceGStreamer.cpp index e10e61f..36b49df 100644 --- a/Source/WebCore/platform/graphics/gstreamer/WebKitWebSourceGStreamer.cpp +++ b/Source/WebCore/platform/graphics/gstreamer/WebKitWebSourceGStreamer.cpp @@ -36,7 +36,8 @@ using namespace WebCore; -class StreamingClient : public Noncopyable, public ResourceHandleClient { +class StreamingClient : public ResourceHandleClient { + WTF_MAKE_NONCOPYABLE(StreamingClient); public: StreamingClient(WebKitWebSrc*); virtual ~StreamingClient(); diff --git a/Source/WebCore/platform/graphics/gtk/FontGtk.cpp b/Source/WebCore/platform/graphics/gtk/FontGtk.cpp index fdf91db..4d6f509 100644 --- a/Source/WebCore/platform/graphics/gtk/FontGtk.cpp +++ b/Source/WebCore/platform/graphics/gtk/FontGtk.cpp @@ -38,6 +38,7 @@ #include "GraphicsContext.h" #include "NotImplemented.h" #include "SimpleFontData.h" +#include "TextRun.h" #include <cairo.h> #include <gdk/gdk.h> #include <pango/pango.h> diff --git a/Source/WebCore/platform/graphics/haiku/FontCustomPlatformData.h b/Source/WebCore/platform/graphics/haiku/FontCustomPlatformData.h index cc348e3..86f99b2 100644 --- a/Source/WebCore/platform/graphics/haiku/FontCustomPlatformData.h +++ b/Source/WebCore/platform/graphics/haiku/FontCustomPlatformData.h @@ -24,14 +24,14 @@ #include "FontOrientation.h" #include "FontRenderingMode.h" #include <wtf/Forward.h> -#include <wtf/Noncopyable.h> namespace WebCore { class FontPlatformData; class SharedBuffer; - struct FontCustomPlatformData : Noncopyable { + struct FontCustomPlatformData { + WTF_MAKE_NONCOPYABLE(FontCustomPlatformData); public: FontCustomPlatformData() { } ~FontCustomPlatformData(); diff --git a/Source/WebCore/platform/graphics/haiku/ImageBufferHaiku.cpp b/Source/WebCore/platform/graphics/haiku/ImageBufferHaiku.cpp index bdad6a0..7a7c88b 100644 --- a/Source/WebCore/platform/graphics/haiku/ImageBufferHaiku.cpp +++ b/Source/WebCore/platform/graphics/haiku/ImageBufferHaiku.cpp @@ -78,6 +78,11 @@ ImageBuffer::~ImageBuffer() { } +size_t ImageBuffer::dataSize() const +{ + return m_size.width() * m_size.height() * 4; +} + GraphicsContext* ImageBuffer::context() const { ASSERT(m_data.m_view.Window()); diff --git a/Source/WebCore/platform/graphics/mac/ComplexTextController.cpp b/Source/WebCore/platform/graphics/mac/ComplexTextController.cpp index 206fd5f..86f6bec 100644 --- a/Source/WebCore/platform/graphics/mac/ComplexTextController.cpp +++ b/Source/WebCore/platform/graphics/mac/ComplexTextController.cpp @@ -30,6 +30,7 @@ #include "FloatSize.h" #include "Font.h" #include "TextBreakIterator.h" +#include "TextRun.h" #include <wtf/StdLibExtras.h> diff --git a/Source/WebCore/platform/graphics/mac/ComplexTextControllerATSUI.cpp b/Source/WebCore/platform/graphics/mac/ComplexTextControllerATSUI.cpp index c24a914..9c2ab6b 100644 --- a/Source/WebCore/platform/graphics/mac/ComplexTextControllerATSUI.cpp +++ b/Source/WebCore/platform/graphics/mac/ComplexTextControllerATSUI.cpp @@ -28,6 +28,7 @@ #include "CharacterNames.h" #include "Font.h" #include "ShapeArabic.h" +#include "TextRun.h" #ifdef __LP64__ // ATSUTextInserted() is SPI in 64-bit. diff --git a/Source/WebCore/platform/graphics/mac/ComplexTextControllerCoreText.cpp b/Source/WebCore/platform/graphics/mac/ComplexTextControllerCoreText.cpp index 42e7897..07fb153 100644 --- a/Source/WebCore/platform/graphics/mac/ComplexTextControllerCoreText.cpp +++ b/Source/WebCore/platform/graphics/mac/ComplexTextControllerCoreText.cpp @@ -24,6 +24,7 @@ #include "config.h" #include "ComplexTextController.h" +#include "TextRun.h" #include "WebCoreSystemInterface.h" #if USE(CORE_TEXT) diff --git a/Source/WebCore/platform/graphics/mac/FontComplexTextMac.cpp b/Source/WebCore/platform/graphics/mac/FontComplexTextMac.cpp index ca006d9..02bac9c 100644 --- a/Source/WebCore/platform/graphics/mac/FontComplexTextMac.cpp +++ b/Source/WebCore/platform/graphics/mac/FontComplexTextMac.cpp @@ -31,6 +31,7 @@ #include "GraphicsContext.h" #include "IntRect.h" #include "SimpleFontData.h" +#include "TextRun.h" #include <wtf/MathExtras.h> using namespace std; diff --git a/Source/WebCore/platform/graphics/mac/FontCustomPlatformData.h b/Source/WebCore/platform/graphics/mac/FontCustomPlatformData.h index c11858c..7043d7e 100644 --- a/Source/WebCore/platform/graphics/mac/FontCustomPlatformData.h +++ b/Source/WebCore/platform/graphics/mac/FontCustomPlatformData.h @@ -36,7 +36,9 @@ namespace WebCore { class FontPlatformData; class SharedBuffer; -struct FontCustomPlatformData : Noncopyable { +struct FontCustomPlatformData { + WTF_MAKE_NONCOPYABLE(FontCustomPlatformData); +public: FontCustomPlatformData(ATSFontContainerRef container, CGFontRef cgFont) : m_atsContainer(container) , m_cgFont(cgFont) diff --git a/Source/WebCore/platform/graphics/mac/GraphicsContext3DMac.mm b/Source/WebCore/platform/graphics/mac/GraphicsContext3DMac.mm index 321d0ef..21eb59d 100644 --- a/Source/WebCore/platform/graphics/mac/GraphicsContext3DMac.mm +++ b/Source/WebCore/platform/graphics/mac/GraphicsContext3DMac.mm @@ -188,21 +188,15 @@ GraphicsContext3D::GraphicsContext3D(GraphicsContext3D::Attributes attrs, HostWi // ANGLE initialization. - TBuiltInResource ANGLEResources; + ShBuiltInResources ANGLEResources; + ShInitBuiltInResources(&ANGLEResources); - ANGLEResources.MaxVertexAttribs = 0; getIntegerv(GraphicsContext3D::MAX_VERTEX_ATTRIBS, &ANGLEResources.MaxVertexAttribs); - ANGLEResources.MaxVertexUniformVectors = 0; getIntegerv(GraphicsContext3D::MAX_VERTEX_UNIFORM_VECTORS, &ANGLEResources.MaxVertexUniformVectors); - ANGLEResources.MaxVaryingVectors = 0; getIntegerv(GraphicsContext3D::MAX_VARYING_VECTORS, &ANGLEResources.MaxVaryingVectors); - ANGLEResources.MaxVertexTextureImageUnits = 0; getIntegerv(GraphicsContext3D::MAX_VERTEX_TEXTURE_IMAGE_UNITS, &ANGLEResources.MaxVertexTextureImageUnits); - ANGLEResources.MaxCombinedTextureImageUnits = 0; getIntegerv(GraphicsContext3D::MAX_COMBINED_TEXTURE_IMAGE_UNITS, &ANGLEResources.MaxCombinedTextureImageUnits); - ANGLEResources.MaxTextureImageUnits = 0; getIntegerv(GraphicsContext3D::MAX_TEXTURE_IMAGE_UNITS, &ANGLEResources.MaxTextureImageUnits); - ANGLEResources.MaxFragmentUniformVectors = 0; getIntegerv(GraphicsContext3D::MAX_FRAGMENT_UNIFORM_VECTORS, &ANGLEResources.MaxFragmentUniformVectors); // Always set to 1 for OpenGL ES. diff --git a/Source/WebCore/platform/graphics/opengl/Extensions3DOpenGL.cpp b/Source/WebCore/platform/graphics/opengl/Extensions3DOpenGL.cpp index 4215d12..3eb5196 100644 --- a/Source/WebCore/platform/graphics/opengl/Extensions3DOpenGL.cpp +++ b/Source/WebCore/platform/graphics/opengl/Extensions3DOpenGL.cpp @@ -33,13 +33,15 @@ #include <wtf/Vector.h> #if PLATFORM(MAC) +#include "ANGLE/ShaderLang.h" #include <OpenGL/gl.h> #endif namespace WebCore { -Extensions3DOpenGL::Extensions3DOpenGL() +Extensions3DOpenGL::Extensions3DOpenGL(GraphicsContext3D* context) : m_initializedAvailableExtensions(false) + , m_context(context) { } @@ -82,12 +84,28 @@ bool Extensions3DOpenGL::supports(const String& name) if (name == "GL_OES_texture_float" || name == "GL_OES_texture_half_float") return m_availableExtensions.contains("GL_ARB_texture_float"); + // Desktop GL always supports the standard derivative functions + if (name == "GL_OES_standard_derivatives") + return true; + return m_availableExtensions.contains(name); } void Extensions3DOpenGL::ensureEnabled(const String& name) { +#if PLATFORM(MAC) + if (name == "GL_OES_standard_derivatives") { + // Enable support in ANGLE (if not enabled already) + ANGLEWebKitBridge& compiler = m_context->m_compiler; + ShBuiltInResources ANGLEResources = compiler.getResources(); + if (!ANGLEResources.OES_standard_derivatives) { + ANGLEResources.OES_standard_derivatives = 1; + compiler.setResources(ANGLEResources); + } + } +#else ASSERT_UNUSED(name, supports(name)); +#endif } int Extensions3DOpenGL::getGraphicsResetStatusARB() diff --git a/Source/WebCore/platform/graphics/opengl/Extensions3DOpenGL.h b/Source/WebCore/platform/graphics/opengl/Extensions3DOpenGL.h index 59f8180..1941a42 100644 --- a/Source/WebCore/platform/graphics/opengl/Extensions3DOpenGL.h +++ b/Source/WebCore/platform/graphics/opengl/Extensions3DOpenGL.h @@ -48,10 +48,13 @@ public: private: // This class only needs to be instantiated by GraphicsContext3D implementations. friend class GraphicsContext3D; - Extensions3DOpenGL(); + Extensions3DOpenGL(GraphicsContext3D*); bool m_initializedAvailableExtensions; HashSet<String> m_availableExtensions; + + // Weak pointer back to GraphicsContext3D + GraphicsContext3D* m_context; }; } // namespace WebCore diff --git a/Source/WebCore/platform/graphics/opengl/GraphicsContext3DOpenGL.cpp b/Source/WebCore/platform/graphics/opengl/GraphicsContext3DOpenGL.cpp index 221ee11..7c103f3 100644 --- a/Source/WebCore/platform/graphics/opengl/GraphicsContext3DOpenGL.cpp +++ b/Source/WebCore/platform/graphics/opengl/GraphicsContext3DOpenGL.cpp @@ -1467,7 +1467,7 @@ void GraphicsContext3D::synthesizeGLError(GC3Denum error) Extensions3D* GraphicsContext3D::getExtensions() { if (!m_extensions) - m_extensions = adoptPtr(new Extensions3DOpenGL); + m_extensions = adoptPtr(new Extensions3DOpenGL(this)); return m_extensions.get(); } diff --git a/Source/WebCore/platform/graphics/openvg/PainterOpenVG.h b/Source/WebCore/platform/graphics/openvg/PainterOpenVG.h index 32f1fe5..3f1494e 100644 --- a/Source/WebCore/platform/graphics/openvg/PainterOpenVG.h +++ b/Source/WebCore/platform/graphics/openvg/PainterOpenVG.h @@ -41,7 +41,8 @@ class TiledImageOpenVG; struct PlatformPainterState; -class PainterOpenVG : public Noncopyable { +class PainterOpenVG { + WTF_MAKE_NONCOPYABLE(PainterOpenVG); public: friend class SurfaceOpenVG; friend struct PlatformPainterState; diff --git a/Source/WebCore/platform/graphics/openvg/SurfaceOpenVG.h b/Source/WebCore/platform/graphics/openvg/SurfaceOpenVG.h index 46d1646..19d95d8 100644 --- a/Source/WebCore/platform/graphics/openvg/SurfaceOpenVG.h +++ b/Source/WebCore/platform/graphics/openvg/SurfaceOpenVG.h @@ -42,7 +42,8 @@ class IntSize; * of #ifdefs and should make it easy to add different surface/context * implementations than EGL. */ -class SurfaceOpenVG : public Noncopyable { +class SurfaceOpenVG { + WTF_MAKE_NONCOPYABLE(SurfaceOpenVG); public: enum MakeCurrentMode { ApplyPainterStateOnSurfaceSwitch, diff --git a/Source/WebCore/platform/graphics/qt/ContextShadowQt.cpp b/Source/WebCore/platform/graphics/qt/ContextShadowQt.cpp index 834ca62..37d6b44 100644 --- a/Source/WebCore/platform/graphics/qt/ContextShadowQt.cpp +++ b/Source/WebCore/platform/graphics/qt/ContextShadowQt.cpp @@ -72,7 +72,7 @@ QImage* ShadowBuffer::scratchImage(const QSize& size) // keep too many allocated pixels for too long. if (!image.isNull() && (image.width() > width) && (image.height() > height)) if (((2 * width) > image.width()) && ((2 * height) > image.height())) { - image.fill(Qt::transparent); + image.fill(0); return ℑ } @@ -82,7 +82,7 @@ QImage* ShadowBuffer::scratchImage(const QSize& size) height = (1 + (height >> 5)) << 5; image = QImage(width, height, QImage::Format_ARGB32_Premultiplied); - image.fill(Qt::transparent); + image.fill(0); return ℑ } diff --git a/Source/WebCore/platform/graphics/qt/FontCustomPlatformData.h b/Source/WebCore/platform/graphics/qt/FontCustomPlatformData.h index 6c41d47..54fa679 100644 --- a/Source/WebCore/platform/graphics/qt/FontCustomPlatformData.h +++ b/Source/WebCore/platform/graphics/qt/FontCustomPlatformData.h @@ -24,6 +24,7 @@ #include "FontOrientation.h" #include "FontRenderingMode.h" +#include <wtf/FastAllocBase.h> #include <wtf/Forward.h> #include <wtf/Noncopyable.h> @@ -32,7 +33,10 @@ namespace WebCore { class FontPlatformData; class SharedBuffer; -struct FontCustomPlatformData : Noncopyable { +struct FontCustomPlatformData { + WTF_MAKE_NONCOPYABLE(FontCustomPlatformData); WTF_MAKE_FAST_ALLOCATED; +public: + FontCustomPlatformData() { } ~FontCustomPlatformData(); // for use with QFontDatabase::addApplicationFont/removeApplicationFont diff --git a/Source/WebCore/platform/graphics/qt/FontPlatformData.h b/Source/WebCore/platform/graphics/qt/FontPlatformData.h index 1c57e29..f268370 100644 --- a/Source/WebCore/platform/graphics/qt/FontPlatformData.h +++ b/Source/WebCore/platform/graphics/qt/FontPlatformData.h @@ -32,7 +32,8 @@ namespace WebCore { -class FontPlatformDataPrivate : public Noncopyable { +class FontPlatformDataPrivate { + WTF_MAKE_NONCOPYABLE(FontPlatformDataPrivate); WTF_MAKE_FAST_ALLOCATED; public: FontPlatformDataPrivate() : refCount(1) @@ -62,8 +63,10 @@ public: -class FontPlatformData : public FastAllocBase { +class FontPlatformData { + WTF_MAKE_FAST_ALLOCATED; public: + FontPlatformData() { } FontPlatformData(float size, bool bold, bool oblique); FontPlatformData(const FontPlatformData &); FontPlatformData(const FontDescription&, const AtomicString& familyName, int wordSpacing = 0, int letterSpacing = 0); diff --git a/Source/WebCore/platform/graphics/qt/FontQt.cpp b/Source/WebCore/platform/graphics/qt/FontQt.cpp index f1ced2b..778a13f 100644 --- a/Source/WebCore/platform/graphics/qt/FontQt.cpp +++ b/Source/WebCore/platform/graphics/qt/FontQt.cpp @@ -31,6 +31,7 @@ #include "GraphicsContext.h" #include "NotImplemented.h" #include "Pattern.h" +#include "TextRun.h" #include <QBrush> #include <QFontInfo> diff --git a/Source/WebCore/platform/graphics/qt/GraphicsContextQt.cpp b/Source/WebCore/platform/graphics/qt/GraphicsContextQt.cpp index 253cd84..4dabe09 100644 --- a/Source/WebCore/platform/graphics/qt/GraphicsContextQt.cpp +++ b/Source/WebCore/platform/graphics/qt/GraphicsContextQt.cpp @@ -8,7 +8,7 @@ * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved. * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies). * Copyright (C) 2008 Dirk Schulze <vbs85@gmx.de> - * Copyright (C) 2010 Sencha, Inc. + * Copyright (C) 2010, 2011 Sencha, Inc. * * All rights reserved. * @@ -174,7 +174,8 @@ static inline Qt::FillRule toQtFillRule(WindRule rule) return Qt::OddEvenFill; } -class GraphicsContextPlatformPrivate : public Noncopyable { +class GraphicsContextPlatformPrivate { + WTF_MAKE_NONCOPYABLE(GraphicsContextPlatformPrivate); WTF_MAKE_FAST_ALLOCATED; public: GraphicsContextPlatformPrivate(QPainter*, const QColor& initialSolidColor); ~GraphicsContextPlatformPrivate(); @@ -505,14 +506,19 @@ void GraphicsContext::fillPath(const Path& path) brush.setTransform(m_state.fillGradient->gradientSpaceTransform()); shadowPainter->setOpacity(static_cast<qreal>(shadow->m_color.alpha()) / 255); shadowPainter->fillPath(platformPath, brush); - } else - shadowPainter->fillPath(platformPath, QColor(shadow->m_color)); + } else { + QColor shadowColor = shadow->m_color; + shadowColor.setAlphaF(shadowColor.alphaF() * p->brush().color().alphaF()); + shadowPainter->fillPath(platformPath, shadowColor); + } shadow->endShadowLayer(this); } } else { QPointF offset = shadow->offset(); p->translate(offset); - p->fillPath(platformPath, QColor(shadow->m_color)); + QColor shadowColor = shadow->m_color; + shadowColor.setAlphaF(shadowColor.alphaF() * p->brush().color().alphaF()); + p->fillPath(platformPath, shadowColor); p->translate(-offset); } } @@ -550,10 +556,12 @@ void GraphicsContext::strokePath(const Path& path) shadow->endShadowLayer(this); } } else { - QPen shadowPen(pen); - shadowPen.setColor(m_data->shadow.m_color); QPointF offset = shadow->offset(); p->translate(offset); + QColor shadowColor = shadow->m_color; + shadowColor.setAlphaF(shadowColor.alphaF() * pen.color().alphaF()); + QPen shadowPen(pen); + shadowPen.setColor(shadowColor); p->strokePath(platformPath, shadowPen); p->translate(-offset); } @@ -983,11 +991,9 @@ void GraphicsContext::clearRect(const FloatRect& rect) QPainter* p = m_data->p(); QPainter::CompositionMode currentCompositionMode = p->compositionMode(); - if (p->paintEngine()->hasFeature(QPaintEngine::PorterDuff)) - p->setCompositionMode(QPainter::CompositionMode_Source); + p->setCompositionMode(QPainter::CompositionMode_Source); p->fillRect(rect, Qt::transparent); - if (p->paintEngine()->hasFeature(QPaintEngine::PorterDuff)) - p->setCompositionMode(currentCompositionMode); + p->setCompositionMode(currentCompositionMode); } void GraphicsContext::strokeRect(const FloatRect& rect, float lineWidth) @@ -1077,12 +1083,7 @@ void GraphicsContext::setPlatformCompositeOperation(CompositeOperator op) if (paintingDisabled()) return; - QPainter* painter = m_data->p(); - - if (!painter->paintEngine()->hasFeature(QPaintEngine::PorterDuff)) - return; - - painter->setCompositionMode(toQtCompositionMode(op)); + m_data->p()->setCompositionMode(toQtCompositionMode(op)); } void GraphicsContext::clip(const Path& path) diff --git a/Source/WebCore/platform/graphics/qt/ImageBufferQt.cpp b/Source/WebCore/platform/graphics/qt/ImageBufferQt.cpp index f56603d..d1567ec 100644 --- a/Source/WebCore/platform/graphics/qt/ImageBufferQt.cpp +++ b/Source/WebCore/platform/graphics/qt/ImageBufferQt.cpp @@ -95,6 +95,11 @@ ImageBuffer::~ImageBuffer() { } +size_t ImageBuffer::dataSize() const +{ + return m_size.width() * m_size.height() * 4; +} + GraphicsContext* ImageBuffer::context() const { ASSERT(m_data.m_painter->isActive()); diff --git a/Source/WebCore/platform/graphics/qt/MediaPlayerPrivateQt.cpp b/Source/WebCore/platform/graphics/qt/MediaPlayerPrivateQt.cpp index be6f732..0a4c0f6 100644 --- a/Source/WebCore/platform/graphics/qt/MediaPlayerPrivateQt.cpp +++ b/Source/WebCore/platform/graphics/qt/MediaPlayerPrivateQt.cpp @@ -20,7 +20,6 @@ #include "config.h" #include "MediaPlayerPrivateQt.h" -#include "FrameLoaderClientQt.h" #include "FrameView.h" #include "GraphicsContext.h" #include "HTMLMediaElement.h" @@ -205,10 +204,10 @@ void MediaPlayerPrivateQt::commitLoad(const String& url) // Grab the frame and network manager Frame* frame = document ? document->frame() : 0; - QNetworkAccessManager* manager = frame ? frame->loader()->networkingContext()->networkAccessManager() : 0; - FrameLoaderClientQt* frameLoader = frame ? static_cast<FrameLoaderClientQt*>(frame->loader()->client()) : 0; + FrameLoader* frameLoader = frame ? frame->loader() : 0; + QNetworkAccessManager* manager = frameLoader ? frameLoader->networkingContext()->networkAccessManager() : 0; - if (document && manager) { + if (manager) { // Set the cookies QtNAMThreadSafeProxy managerProxy(manager); QList<QNetworkCookie> cookies = managerProxy.cookiesForUrl(rUrl); diff --git a/Source/WebCore/platform/graphics/qt/TransparencyLayer.h b/Source/WebCore/platform/graphics/qt/TransparencyLayer.h index 5b2f8b2..ff9ef20 100644 --- a/Source/WebCore/platform/graphics/qt/TransparencyLayer.h +++ b/Source/WebCore/platform/graphics/qt/TransparencyLayer.h @@ -42,7 +42,9 @@ namespace WebCore { -struct TransparencyLayer : FastAllocBase { +struct TransparencyLayer { + WTF_MAKE_FAST_ALLOCATED; +public: TransparencyLayer(const QPainter* p, const QRect &rect, qreal opacity, QPixmap& alphaMask) : pixmap(rect.width(), rect.height()) , opacity(opacity) @@ -59,8 +61,7 @@ struct TransparencyLayer : FastAllocBase { painter.setTransform(p->transform(), true); painter.setOpacity(p->opacity()); painter.setFont(p->font()); - if (painter.paintEngine()->hasFeature(QPaintEngine::PorterDuff)) - painter.setCompositionMode(p->compositionMode()); + painter.setCompositionMode(p->compositionMode()); } TransparencyLayer() diff --git a/Source/WebCore/platform/graphics/skia/FontCustomPlatformData.cpp b/Source/WebCore/platform/graphics/skia/FontCustomPlatformData.cpp index e94c417..0b31dfa 100644 --- a/Source/WebCore/platform/graphics/skia/FontCustomPlatformData.cpp +++ b/Source/WebCore/platform/graphics/skia/FontCustomPlatformData.cpp @@ -35,8 +35,8 @@ #if OS(WINDOWS) #include "Base64.h" -#include "ChromiumBridge.h" #include "OpenTypeUtilities.h" +#include "PlatformBridge.h" #elif OS(LINUX) || OS(FREEBSD) || PLATFORM(BREWMP) #include "SkStream.h" #endif @@ -91,7 +91,7 @@ FontPlatformData FontCustomPlatformData::fontPlatformData(int size, bool bold, b logFont.lfStrikeOut = false; logFont.lfCharSet = DEFAULT_CHARSET; logFont.lfOutPrecision = OUT_TT_ONLY_PRECIS; - logFont.lfQuality = ChromiumBridge::layoutTestMode() ? + logFont.lfQuality = PlatformBridge::layoutTestMode() ? NONANTIALIASED_QUALITY : DEFAULT_QUALITY; // Honor user's desktop settings. logFont.lfPitchAndFamily = DEFAULT_PITCH | FF_DONTCARE; diff --git a/Source/WebCore/platform/graphics/skia/FontCustomPlatformData.h b/Source/WebCore/platform/graphics/skia/FontCustomPlatformData.h index e51b6b6..4228b40 100644 --- a/Source/WebCore/platform/graphics/skia/FontCustomPlatformData.h +++ b/Source/WebCore/platform/graphics/skia/FontCustomPlatformData.h @@ -49,7 +49,9 @@ namespace WebCore { class FontPlatformData; class SharedBuffer; -struct FontCustomPlatformData : Noncopyable { +struct FontCustomPlatformData { + WTF_MAKE_NONCOPYABLE(FontCustomPlatformData); +public: #if OS(WINDOWS) FontCustomPlatformData(HANDLE fontReference, const String& name) : m_fontReference(fontReference) diff --git a/Source/WebCore/platform/graphics/skia/GraphicsContextPlatformPrivate.h b/Source/WebCore/platform/graphics/skia/GraphicsContextPlatformPrivate.h index 5e12ad6..44835a4 100644 --- a/Source/WebCore/platform/graphics/skia/GraphicsContextPlatformPrivate.h +++ b/Source/WebCore/platform/graphics/skia/GraphicsContextPlatformPrivate.h @@ -31,14 +31,14 @@ #ifndef GraphicsContextPlatformPrivate_h #define GraphicsContextPlatformPrivate_h -#include <wtf/Noncopyable.h> class PlatformContextSkia; namespace WebCore { // This class just holds onto a PlatformContextSkia for GraphicsContext. -class GraphicsContextPlatformPrivate : public Noncopyable { +class GraphicsContextPlatformPrivate { + WTF_MAKE_NONCOPYABLE(GraphicsContextPlatformPrivate); public: GraphicsContextPlatformPrivate(PlatformContextSkia* platformContext) : m_context(platformContext) { } diff --git a/Source/WebCore/platform/graphics/skia/GraphicsContextSkia.cpp b/Source/WebCore/platform/graphics/skia/GraphicsContextSkia.cpp index 51e2477..1a7112b 100644 --- a/Source/WebCore/platform/graphics/skia/GraphicsContextSkia.cpp +++ b/Source/WebCore/platform/graphics/skia/GraphicsContextSkia.cpp @@ -386,6 +386,9 @@ void GraphicsContext::canvasClip(const Path& path) if (paintingDisabled()) return; + if (platformContext()->useGPU()) + platformContext()->gpuCanvas()->clipPath(path); + const SkPath& p = *path.platformPath(); if (!isPathSkiaSafe(getCTM(), p)) return; @@ -410,6 +413,9 @@ void GraphicsContext::clipOut(const Path& p) if (paintingDisabled()) return; + if (platformContext()->useGPU()) + platformContext()->gpuCanvas()->clipOut(p); + const SkPath& path = *p.platformPath(); if (!isPathSkiaSafe(getCTM(), path)) return; @@ -422,6 +428,9 @@ void GraphicsContext::clipPath(const Path& pathToClip, WindRule clipRule) if (paintingDisabled()) return; + if (platformContext()->useGPU()) + platformContext()->gpuCanvas()->clipPath(pathToClip); + // FIXME: Be smarter about this. beginPath(); addPath(pathToClip); @@ -733,6 +742,12 @@ void GraphicsContext::fillPath(const Path& pathToFill) beginPath(); addPath(pathToFill); + if (platformContext()->useGPU() && platformContext()->canAccelerate()) { + platformContext()->prepareForHardwareDraw(); + platformContext()->gpuCanvas()->fillPath(pathToFill); + return; + } + SkPath path = platformContext()->currentPathInLocalCoordinates(); if (!isPathSkiaSafe(getCTM(), path)) return; diff --git a/Source/WebCore/platform/graphics/skia/ImageBufferSkia.cpp b/Source/WebCore/platform/graphics/skia/ImageBufferSkia.cpp index b65b5bd..2c489ef 100644 --- a/Source/WebCore/platform/graphics/skia/ImageBufferSkia.cpp +++ b/Source/WebCore/platform/graphics/skia/ImageBufferSkia.cpp @@ -91,6 +91,11 @@ GraphicsContext* ImageBuffer::context() const return m_context.get(); } +size_t ImageBuffer::dataSize() const +{ + return m_size.width() * m_size.height() * 4; +} + bool ImageBuffer::drawsUsingCopy() const { return false; diff --git a/Source/WebCore/platform/graphics/skia/PlatformContextSkia.cpp b/Source/WebCore/platform/graphics/skia/PlatformContextSkia.cpp index d3c0e00..d852e9b 100644 --- a/Source/WebCore/platform/graphics/skia/PlatformContextSkia.cpp +++ b/Source/WebCore/platform/graphics/skia/PlatformContextSkia.cpp @@ -702,8 +702,7 @@ void PlatformContextSkia::applyAntiAliasedClipPaths(WTF::Vector<SkPath>& paths) bool PlatformContextSkia::canAccelerate() const { return !m_state->m_fillShader // Can't accelerate with a fill gradient or pattern. - && !m_state->m_looper // Can't accelerate with a shadow. - && !m_state->m_canvasClipApplied; // Can't accelerate with a clip to path applied. + && !m_state->m_looper; // Can't accelerate with a shadow. } bool PlatformContextSkia::canvasClipApplied() const @@ -848,7 +847,7 @@ void PlatformContextSkia::uploadSoftwareToHardware(CompositeOperator op) const m_uploadTexture->updateSubRect(bitmap.getPixels(), m_softwareDirtyRect); AffineTransform identity; - gpuCanvas()->drawTexturedRect(m_uploadTexture.get(), m_softwareDirtyRect, m_softwareDirtyRect, identity, 1.0, ColorSpaceDeviceRGB, op); + gpuCanvas()->drawTexturedRect(m_uploadTexture.get(), m_softwareDirtyRect, m_softwareDirtyRect, identity, 1.0, ColorSpaceDeviceRGB, op, false); // Clear out the region of the software canvas we just uploaded. m_canvas->save(); m_canvas->resetMatrix(); diff --git a/Source/WebCore/platform/graphics/skia/PlatformContextSkia.h b/Source/WebCore/platform/graphics/skia/PlatformContextSkia.h index 11b311a..0304486 100644 --- a/Source/WebCore/platform/graphics/skia/PlatformContextSkia.h +++ b/Source/WebCore/platform/graphics/skia/PlatformContextSkia.h @@ -67,7 +67,8 @@ class Texture; // responsible for managing the painting state which is store in separate // SkPaint objects. This class provides the adaptor that allows the painting // state to be pushed and popped along with the bitmap. -class PlatformContextSkia : public Noncopyable { +class PlatformContextSkia { + WTF_MAKE_NONCOPYABLE(PlatformContextSkia); public: // For printing, there shouldn't be any canvas. canvas can be NULL. If you // supply a NULL canvas, you can also call setCanvas later. diff --git a/Source/WebCore/platform/graphics/transforms/AffineTransform.cpp b/Source/WebCore/platform/graphics/transforms/AffineTransform.cpp index f275526..3f88140 100644 --- a/Source/WebCore/platform/graphics/transforms/AffineTransform.cpp +++ b/Source/WebCore/platform/graphics/transforms/AffineTransform.cpp @@ -164,12 +164,10 @@ AffineTransform AffineTransform::inverse() const return result; } -AffineTransform& AffineTransform::multiply(const AffineTransform& other) -{ - return (*this) *= other; -} -AffineTransform& AffineTransform::multLeft(const AffineTransform& other) +// Multiplies this AffineTransform by the provided AffineTransform - i.e. +// this = this * other; +AffineTransform& AffineTransform::multiply(const AffineTransform& other) { AffineTransform trans; @@ -192,7 +190,7 @@ AffineTransform& AffineTransform::rotate(double a) double sinAngle = sin(a); AffineTransform rot(cosAngle, sinAngle, -sinAngle, cosAngle, 0, 0); - multLeft(rot); + multiply(rot); return *this; } diff --git a/Source/WebCore/platform/graphics/transforms/AffineTransform.h b/Source/WebCore/platform/graphics/transforms/AffineTransform.h index baee102..50d0655 100644 --- a/Source/WebCore/platform/graphics/transforms/AffineTransform.h +++ b/Source/WebCore/platform/graphics/transforms/AffineTransform.h @@ -55,7 +55,8 @@ class IntPoint; class IntRect; class TransformationMatrix; -class AffineTransform : public FastAllocBase { +class AffineTransform { + WTF_MAKE_FAST_ALLOCATED; public: typedef double Transform[6]; @@ -95,8 +96,7 @@ public: void makeIdentity(); - AffineTransform& multiply(const AffineTransform&); - AffineTransform& multLeft(const AffineTransform&); + AffineTransform& multiply(const AffineTransform& other); AffineTransform& scale(double); AffineTransform& scale(double sx, double sy); AffineTransform& scaleNonUniform(double sx, double sy); @@ -147,15 +147,14 @@ public: // *this = *this * t (i.e., a multRight) AffineTransform& operator*=(const AffineTransform& t) { - *this = *this * t; - return *this; + return multiply(t); } // result = *this * t (i.e., a multRight) AffineTransform operator*(const AffineTransform& t) const { - AffineTransform result = t; - result.multLeft(*this); + AffineTransform result = *this; + result *= t; return result; } diff --git a/Source/WebCore/platform/graphics/transforms/TransformOperations.h b/Source/WebCore/platform/graphics/transforms/TransformOperations.h index c0da377..981e1f6 100644 --- a/Source/WebCore/platform/graphics/transforms/TransformOperations.h +++ b/Source/WebCore/platform/graphics/transforms/TransformOperations.h @@ -31,7 +31,8 @@ namespace WebCore { -class TransformOperations : public FastAllocBase { +class TransformOperations { + WTF_MAKE_FAST_ALLOCATED; public: TransformOperations(bool makeIdentity = false); diff --git a/Source/WebCore/platform/graphics/transforms/TransformationMatrix.cpp b/Source/WebCore/platform/graphics/transforms/TransformationMatrix.cpp index 10c7f70..357a140 100644 --- a/Source/WebCore/platform/graphics/transforms/TransformationMatrix.cpp +++ b/Source/WebCore/platform/graphics/transforms/TransformationMatrix.cpp @@ -27,6 +27,7 @@ #include "config.h" #include "TransformationMatrix.h" +#include "AffineTransform.h" #include "FloatPoint3D.h" #include "FloatRect.h" #include "FloatQuad.h" diff --git a/Source/WebCore/platform/graphics/transforms/TransformationMatrix.h b/Source/WebCore/platform/graphics/transforms/TransformationMatrix.h index f13bcc1..c883675 100644 --- a/Source/WebCore/platform/graphics/transforms/TransformationMatrix.h +++ b/Source/WebCore/platform/graphics/transforms/TransformationMatrix.h @@ -26,7 +26,6 @@ #ifndef TransformationMatrix_h #define TransformationMatrix_h -#include "AffineTransform.h" #include "FloatPoint.h" #include "IntPoint.h" #include <string.h> //for memcpy @@ -65,7 +64,8 @@ class FloatPoint3D; class FloatRect; class FloatQuad; -class TransformationMatrix : public FastAllocBase { +class TransformationMatrix { + WTF_MAKE_FAST_ALLOCATED; public: typedef double Matrix4[4][4]; diff --git a/Source/WebCore/platform/graphics/win/FontCustomPlatformData.h b/Source/WebCore/platform/graphics/win/FontCustomPlatformData.h index 1bdf270..de33c63 100644 --- a/Source/WebCore/platform/graphics/win/FontCustomPlatformData.h +++ b/Source/WebCore/platform/graphics/win/FontCustomPlatformData.h @@ -34,7 +34,9 @@ namespace WebCore { class FontPlatformData; class SharedBuffer; -struct FontCustomPlatformData : Noncopyable { +struct FontCustomPlatformData { + WTF_MAKE_NONCOPYABLE(FontCustomPlatformData); +public: FontCustomPlatformData(HANDLE fontReference, const String& name) : m_fontReference(fontReference) , m_name(name) diff --git a/Source/WebCore/platform/graphics/win/FontCustomPlatformDataCairo.h b/Source/WebCore/platform/graphics/win/FontCustomPlatformDataCairo.h index 3ab52b8..9c67037 100644 --- a/Source/WebCore/platform/graphics/win/FontCustomPlatformDataCairo.h +++ b/Source/WebCore/platform/graphics/win/FontCustomPlatformDataCairo.h @@ -33,7 +33,9 @@ namespace WebCore { class FontPlatformData; class SharedBuffer; -struct FontCustomPlatformData : Noncopyable { +struct FontCustomPlatformData { + WTF_MAKE_NONCOPYABLE(FontCustomPlatformData); +public: FontCustomPlatformData(cairo_font_face_t* fontFace) : m_fontFace(fontFace) { diff --git a/Source/WebCore/platform/graphics/win/FontWin.cpp b/Source/WebCore/platform/graphics/win/FontWin.cpp index 2170954..2ed9eb3 100644 --- a/Source/WebCore/platform/graphics/win/FontWin.cpp +++ b/Source/WebCore/platform/graphics/win/FontWin.cpp @@ -32,6 +32,7 @@ #include "IntRect.h" #include "Logging.h" #include "SimpleFontData.h" +#include "TextRun.h" #include "UniscribeController.h" #include <wtf/MathExtras.h> diff --git a/Source/WebCore/platform/graphics/win/LocalWindowsContext.h b/Source/WebCore/platform/graphics/win/LocalWindowsContext.h index c216140..5951e49 100644 --- a/Source/WebCore/platform/graphics/win/LocalWindowsContext.h +++ b/Source/WebCore/platform/graphics/win/LocalWindowsContext.h @@ -31,7 +31,8 @@ namespace WebCore { -class LocalWindowsContext : public Noncopyable { +class LocalWindowsContext { + WTF_MAKE_NONCOPYABLE(LocalWindowsContext); public: LocalWindowsContext(GraphicsContext* graphicsContext, const IntRect& rect, bool supportAlphaBlend = true, bool mayCreateBitmap = true) : m_graphicsContext(graphicsContext) diff --git a/Source/WebCore/platform/graphics/win/MediaPlayerPrivateFullscreenWindow.cpp b/Source/WebCore/platform/graphics/win/MediaPlayerPrivateFullscreenWindow.cpp index 7abe2eb..01db7f2 100644 --- a/Source/WebCore/platform/graphics/win/MediaPlayerPrivateFullscreenWindow.cpp +++ b/Source/WebCore/platform/graphics/win/MediaPlayerPrivateFullscreenWindow.cpp @@ -40,7 +40,7 @@ MediaPlayerPrivateFullscreenWindow::MediaPlayerPrivateFullscreenWindow(MediaPlay : m_client(client) , m_hwnd(0) #if USE(ACCELERATED_COMPOSITING) - , m_layerRenderer(WKCACFLayerRenderer::create(0)) + , m_layerTreeHost(CACFLayerTreeHost::create()) #endif { } @@ -81,7 +81,7 @@ void MediaPlayerPrivateFullscreenWindow::createWindow(HWND parentHwnd) ASSERT(IsWindow(m_hwnd)); #if USE(ACCELERATED_COMPOSITING) - m_layerRenderer->setHostWindow(m_hwnd); + m_layerTreeHost->setWindow(m_hwnd); #endif ::SetFocus(m_hwnd); @@ -107,7 +107,7 @@ void MediaPlayerPrivateFullscreenWindow::setRootChildLayer(PassRefPtr<PlatformCA if (!m_rootChild) return; - m_layerRenderer->setRootChildLayer(m_rootChild.get()); + m_layerTreeHost->setRootChildLayer(m_rootChild.get()); PlatformCALayer* rootLayer = m_rootChild->rootLayer(); CGRect rootBounds = m_rootChild->rootLayer()->bounds(); m_rootChild->setFrame(rootBounds); @@ -147,7 +147,7 @@ LRESULT MediaPlayerPrivateFullscreenWindow::wndProc(HWND hWnd, UINT message, WPA case WM_DESTROY: m_hwnd = 0; #if USE(ACCELERATED_COMPOSITING) - m_layerRenderer->setHostWindow(0); + m_layerTreeHost->setWindow(0); #endif break; case WM_WINDOWPOSCHANGED: @@ -156,7 +156,7 @@ LRESULT MediaPlayerPrivateFullscreenWindow::wndProc(HWND hWnd, UINT message, WPA if (wp->flags & SWP_NOSIZE) break; #if USE(ACCELERATED_COMPOSITING) - m_layerRenderer->resize(); + m_layerTreeHost->resize(); PlatformCALayer* rootLayer = m_rootChild->rootLayer(); CGRect rootBounds = m_rootChild->rootLayer()->bounds(); m_rootChild->setFrame(rootBounds); @@ -166,7 +166,7 @@ LRESULT MediaPlayerPrivateFullscreenWindow::wndProc(HWND hWnd, UINT message, WPA break; case WM_PAINT: #if USE(ACCELERATED_COMPOSITING) - m_layerRenderer->paint(); + m_layerTreeHost->paint(); ::ValidateRect(m_hwnd, 0); #endif break; diff --git a/Source/WebCore/platform/graphics/win/MediaPlayerPrivateFullscreenWindow.h b/Source/WebCore/platform/graphics/win/MediaPlayerPrivateFullscreenWindow.h index a18f0cc..c1ae762 100644 --- a/Source/WebCore/platform/graphics/win/MediaPlayerPrivateFullscreenWindow.h +++ b/Source/WebCore/platform/graphics/win/MediaPlayerPrivateFullscreenWindow.h @@ -27,10 +27,9 @@ #define MediaPlayerPrivateFullscreenWindow_h #if USE(ACCELERATED_COMPOSITING) +#include "CACFLayerTreeHost.h" #include "PlatformCALayer.h" -#include "WKCACFLayerRenderer.h" #endif -#include <wtf/OwnPtr.h> typedef unsigned WPARAM; typedef long LPARAM; @@ -59,7 +58,7 @@ public: HWND hwnd() const { return m_hwnd; } #if USE(ACCELERATED_COMPOSITING) - WKCACFLayerRenderer* layerRenderer() const { return m_layerRenderer.get(); } + CACFLayerTreeHost* layerView() const { return m_layerTreeHost.get(); } PlatformCALayer* rootChildLayer() const { return m_rootChild.get(); } void setRootChildLayer(PassRefPtr<PlatformCALayer>); @@ -71,7 +70,7 @@ private: MediaPlayerPrivateFullscreenClient* m_client; #if USE(ACCELERATED_COMPOSITING) - OwnPtr<WKCACFLayerRenderer> m_layerRenderer; + RefPtr<CACFLayerTreeHost> m_layerTreeHost; RefPtr<PlatformCALayer> m_rootChild; #endif HWND m_hwnd; diff --git a/Source/WebCore/platform/graphics/win/QTMovie.cpp b/Source/WebCore/platform/graphics/win/QTMovie.cpp index efaf218..dfa1d36 100644 --- a/Source/WebCore/platform/graphics/win/QTMovie.cpp +++ b/Source/WebCore/platform/graphics/win/QTMovie.cpp @@ -63,7 +63,8 @@ union UppParam { static Vector<CFStringRef>* gSupportedTypes = 0; static SInt32 quickTimeVersion = 0; -class QTMoviePrivate : public Noncopyable, public QTMovieTaskClient { +class QTMoviePrivate : public QTMovieTaskClient { + WTF_MAKE_NONCOPYABLE(QTMoviePrivate); public: QTMoviePrivate(); ~QTMoviePrivate(); diff --git a/Source/WebCore/platform/graphics/win/QTTrack.cpp b/Source/WebCore/platform/graphics/win/QTTrack.cpp index 09142bc..bf80a81 100644 --- a/Source/WebCore/platform/graphics/win/QTTrack.cpp +++ b/Source/WebCore/platform/graphics/win/QTTrack.cpp @@ -31,7 +31,8 @@ using namespace std; -class QTTrackPrivate : public Noncopyable { +class QTTrackPrivate { + WTF_MAKE_NONCOPYABLE(QTTrackPrivate); public: QTTrackPrivate(); ~QTTrackPrivate(); diff --git a/Source/WebCore/platform/graphics/win/UniscribeController.cpp b/Source/WebCore/platform/graphics/win/UniscribeController.cpp index ab32150..dac6c3e 100644 --- a/Source/WebCore/platform/graphics/win/UniscribeController.cpp +++ b/Source/WebCore/platform/graphics/win/UniscribeController.cpp @@ -27,6 +27,7 @@ #include "UniscribeController.h" #include "Font.h" #include "SimpleFontData.h" +#include "TextRun.h" #include <wtf/MathExtras.h> using namespace std; diff --git a/Source/WebCore/platform/graphics/win/WKCACFContextFlusher.cpp b/Source/WebCore/platform/graphics/win/WKCACFContextFlusher.cpp deleted file mode 100644 index d75c854..0000000 --- a/Source/WebCore/platform/graphics/win/WKCACFContextFlusher.cpp +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Copyright (C) 2009 Apple 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 INC. ``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 COMPUTER, INC. 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" - -#if USE(ACCELERATED_COMPOSITING) - -#include "WKCACFContextFlusher.h" - -#include <WebKitSystemInterface/WebKitSystemInterface.h> -#include <wtf/StdLibExtras.h> - -namespace WebCore { - -WKCACFContextFlusher& WKCACFContextFlusher::shared() -{ - DEFINE_STATIC_LOCAL(WKCACFContextFlusher, flusher, ()); - return flusher; -} - -WKCACFContextFlusher::WKCACFContextFlusher() -{ -} - -WKCACFContextFlusher::~WKCACFContextFlusher() -{ -} - -void WKCACFContextFlusher::addContext(WKCACFContext* context) -{ - ASSERT(context); - - m_contexts.add(context); -} - -void WKCACFContextFlusher::removeContext(WKCACFContext* context) -{ - ASSERT(context); - - m_contexts.remove(context); -} - -void WKCACFContextFlusher::flushAllContexts() -{ - // addContext might get called beneath CACFContextFlush, and we don't want m_contexts to change while - // we're iterating over it, so we move the contexts into a local ContextSet and iterate over that instead. - ContextSet contextsToFlush; - contextsToFlush.swap(m_contexts); - - ContextSet::const_iterator end = contextsToFlush.end(); - for (ContextSet::const_iterator it = contextsToFlush.begin(); it != end; ++it) - wkCACFContextFlush(*it); -} - -} - -#endif // USE(ACCELERATED_COMPOSITING) diff --git a/Source/WebCore/platform/graphics/wince/FontCustomPlatformData.h b/Source/WebCore/platform/graphics/wince/FontCustomPlatformData.h index abdc0f2..0508246 100644 --- a/Source/WebCore/platform/graphics/wince/FontCustomPlatformData.h +++ b/Source/WebCore/platform/graphics/wince/FontCustomPlatformData.h @@ -37,7 +37,9 @@ namespace WebCore { virtual void unregisterFont(const String& fontName) = 0; }; - struct FontCustomPlatformData : Noncopyable { + struct FontCustomPlatformData { + WTF_MAKE_NONCOPYABLE(FontCustomPlatformData); + public: FontCustomPlatformData(const String& name) : m_name(name) { diff --git a/Source/WebCore/platform/graphics/wince/FontWinCE.cpp b/Source/WebCore/platform/graphics/wince/FontWinCE.cpp index d636517..5a4c8da 100644 --- a/Source/WebCore/platform/graphics/wince/FontWinCE.cpp +++ b/Source/WebCore/platform/graphics/wince/FontWinCE.cpp @@ -38,6 +38,7 @@ #include "GraphicsContext.h" #include "IntRect.h" #include "NotImplemented.h" +#include "TextRun.h" #include "WidthIterator.h" #include <wtf/MathExtras.h> #include <wtf/OwnPtr.h> diff --git a/Source/WebCore/platform/graphics/wince/GraphicsContextWinCE.cpp b/Source/WebCore/platform/graphics/wince/GraphicsContextWinCE.cpp index 2def6ab..9b672d2 100644 --- a/Source/WebCore/platform/graphics/wince/GraphicsContextWinCE.cpp +++ b/Source/WebCore/platform/graphics/wince/GraphicsContextWinCE.cpp @@ -209,7 +209,7 @@ public: void concatCTM(const AffineTransform& transform) { - m_transform = transform * m_transform; + m_transform *= transform; } IntRect mapRect(const IntRect& rect) const @@ -438,7 +438,8 @@ static void rotateBitmap(SharedBitmap* destBmp, const SharedBitmap* sourceBmp, c _rotateBitmap<unsigned, false>(destBmp, sourceBmp, transform); } -class TransparentLayerDC : Noncopyable { +class TransparentLayerDC { + WTF_MAKE_NONCOPYABLE(TransparentLayerDC); public: TransparentLayerDC(GraphicsContextPlatformPrivate* data, IntRect& origRect, const IntRect* rectBeforeTransform = 0, int alpha = 255, bool paintImage = false); ~TransparentLayerDC(); @@ -558,7 +559,8 @@ void TransparentLayerDC::fillAlphaChannel() } } -class ScopeDCProvider : Noncopyable { +class ScopeDCProvider { + WTF_MAKE_NONCOPYABLE(ScopeDCProvider); public: explicit ScopeDCProvider(GraphicsContextPlatformPrivate* data) : m_data(data) diff --git a/Source/WebCore/platform/graphics/wince/ImageBufferData.h b/Source/WebCore/platform/graphics/wince/ImageBufferData.h index 01b7d06..cbd49dc 100644 --- a/Source/WebCore/platform/graphics/wince/ImageBufferData.h +++ b/Source/WebCore/platform/graphics/wince/ImageBufferData.h @@ -20,15 +20,18 @@ #ifndef ImageBufferData_h #define ImageBufferData_h +#include "SharedBitmap.h" + namespace WebCore { - class IntSize; - class ImageBufferData { - public: - ImageBufferData(const IntSize& size); - RefPtr<SharedBitmap> m_bitmap; - }; +class IntSize; + +class ImageBufferData { +public: + ImageBufferData(const IntSize&); + RefPtr<SharedBitmap> m_bitmap; +}; -} // namespace WebCore +} // namespace WebCore -#endif // ImageBufferData_h +#endif // ImageBufferData_h diff --git a/Source/WebCore/platform/graphics/wince/ImageBufferWinCE.cpp b/Source/WebCore/platform/graphics/wince/ImageBufferWinCE.cpp index 537d27d..b5118f6 100644 --- a/Source/WebCore/platform/graphics/wince/ImageBufferWinCE.cpp +++ b/Source/WebCore/platform/graphics/wince/ImageBufferWinCE.cpp @@ -88,6 +88,11 @@ ImageBuffer::~ImageBuffer() { } +size_t ImageBuffer::dataSize() const +{ + return m_size.width() * m_size.height() * 4; +} + GraphicsContext* ImageBuffer::context() const { return m_context.get(); diff --git a/Source/WebCore/platform/graphics/wince/SharedBitmap.cpp b/Source/WebCore/platform/graphics/wince/SharedBitmap.cpp index 05d1535..168a5e2 100644 --- a/Source/WebCore/platform/graphics/wince/SharedBitmap.cpp +++ b/Source/WebCore/platform/graphics/wince/SharedBitmap.cpp @@ -445,8 +445,7 @@ void SharedBitmap::drawPattern(HDC hdc, const AffineTransform& transform, const bmpHeight = tileRect.height(); } - AffineTransform tf = transform; - tf *= patternTransform; + AffineTransform tf = patternTransform * transform; FloatRect trRect = tf.mapRect(destRect); diff --git a/Source/WebCore/platform/graphics/wx/FontCustomPlatformData.h b/Source/WebCore/platform/graphics/wx/FontCustomPlatformData.h index cc348e3..86f99b2 100644 --- a/Source/WebCore/platform/graphics/wx/FontCustomPlatformData.h +++ b/Source/WebCore/platform/graphics/wx/FontCustomPlatformData.h @@ -24,14 +24,14 @@ #include "FontOrientation.h" #include "FontRenderingMode.h" #include <wtf/Forward.h> -#include <wtf/Noncopyable.h> namespace WebCore { class FontPlatformData; class SharedBuffer; - struct FontCustomPlatformData : Noncopyable { + struct FontCustomPlatformData { + WTF_MAKE_NONCOPYABLE(FontCustomPlatformData); public: FontCustomPlatformData() { } ~FontCustomPlatformData(); diff --git a/Source/WebCore/platform/graphics/wx/ImageBufferWx.cpp b/Source/WebCore/platform/graphics/wx/ImageBufferWx.cpp index ba33287..b603a60 100644 --- a/Source/WebCore/platform/graphics/wx/ImageBufferWx.cpp +++ b/Source/WebCore/platform/graphics/wx/ImageBufferWx.cpp @@ -48,6 +48,12 @@ ImageBuffer::~ImageBuffer() { } +size_t ImageBuffer::dataSize() const +{ + notImplemented(); + return 0; +} + GraphicsContext* ImageBuffer::context() const { notImplemented(); |
