diff options
Diffstat (limited to 'Source/WebCore/platform/graphics')
151 files changed, 1688 insertions, 2212 deletions
diff --git a/Source/WebCore/platform/graphics/BitmapImage.cpp b/Source/WebCore/platform/graphics/BitmapImage.cpp index 04528591a..45460f8d3 100644 --- a/Source/WebCore/platform/graphics/BitmapImage.cpp +++ b/Source/WebCore/platform/graphics/BitmapImage.cpp @@ -304,7 +304,7 @@ NativeImagePtr BitmapImage::frameAtIndex(size_t index) bool BitmapImage::frameIsCompleteAtIndex(size_t index) { if (!ensureFrameIsCached(index)) - return true; // Why would an invalid index return true here? + return false; return m_frames[index].m_isComplete; } @@ -563,11 +563,4 @@ Color BitmapImage::solidColor() const return m_solidColor; } -#if !USE(CG) -void BitmapImage::draw(GraphicsContext* ctx, const FloatRect& dstRect, const FloatRect& srcRect, ColorSpace styleColorSpace, CompositeOperator op, RespectImageOrientationEnum) -{ - draw(ctx, dstRect, srcRect, styleColorSpace, op); -} -#endif - } diff --git a/Source/WebCore/platform/graphics/BitmapImage.h b/Source/WebCore/platform/graphics/BitmapImage.h index 21885cdd4..f5bfeb145 100644 --- a/Source/WebCore/platform/graphics/BitmapImage.h +++ b/Source/WebCore/platform/graphics/BitmapImage.h @@ -199,7 +199,9 @@ protected: virtual void drawFrameMatchingSourceSize(GraphicsContext*, const FloatRect& dstRect, const IntSize& srcSize, ColorSpace styleColorSpace, CompositeOperator); #endif virtual void draw(GraphicsContext*, const FloatRect& dstRect, const FloatRect& srcRect, ColorSpace styleColorSpace, CompositeOperator); - void draw(GraphicsContext*, const FloatRect& dstRect, const FloatRect& srcRect, ColorSpace styleColorSpace, CompositeOperator, RespectImageOrientationEnum); +#if USE(CG) + virtual void draw(GraphicsContext*, const FloatRect& dstRect, const FloatRect& srcRect, ColorSpace styleColorSpace, CompositeOperator, RespectImageOrientationEnum); +#endif #if (OS(WINCE) && !PLATFORM(QT)) virtual void drawPattern(GraphicsContext*, const FloatRect& srcRect, const AffineTransform& patternTransform, diff --git a/Source/WebCore/platform/graphics/FractionalLayoutBoxExtent.cpp b/Source/WebCore/platform/graphics/FractionalLayoutBoxExtent.cpp index 1fd52a919..e4e545a1b 100644 --- a/Source/WebCore/platform/graphics/FractionalLayoutBoxExtent.cpp +++ b/Source/WebCore/platform/graphics/FractionalLayoutBoxExtent.cpp @@ -35,6 +35,16 @@ namespace WebCore { +FractionalLayoutUnit FractionalLayoutBoxExtent::logicalTop(const RenderStyle* style) const +{ + return style->isHorizontalWritingMode() ? m_top : m_left; +} + +FractionalLayoutUnit FractionalLayoutBoxExtent::logicalBottom(const RenderStyle* style) const +{ + return style->isHorizontalWritingMode() ? m_bottom : m_right; +} + FractionalLayoutUnit FractionalLayoutBoxExtent::logicalLeft(const RenderStyle* style) const { return style->isHorizontalWritingMode() ? m_left : m_top; diff --git a/Source/WebCore/platform/graphics/FractionalLayoutBoxExtent.h b/Source/WebCore/platform/graphics/FractionalLayoutBoxExtent.h index af9630880..921c84b90 100644 --- a/Source/WebCore/platform/graphics/FractionalLayoutBoxExtent.h +++ b/Source/WebCore/platform/graphics/FractionalLayoutBoxExtent.h @@ -53,6 +53,8 @@ public: inline void setBottom(FractionalLayoutUnit value) { m_bottom = value; } inline void setLeft(FractionalLayoutUnit value) { m_left = value; } + FractionalLayoutUnit logicalTop(const RenderStyle*) const; + FractionalLayoutUnit logicalBottom(const RenderStyle*) const; FractionalLayoutUnit logicalLeft(const RenderStyle*) const; FractionalLayoutUnit logicalRight(const RenderStyle*) const; diff --git a/Source/WebCore/platform/graphics/FractionalLayoutRect.h b/Source/WebCore/platform/graphics/FractionalLayoutRect.h index d91be931a..a06d17508 100644 --- a/Source/WebCore/platform/graphics/FractionalLayoutRect.h +++ b/Source/WebCore/platform/graphics/FractionalLayoutRect.h @@ -31,6 +31,7 @@ #ifndef FractionalLayoutRect_h #define FractionalLayoutRect_h +#include "FractionalLayoutBoxExtent.h" #include "FractionalLayoutPoint.h" #include "IntRect.h" #include <wtf/Vector.h> @@ -99,6 +100,11 @@ public: void move(FractionalLayoutUnit dx, FractionalLayoutUnit dy) { m_location.move(dx, dy); } void expand(const FractionalLayoutSize& size) { m_size += size; } + void expand(const FractionalLayoutBoxExtent& box) + { + m_location.move(-box.left(), -box.top()); + m_size.expand(box.left() + box.right(), box.top() + box.bottom()); + } void expand(FractionalLayoutUnit dw, FractionalLayoutUnit dh) { m_size.expand(dw, dh); } void contract(const FractionalLayoutSize& size) { m_size -= size; } void contract(FractionalLayoutUnit dw, FractionalLayoutUnit dh) { m_size.expand(-dw, -dh); } diff --git a/Source/WebCore/platform/graphics/Gradient.h b/Source/WebCore/platform/graphics/Gradient.h index 5e36ff3c3..6ae483ac8 100644 --- a/Source/WebCore/platform/graphics/Gradient.h +++ b/Source/WebCore/platform/graphics/Gradient.h @@ -39,7 +39,7 @@ typedef struct CGContext* CGContextRef; -#define USE_CG_SHADING defined(BUILDING_ON_LEOPARD) +#define USE_CG_SHADING (PLATFORM(MAC) && !PLATFORM(IOS) && __MAC_OS_X_VERSION_MIN_REQUIRED == 1050) #if USE_CG_SHADING typedef struct CGShading* CGShadingRef; diff --git a/Source/WebCore/platform/graphics/GraphicsContext.cpp b/Source/WebCore/platform/graphics/GraphicsContext.cpp index bf1f8c056..6664b8644 100644 --- a/Source/WebCore/platform/graphics/GraphicsContext.cpp +++ b/Source/WebCore/platform/graphics/GraphicsContext.cpp @@ -490,10 +490,7 @@ void GraphicsContext::drawImage(Image* image, ColorSpace styleColorSpace, const #endif } - if (image->isBitmapImage()) - static_cast<BitmapImage*>(image)->draw(this, FloatRect(dest.location(), FloatSize(tw, th)), FloatRect(src.location(), FloatSize(tsw, tsh)), styleColorSpace, op, shouldRespectImageOrientation); - else - image->draw(this, FloatRect(dest.location(), FloatSize(tw, th)), FloatRect(src.location(), FloatSize(tsw, tsh)), styleColorSpace, op); + image->draw(this, FloatRect(dest.location(), FloatSize(tw, th)), FloatRect(src.location(), FloatSize(tsw, tsh)), styleColorSpace, op, shouldRespectImageOrientation); if (useLowQualityScale) setImageInterpolationQuality(previousInterpolationQuality); diff --git a/Source/WebCore/platform/graphics/GraphicsContext3D.h b/Source/WebCore/platform/graphics/GraphicsContext3D.h index 51eef09c5..1e6184293 100644 --- a/Source/WebCore/platform/graphics/GraphicsContext3D.h +++ b/Source/WebCore/platform/graphics/GraphicsContext3D.h @@ -956,10 +956,7 @@ public: ANGLEWebKitBridge m_compiler; #endif -#if PLATFORM(QT) && defined(QT_OPENGL_ES_2) - friend class Extensions3DQt; - OwnPtr<Extensions3DQt> m_extensions; -#elif PLATFORM(BLACKBERRY) +#if PLATFORM(BLACKBERRY) || (PLATFORM(QT) && defined(QT_OPENGL_ES_2)) friend class Extensions3DOpenGLES; OwnPtr<Extensions3DOpenGLES> m_extensions; #elif !PLATFORM(CHROMIUM) diff --git a/Source/WebCore/platform/graphics/GraphicsLayer.cpp b/Source/WebCore/platform/graphics/GraphicsLayer.cpp index 9a52fb67b..dda637311 100644 --- a/Source/WebCore/platform/graphics/GraphicsLayer.cpp +++ b/Source/WebCore/platform/graphics/GraphicsLayer.cpp @@ -79,6 +79,7 @@ GraphicsLayer::GraphicsLayer(GraphicsLayerClient* client) , m_acceleratesDrawing(false) , m_maintainsPixelAlignment(false) , m_appliesPageScale(false) + , m_usingTileCache(false) , m_paintingPhase(GraphicsLayerPaintAll) , m_contentsOrientation(CompositingCoordinatesTopDown) , m_parent(0) @@ -340,9 +341,7 @@ void GraphicsLayer::updateDebugIndicators() { if (GraphicsLayer::showDebugBorders()) { if (drawsContent()) { - // FIXME: It's weird to ask the client if this layer is a tile cache layer. - // Maybe we should just cache that information inside GraphicsLayer? - if (m_client->shouldUseTileCache(this)) // tile cache layer: dark blue + if (m_usingTileCache) // tile cache layer: dark blue setDebugBorder(Color(0, 0, 128, 128), 0.5); else if (m_usingTiledLayer) setDebugBorder(Color(255, 128, 0, 128), 2); // tiled layer: orange diff --git a/Source/WebCore/platform/graphics/GraphicsLayer.h b/Source/WebCore/platform/graphics/GraphicsLayer.h index 7939717fa..ccd61fb9e 100644 --- a/Source/WebCore/platform/graphics/GraphicsLayer.h +++ b/Source/WebCore/platform/graphics/GraphicsLayer.h @@ -466,6 +466,7 @@ protected: bool m_acceleratesDrawing : 1; bool m_maintainsPixelAlignment : 1; bool m_appliesPageScale : 1; // Set for the layer which has the page scale applied to it. + bool m_usingTileCache : 1; GraphicsLayerPaintingPhase m_paintingPhase; CompositingCoordinatesOrientation m_contentsOrientation; // affects orientation of layer contents diff --git a/Source/WebCore/platform/graphics/texmap/TextureMapperAnimation.cpp b/Source/WebCore/platform/graphics/GraphicsLayerAnimation.cpp index aa022a24e..ef8232c5d 100644 --- a/Source/WebCore/platform/graphics/texmap/TextureMapperAnimation.cpp +++ b/Source/WebCore/platform/graphics/GraphicsLayerAnimation.cpp @@ -18,12 +18,11 @@ */ #include "config.h" -#include "TextureMapperAnimation.h" +#include "GraphicsLayerAnimation.h" #include "UnitBezier.h" #include <wtf/CurrentTime.h> -#if USE(TEXTURE_MAPPER) namespace WebCore { @@ -145,7 +144,7 @@ static TransformationMatrix applyTransformAnimation(const TransformOperations* f } -TextureMapperAnimation::TextureMapperAnimation(const KeyframeValueList& keyframes, const IntSize& boxSize, const Animation* animation, double timeOffset, bool listsMatch) +GraphicsLayerAnimation::GraphicsLayerAnimation(const KeyframeValueList& keyframes, const IntSize& boxSize, const Animation* animation, double timeOffset, bool listsMatch) : m_keyframes(keyframes) , m_boxSize(boxSize) , m_animation(Animation::create(animation)) @@ -156,21 +155,21 @@ TextureMapperAnimation::TextureMapperAnimation(const KeyframeValueList& keyframe { } -void TextureMapperAnimation::applyInternal(TextureMapperAnimationClient* client, const AnimationValue* from, const AnimationValue* to, float progress) +void GraphicsLayerAnimation::applyInternal(Client* client, const AnimationValue* from, const AnimationValue* to, float progress) { switch (m_keyframes.property()) { case AnimatedPropertyOpacity: - client->setOpacity(applyOpacityAnimation((static_cast<const FloatAnimationValue*>(from)->value()), (static_cast<const FloatAnimationValue*>(to)->value()), progress)); + client->setAnimatedOpacity(applyOpacityAnimation((static_cast<const FloatAnimationValue*>(from)->value()), (static_cast<const FloatAnimationValue*>(to)->value()), progress)); return; case AnimatedPropertyWebkitTransform: - client->setTransform(applyTransformAnimation(static_cast<const TransformAnimationValue*>(from)->value(), static_cast<const TransformAnimationValue*>(to)->value(), progress, m_boxSize, m_listsMatch)); + client->setAnimatedTransform(applyTransformAnimation(static_cast<const TransformAnimationValue*>(from)->value(), static_cast<const TransformAnimationValue*>(to)->value(), progress, m_boxSize, m_listsMatch)); return; default: ASSERT_NOT_REACHED(); } } -bool TextureMapperAnimation::isActive() const +bool GraphicsLayerAnimation::isActive() const { if (state() != StoppedState) return true; @@ -178,11 +177,11 @@ bool TextureMapperAnimation::isActive() const return m_animation->fillsForwards(); } -bool TextureMapperAnimations::hasActiveAnimationsOfType(AnimatedPropertyID type) const +bool GraphicsLayerAnimations::hasActiveAnimationsOfType(AnimatedPropertyID type) const { - HashMap<String, Vector<TextureMapperAnimation> >::const_iterator end = m_animations.end(); - for (HashMap<String, Vector<TextureMapperAnimation> >::const_iterator it = m_animations.begin(); it != end; ++it) { - const Vector<TextureMapperAnimation>& animations = it->second; + HashMap<String, Vector<GraphicsLayerAnimation> >::const_iterator end = m_animations.end(); + for (HashMap<String, Vector<GraphicsLayerAnimation> >::const_iterator it = m_animations.begin(); it != end; ++it) { + const Vector<GraphicsLayerAnimation>& animations = it->second; for (size_t i = 0; i < animations.size(); ++i) { if (animations[i].isActive() && animations[i].property() == type) return true; @@ -191,13 +190,13 @@ bool TextureMapperAnimations::hasActiveAnimationsOfType(AnimatedPropertyID type) return false; } -bool TextureMapperAnimations::hasRunningAnimations() const +bool GraphicsLayerAnimations::hasRunningAnimations() const { - HashMap<String, Vector<TextureMapperAnimation> >::const_iterator end = m_animations.end(); - for (HashMap<String, Vector<TextureMapperAnimation> >::const_iterator it = m_animations.begin(); it != end; ++it) { - const Vector<TextureMapperAnimation>& animations = it->second; + HashMap<String, Vector<GraphicsLayerAnimation> >::const_iterator end = m_animations.end(); + for (HashMap<String, Vector<GraphicsLayerAnimation> >::const_iterator it = m_animations.begin(); it != end; ++it) { + const Vector<GraphicsLayerAnimation>& animations = it->second; for (size_t i = 0; i < animations.size(); ++i) { - if (animations[i].state() == TextureMapperAnimation::PlayingState) + if (animations[i].state() == GraphicsLayerAnimation::PlayingState) return true; } } @@ -205,7 +204,7 @@ bool TextureMapperAnimations::hasRunningAnimations() const return false; } -void TextureMapperAnimation::apply(TextureMapperAnimationClient* client) +void GraphicsLayerAnimation::apply(Client* client) { if (state() == StoppedState) return; @@ -244,29 +243,29 @@ void TextureMapperAnimation::apply(TextureMapperAnimationClient* client) } } -void TextureMapperAnimation::pause(double offset) +void GraphicsLayerAnimation::pause(double offset) { // FIXME: should apply offset here. setState(PausedState); m_pauseTime = WTF::currentTime() - offset; } -void TextureMapperAnimations::add(const String& name, const TextureMapperAnimation& animation) +void GraphicsLayerAnimations::add(const String& name, const GraphicsLayerAnimation& animation) { - HashMap<String, Vector<TextureMapperAnimation> >::iterator it = m_animations.find(name); + HashMap<String, Vector<GraphicsLayerAnimation> >::iterator it = m_animations.find(name); if (it != m_animations.end()) { it->second.append(animation); return; } - Vector<TextureMapperAnimation> animations; + Vector<GraphicsLayerAnimation> animations; animations.append(animation); m_animations.add(name, animations); } -void TextureMapperAnimations::pause(const String& name, double offset) +void GraphicsLayerAnimations::pause(const String& name, double offset) { - HashMap<String, Vector<TextureMapperAnimation> >::iterator it = m_animations.find(name); + HashMap<String, Vector<GraphicsLayerAnimation> >::iterator it = m_animations.find(name); if (it == m_animations.end()) return; @@ -274,14 +273,13 @@ void TextureMapperAnimations::pause(const String& name, double offset) it->second[i].pause(offset); } -void TextureMapperAnimations::apply(TextureMapperAnimationClient* client) +void GraphicsLayerAnimations::apply(GraphicsLayerAnimation::Client* client) { - HashMap<String, Vector<TextureMapperAnimation> >::iterator end = m_animations.end(); - for (HashMap<String, Vector<TextureMapperAnimation> >::iterator it = m_animations.begin(); it != end; ++it) { + HashMap<String, Vector<GraphicsLayerAnimation> >::iterator end = m_animations.end(); + for (HashMap<String, Vector<GraphicsLayerAnimation> >::iterator it = m_animations.begin(); it != end; ++it) { for (size_t i = 0; i < it->second.size(); ++i) it->second[i].apply(client); } } } -#endif diff --git a/Source/WebCore/platform/graphics/texmap/TextureMapperAnimation.h b/Source/WebCore/platform/graphics/GraphicsLayerAnimation.h index d0e90b518..2fbc05a12 100644 --- a/Source/WebCore/platform/graphics/texmap/TextureMapperAnimation.h +++ b/Source/WebCore/platform/graphics/GraphicsLayerAnimation.h @@ -17,32 +17,30 @@ Boston, MA 02110-1301, USA. */ -#ifndef TextureMapperAnimation_h -#define TextureMapperAnimation_h +#ifndef GraphicsLayerAnimation_h +#define GraphicsLayerAnimation_h #include "GraphicsLayer.h" #include "TransformationMatrix.h" #include <wtf/HashMap.h> #include <wtf/text/StringHash.h> -#if USE(TEXTURE_MAPPER) namespace WebCore { -class TextureMapperAnimationClient { -public: - virtual void setTransform(const TransformationMatrix&) = 0; - virtual void setOpacity(float) = 0; -}; - -class TextureMapperAnimation { +class GraphicsLayerAnimation { public: enum AnimationState { PlayingState, PausedState, StoppedState }; + class Client { + public: + virtual void setAnimatedTransform(const TransformationMatrix&) = 0; + virtual void setAnimatedOpacity(float) = 0; + }; - TextureMapperAnimation() + GraphicsLayerAnimation() : m_keyframes(AnimatedPropertyInvalid) { } - TextureMapperAnimation(const KeyframeValueList&, const IntSize&, const Animation*, double, bool); - void apply(TextureMapperAnimationClient*); + GraphicsLayerAnimation(const KeyframeValueList&, const IntSize&, const Animation*, double, bool); + void apply(Client*); void pause(double); AnimationState state() const { return m_state; } void setState(AnimationState s) { m_state = s; } @@ -50,7 +48,7 @@ public: bool isActive() const; private: - void applyInternal(TextureMapperAnimationClient*, const AnimationValue* from, const AnimationValue* to, float progress); + void applyInternal(Client*, const AnimationValue* from, const AnimationValue* to, float progress); KeyframeValueList m_keyframes; IntSize m_boxSize; RefPtr<Animation> m_animation; @@ -62,24 +60,22 @@ private: AnimationState m_state; }; -class TextureMapperAnimations { +class GraphicsLayerAnimations { public: - TextureMapperAnimations() { } + GraphicsLayerAnimations() { } - void add(const String&, const TextureMapperAnimation&); + void add(const String&, const GraphicsLayerAnimation&); void remove(const String& name) { m_animations.remove(name); } void pause(const String&, double); - void apply(TextureMapperAnimationClient*); + void apply(GraphicsLayerAnimation::Client*); bool isEmpty() const { return m_animations.isEmpty(); } bool hasRunningAnimations() const; bool hasActiveAnimationsOfType(AnimatedPropertyID type) const; private: - HashMap<String, Vector<TextureMapperAnimation> > m_animations; + HashMap<String, Vector<GraphicsLayerAnimation> > m_animations; }; } -#endif // USE(TEXTURE_MAPPER) - -#endif // TextureMapperAnimation_h +#endif // GraphicsLayerAnimation_h diff --git a/Source/WebCore/platform/graphics/GraphicsLayerClient.h b/Source/WebCore/platform/graphics/GraphicsLayerClient.h index 36a7f4365..7049e4226 100644 --- a/Source/WebCore/platform/graphics/GraphicsLayerClient.h +++ b/Source/WebCore/platform/graphics/GraphicsLayerClient.h @@ -56,6 +56,7 @@ public: virtual ~GraphicsLayerClient() {} virtual bool shouldUseTileCache(const GraphicsLayer*) const { return false; } + virtual bool usingTileCache(const GraphicsLayer*) const { return false; } // Callback for when hardware-accelerated animation started. virtual void notifyAnimationStarted(const GraphicsLayer*, double time) = 0; diff --git a/Source/WebCore/platform/graphics/texmap/LayerTransform.cpp b/Source/WebCore/platform/graphics/GraphicsLayerTransform.cpp index 1c3c02e57..77cac87d6 100644 --- a/Source/WebCore/platform/graphics/texmap/LayerTransform.cpp +++ b/Source/WebCore/platform/graphics/GraphicsLayerTransform.cpp @@ -18,60 +18,60 @@ */ #include "config.h" -#include "LayerTransform.h" +#include "GraphicsLayerTransform.h" namespace WebCore { -LayerTransform::LayerTransform() -: m_flattening(false) -, m_dirty(false) // false by default since all default values would be combined as the identity matrix -, m_childrenDirty(false) +GraphicsLayerTransform::GraphicsLayerTransform() + : m_flattening(false) + , m_dirty(false) // false by default since all default values would be combined as the identity matrix + , m_childrenDirty(false) { } -void LayerTransform::setPosition(const FloatPoint& position) +void GraphicsLayerTransform::setPosition(const FloatPoint& position) { m_position = position; m_dirty = true; } -void LayerTransform::setSize(const FloatSize& size) +void GraphicsLayerTransform::setSize(const FloatSize& size) { m_size = size; m_dirty = true; } -void LayerTransform::setAnchorPoint(const FloatPoint3D& anchorPoint) +void GraphicsLayerTransform::setAnchorPoint(const FloatPoint3D& anchorPoint) { m_anchorPoint = anchorPoint; m_dirty = true; } -void LayerTransform::setFlattening(bool flattening) +void GraphicsLayerTransform::setFlattening(bool flattening) { m_flattening = flattening; m_dirty = true; } -void LayerTransform::setLocalTransform(const TransformationMatrix& transform) +void GraphicsLayerTransform::setLocalTransform(const TransformationMatrix& transform) { m_local = transform; m_dirty = true; } -void LayerTransform::setChildrenTransform(const TransformationMatrix& transform) +void GraphicsLayerTransform::setChildrenTransform(const TransformationMatrix& transform) { m_children = transform; m_dirty = true; } -TransformationMatrix LayerTransform::combined() +TransformationMatrix GraphicsLayerTransform::combined() { ASSERT(!m_dirty); return m_combined; } -TransformationMatrix LayerTransform::combinedForChildren() +TransformationMatrix GraphicsLayerTransform::combinedForChildren() { ASSERT(!m_dirty); if (m_childrenDirty) @@ -79,7 +79,7 @@ TransformationMatrix LayerTransform::combinedForChildren() return m_combinedForChildren; } -void LayerTransform::combineTransforms(const TransformationMatrix& parentTransform) +void GraphicsLayerTransform::combineTransforms(const TransformationMatrix& parentTransform) { float originX = m_anchorPoint.x() * m_size.width(); float originY = m_anchorPoint.y() * m_size.height(); @@ -96,7 +96,7 @@ void LayerTransform::combineTransforms(const TransformationMatrix& parentTransfo m_childrenDirty = true; } -void LayerTransform::combineTransformsForChildren() +void GraphicsLayerTransform::combineTransformsForChildren() { ASSERT(!m_dirty); ASSERT(m_childrenDirty); diff --git a/Source/WebCore/platform/graphics/texmap/LayerTransform.h b/Source/WebCore/platform/graphics/GraphicsLayerTransform.h index b73818501..5da25b4d8 100644 --- a/Source/WebCore/platform/graphics/texmap/LayerTransform.h +++ b/Source/WebCore/platform/graphics/GraphicsLayerTransform.h @@ -17,8 +17,8 @@ Boston, MA 02110-1301, USA. */ -#ifndef LayerTransform_h -#define LayerTransform_h +#ifndef GraphicsLayerTransform_h +#define GraphicsLayerTransform_h #include "FloatPoint.h" #include "FloatPoint3D.h" @@ -27,9 +27,9 @@ namespace WebCore { -class LayerTransform { +class GraphicsLayerTransform { public: - LayerTransform(); + GraphicsLayerTransform(); void setPosition(const FloatPoint&); void setSize(const FloatSize&); void setAnchorPoint(const FloatPoint3D&); @@ -59,4 +59,4 @@ private: } -#endif // LayerTransform_h +#endif // GraphicsLayerTransform_h diff --git a/Source/WebCore/platform/graphics/Image.cpp b/Source/WebCore/platform/graphics/Image.cpp index 0ace7ac20..2b19f1349 100644 --- a/Source/WebCore/platform/graphics/Image.cpp +++ b/Source/WebCore/platform/graphics/Image.cpp @@ -89,6 +89,11 @@ void Image::fillWithSolidColor(GraphicsContext* ctxt, const FloatRect& dstRect, ctxt->setCompositeOperation(previousOperator); } +void Image::draw(GraphicsContext* ctx, const FloatRect& dstRect, const FloatRect& srcRect, ColorSpace styleColorSpace, CompositeOperator op, RespectImageOrientationEnum) +{ + draw(ctx, dstRect, srcRect, styleColorSpace, op); +} + void Image::drawTiled(GraphicsContext* ctxt, const FloatRect& destRect, const FloatPoint& srcPoint, const FloatSize& scaledTileSize, ColorSpace styleColorSpace, CompositeOperator op) { if (mayFillWithSolidColor()) { diff --git a/Source/WebCore/platform/graphics/Image.h b/Source/WebCore/platform/graphics/Image.h index 3ff48236a..a6b949047 100644 --- a/Source/WebCore/platform/graphics/Image.h +++ b/Source/WebCore/platform/graphics/Image.h @@ -181,6 +181,7 @@ protected: virtual void drawFrameMatchingSourceSize(GraphicsContext*, const FloatRect& dstRect, const IntSize& srcSize, ColorSpace styleColorSpace, CompositeOperator) { } #endif virtual void draw(GraphicsContext*, const FloatRect& dstRect, const FloatRect& srcRect, ColorSpace styleColorSpace, CompositeOperator) = 0; + virtual void draw(GraphicsContext*, const FloatRect& dstRect, const FloatRect& srcRect, ColorSpace styleColorSpace, CompositeOperator, RespectImageOrientationEnum); void drawTiled(GraphicsContext*, const FloatRect& dstRect, const FloatPoint& srcPoint, const FloatSize& tileSize, ColorSpace styleColorSpace, CompositeOperator); void drawTiled(GraphicsContext*, const FloatRect& dstRect, const FloatRect& srcRect, const FloatSize& tileScaleFactor, TileRule hRule, TileRule vRule, ColorSpace styleColorSpace, CompositeOperator); diff --git a/Source/WebCore/platform/graphics/MediaPlayer.cpp b/Source/WebCore/platform/graphics/MediaPlayer.cpp index 73aacd496..ec622437e 100644 --- a/Source/WebCore/platform/graphics/MediaPlayer.cpp +++ b/Source/WebCore/platform/graphics/MediaPlayer.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserved. + * Copyright (C) 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -208,7 +208,7 @@ static Vector<MediaPlayerFactory*>& installedMediaEngines() enginesQueried = true; #if USE(AVFOUNDATION) - if (Settings::isAVFoundationEnabled()) { + if (1 /* @@Settings::isAVFoundationEnabled() @@ */) { #if PLATFORM(MAC) MediaPlayerPrivateAVFoundationObjC::registerMediaEngine(addMediaEngine); #elif PLATFORM(WIN) @@ -1068,6 +1068,16 @@ String MediaPlayer::userAgent() const return m_mediaPlayerClient->mediaPlayerUserAgent(); } +#if PLATFORM(WIN) && USE(AVFOUNDATION) +GraphicsDeviceAdapter* MediaPlayer::graphicsDeviceAdapter() const +{ + if (!m_mediaPlayerClient) + return 0; + + return m_mediaPlayerClient->mediaPlayerGraphicsDeviceAdapter(this); +} +#endif + } #endif diff --git a/Source/WebCore/platform/graphics/MediaPlayer.h b/Source/WebCore/platform/graphics/MediaPlayer.h index 8eb728596..3b382d83a 100644 --- a/Source/WebCore/platform/graphics/MediaPlayer.h +++ b/Source/WebCore/platform/graphics/MediaPlayer.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserved. + * Copyright (C) 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -99,6 +99,10 @@ class MediaPlayer; struct MediaPlayerFactory; class TimeRanges; +#if PLATFORM(WIN) && USE(AVFOUNDATION) +struct GraphicsDeviceAdapter; +#endif + class MediaPlayerClient { public: enum CORSMode { Unspecified, Anonymous, UseCredentials }; @@ -165,6 +169,10 @@ public: virtual void mediaPlayerRenderingModeChanged(MediaPlayer*) { } #endif +#if PLATFORM(WIN) && USE(AVFOUNDATION) + virtual GraphicsDeviceAdapter* mediaPlayerGraphicsDeviceAdapter(const MediaPlayer*) const { return 0; } +#endif + #if ENABLE(MEDIA_SOURCE) virtual void mediaPlayerSourceOpened() { } virtual String mediaPlayerSourceURL() const { return "x-media-source-unsupported:"; } @@ -356,6 +364,10 @@ public: void acceleratedRenderingStateChanged(); #endif +#if PLATFORM(WIN) && USE(AVFOUNDATION) + GraphicsDeviceAdapter* graphicsDeviceAdapter() const; +#endif + bool hasSingleSecurityOrigin() const; bool didPassCORSAccessCheck() const; diff --git a/Source/WebCore/platform/graphics/OpenGLESShims.h b/Source/WebCore/platform/graphics/OpenGLESShims.h index 052af5e45..4e0951201 100644 --- a/Source/WebCore/platform/graphics/OpenGLESShims.h +++ b/Source/WebCore/platform/graphics/OpenGLESShims.h @@ -26,7 +26,7 @@ #ifndef OpenGLESShims_h #define OpenGLESShims_h -#if PLATFORM(BLACKBERRY) +#if PLATFORM(BLACKBERRY) || PLATFORM(QT) #define glBindFramebufferEXT glBindFramebuffer #define glFramebufferTexture2DEXT glFramebufferTexture2D #define glBindRenderbufferEXT glBindRenderbuffer diff --git a/Source/WebCore/platform/graphics/avfoundation/cf/AVFoundationCFSoftLinking.h b/Source/WebCore/platform/graphics/avfoundation/cf/AVFoundationCFSoftLinking.h index 04098002d..95b9403bf 100644 --- a/Source/WebCore/platform/graphics/avfoundation/cf/AVFoundationCFSoftLinking.h +++ b/Source/WebCore/platform/graphics/avfoundation/cf/AVFoundationCFSoftLinking.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2011 Apple Inc. All rights reserved. + * Copyright (C) 2011, 2012 Apple Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -177,6 +177,8 @@ SOFT_LINK_DLL_IMPORT(AVFoundationCF, AVCFURLAssetCopyAudiovisualMIMETypes, CFArr SOFT_LINK_DLL_IMPORT(AVFoundationCF, AVCFURLAssetCreateWithURLAndOptions, AVCFURLAssetRef, __cdecl, (CFAllocatorRef allocator, CFURLRef URL, CFDictionaryRef options, dispatch_queue_t notificationQueue), (allocator, URL, options, notificationQueue)) #define AVCFURLAssetCreateWithURLAndOptions softLink_AVCFURLAssetCreateWithURLAndOptions +SOFT_LINK_DLL_IMPORT_OPTIONAL(AVFoundationCF, AVCFPlayerSetDirect3DDevice, void, __cdecl, (AVCFPlayerRef player, IDirect3DDevice9* d3dDevice)) + // Variables SOFT_LINK_VARIABLE_DLL_IMPORT(AVFoundationCF, AVCFAssetImageGeneratorApertureModeCleanAperture, const CFStringRef); @@ -244,3 +246,6 @@ SOFT_LINK_VARIABLE_DLL_IMPORT(AVFoundationCF, AVCFPlayerItemTracksChangedNotific SOFT_LINK_VARIABLE_DLL_IMPORT(AVFoundationCF, AVCFPlayerRateChangedNotification, const CFStringRef); #define AVCFPlayerRateChangedNotification get_AVCFPlayerRateChangedNotification() + +SOFT_LINK_VARIABLE_DLL_IMPORT_OPTIONAL(AVFoundationCF, AVCFPlayerEnableHardwareAcceleratedVideoDecoderKey, const CFStringRef); +#define AVCFPlayerEnableHardwareAcceleratedVideoDecoderKey get_AVCFPlayerEnableHardwareAcceleratedVideoDecoderKey() diff --git a/Source/WebCore/platform/graphics/avfoundation/cf/MediaPlayerPrivateAVFoundationCF.cpp b/Source/WebCore/platform/graphics/avfoundation/cf/MediaPlayerPrivateAVFoundationCF.cpp index a9f39a40d..81d862981 100644 --- a/Source/WebCore/platform/graphics/avfoundation/cf/MediaPlayerPrivateAVFoundationCF.cpp +++ b/Source/WebCore/platform/graphics/avfoundation/cf/MediaPlayerPrivateAVFoundationCF.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2011 Apple Inc. All rights reserved. + * Copyright (C) 2011, 2012 Apple Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -32,6 +32,7 @@ #include "MediaPlayerPrivateAVFoundationCF.h" #include "ApplicationCacheResource.h" +#include "COMPtr.h" #include "FloatConversion.h" #include "FrameView.h" #include "GraphicsContext.h" @@ -44,9 +45,9 @@ #include <AVFoundationCF/AVCFPlayerLayer.h> #include <AVFoundationCF/AVFoundationCF.h> #include <CoreMedia/CoreMedia.h> - #include <delayimp.h> #include <dispatch/dispatch.h> +#include <WebKitQuartzCoreAdditions/WKCACFTypes.h> #include <wtf/HashMap.h> #include <wtf/Threading.h> #include <wtf/UnusedParam.h> @@ -87,7 +88,7 @@ public: void createAssetForURL(const String& url); void setAsset(AVCFURLAssetRef); - void createPlayer(); + void createPlayer(IDirect3DDevice9*); void createPlayerItem(); void checkPlayability(); @@ -137,6 +138,7 @@ private: RefPtr<PlatformCALayer> m_videoLayerWrapper; OwnPtr<LayerClient> m_layerClient; + COMPtr<IDirect3DDevice9Ex> m_d3dDevice; }; uintptr_t AVFWrapper::s_nextAVFWrapperObjectID; @@ -339,7 +341,7 @@ void MediaPlayerPrivateAVFoundationCF::createAVPlayer() ASSERT(m_avfWrapper); setDelayCallbacks(true); - m_avfWrapper->createPlayer(); + m_avfWrapper->createPlayer(reinterpret_cast<IDirect3DDevice9*>(player()->graphicsDeviceAdapter())); setDelayCallbacks(false); } @@ -355,8 +357,9 @@ void MediaPlayerPrivateAVFoundationCF::createAVPlayerItem() void MediaPlayerPrivateAVFoundationCF::createAVAssetForURL(const String& url) { ASSERT(!m_avfWrapper); - + setDelayCallbacks(true); + m_avfWrapper = new AVFWrapper(this); m_avfWrapper->createAssetForURL(url); setDelayCallbacks(false); @@ -955,20 +958,36 @@ void AVFWrapper::disconnectAndDeleteAVFWrapper(void* context) void AVFWrapper::createAssetForURL(const String& url) { ASSERT(!avAsset()); - + RetainPtr<CFURLRef> urlRef(AdoptCF, KURL(ParsedURLString, url).createCFURL()); + AVCFURLAssetRef assetRef = AVCFURLAssetCreateWithURLAndOptions(kCFAllocatorDefault, urlRef.get(), 0, m_notificationQueue); m_avAsset.adoptCF(assetRef); } -void AVFWrapper::createPlayer() +void AVFWrapper::createPlayer(IDirect3DDevice9* d3dDevice) { ASSERT(!avPlayer() && avPlayerItem()); + RetainPtr<CFMutableDictionaryRef> optionsRef(AdoptCF, CFDictionaryCreateMutable(kCFAllocatorDefault, 1, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks)); + + if (d3dDevice) { + // QI for an IDirect3DDevice9Ex interface, it is required to do HW video decoding. + COMPtr<IDirect3DDevice9Ex> d3dEx(Query, d3dDevice); + m_d3dDevice = d3dEx; + } else + m_d3dDevice = 0; + + if (m_d3dDevice && AVCFPlayerEnableHardwareAcceleratedVideoDecoderKey) + CFDictionarySetValue(optionsRef.get(), AVCFPlayerEnableHardwareAcceleratedVideoDecoderKey, kCFBooleanTrue); + // FIXME: We need a way to create a AVPlayer without an AVPlayerItem, see <rdar://problem/9877730>. - AVCFPlayerRef playerRef = AVCFPlayerCreateWithPlayerItemAndOptions(kCFAllocatorDefault, avPlayerItem(), 0, m_notificationQueue); + AVCFPlayerRef playerRef = AVCFPlayerCreateWithPlayerItemAndOptions(kCFAllocatorDefault, avPlayerItem(), optionsRef.get(), m_notificationQueue); m_avPlayer.adoptCF(playerRef); + if (m_d3dDevice && AVCFPlayerSetDirect3DDevicePtr()) + AVCFPlayerSetDirect3DDevicePtr()(playerRef, m_d3dDevice.get()); + CFNotificationCenterRef center = CFNotificationCenterGetLocalCenter(); ASSERT(center); diff --git a/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm b/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm index a26141daf..59a72f789 100644 --- a/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm +++ b/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm @@ -258,7 +258,7 @@ void MediaPlayerPrivateAVFoundationObjC::createAVAssetForURL(const String& url) [options.get() setObject:[NSNumber numberWithInt:AVAssetReferenceRestrictionForbidRemoteReferenceToLocal | AVAssetReferenceRestrictionForbidLocalReferenceToRemote] forKey:AVURLAssetReferenceRestrictionsKey]; -#if !defined(BUILDING_ON_SNOW_LEOPARD) && !defined(BUILDING_ON_LION) +#if PLATFORM(IOS) || __MAC_OS_X_VERSION_MIN_REQUIRED >= 1080 RetainPtr<NSMutableDictionary> headerFields(AdoptNS, [[NSMutableDictionary alloc] init]); String referrer = player()->referrer(); diff --git a/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.cpp b/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.cpp index 55d479b8a..e3a565d18 100644 --- a/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.cpp +++ b/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.cpp @@ -247,7 +247,7 @@ static bool animationHasStepsTimingFunction(const KeyframeValueList& valueList, static inline bool supportsAcceleratedFilterAnimations() { // <rdar://problem/10907251> - WebKit2 doesn't support CA animations of CI filters on Lion and below -#if !defined(BUILDING_ON_SNOW_LEOPARD) && !defined(BUILDING_ON_LION) +#if PLATFORM(MAC) && (PLATFORM(IOS) || __MAC_OS_X_VERSION_MIN_REQUIRED >= 1080) return true; #else return false; @@ -268,8 +268,10 @@ GraphicsLayerCA::GraphicsLayerCA(GraphicsLayerClient* client) , m_uncommittedChanges(0) { PlatformCALayer::LayerType layerType = PlatformCALayer::LayerTypeWebLayer; - if (client && client->shouldUseTileCache(this)) + if (client && client->shouldUseTileCache(this)) { layerType = PlatformCALayer::LayerTypeTileCacheLayer; + m_usingTileCache = true; + } m_layer = PlatformCALayer::create(layerType, this); @@ -1881,7 +1883,7 @@ bool GraphicsLayerCA::createTransformAnimationsFromKeyframes(const KeyframeValue int numAnimations = isMatrixAnimation ? 1 : operations->size(); bool reverseAnimationList = true; -#if !defined(BUILDING_ON_SNOW_LEOPARD) && !PLATFORM(WIN) +#if !PLATFORM(IOS) && !PLATFORM(WIN) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 1070 // Old versions of Core Animation apply animations in reverse order (<rdar://problem/7095638>) so we need to flip the list. // to be non-additive. For binary compatibility, the current version of Core Animation preserves this behavior for applications linked // on or before Snow Leopard. @@ -2390,7 +2392,7 @@ void GraphicsLayerCA::setDebugBorder(const Color& color, float borderWidth) FloatSize GraphicsLayerCA::constrainedSize() const { FloatSize constrainedSize = m_size; -#if defined(BUILDING_ON_SNOW_LEOPARD) +#if !PLATFORM(IOS) && __MAC_OS_X_VERSION_MIN_REQUIRED == 1060 float tileColumns = ceilf(m_size.width() / kTiledLayerTileSize); float tileRows = ceilf(m_size.height() / kTiledLayerTileSize); double numTiles = tileColumns * tileRows; diff --git a/Source/WebCore/platform/graphics/ca/PlatformCALayer.h b/Source/WebCore/platform/graphics/ca/PlatformCALayer.h index 002b7a07a..1ed94115c 100644 --- a/Source/WebCore/platform/graphics/ca/PlatformCALayer.h +++ b/Source/WebCore/platform/graphics/ca/PlatformCALayer.h @@ -213,7 +213,7 @@ public: void printTree() const; #endif -#if PLATFORM(MAC) && !defined(BUILDING_ON_SNOW_LEOPARD) +#if PLATFORM(MAC) && (PLATFORM(IOS) || __MAC_OS_X_VERSION_MIN_REQUIRED >= 1070) void synchronouslyDisplayTilesInRect(const FloatRect&); #endif diff --git a/Source/WebCore/platform/graphics/ca/mac/PlatformCALayerMac.mm b/Source/WebCore/platform/graphics/ca/mac/PlatformCALayerMac.mm index 3a7ac781f..f28967c51 100644 --- a/Source/WebCore/platform/graphics/ca/mac/PlatformCALayerMac.mm +++ b/Source/WebCore/platform/graphics/ca/mac/PlatformCALayerMac.mm @@ -93,7 +93,7 @@ static double mediaTimeToCurrentTime(CFTimeInterval t) @end -#if !defined(BUILDING_ON_SNOW_LEOPARD) +#if PLATFORM(IOS) || __MAC_OS_X_VERSION_MIN_REQUIRED >= 1070 @interface CATiledLayer(GraphicsLayerCAPrivate) - (void)displayInRect:(CGRect)r levelOfDetail:(int)lod options:(NSDictionary *)dict; - (BOOL)canDrawConcurrently; @@ -103,7 +103,7 @@ static double mediaTimeToCurrentTime(CFTimeInterval t) @interface CALayer(Private) - (void)setContentsChanged; -#if !defined(BUILDING_ON_SNOW_LEOPARD) +#if PLATFORM(IOS) || __MAC_OS_X_VERSION_MIN_REQUIRED >= 1070 - (void)setAcceleratesDrawing:(BOOL)flag; - (BOOL)acceleratesDrawing; #endif @@ -554,7 +554,7 @@ void PlatformCALayer::setMasksToBounds(bool value) bool PlatformCALayer::acceleratesDrawing() const { -#if !defined(BUILDING_ON_SNOW_LEOPARD) +#if PLATFORM(IOS) || __MAC_OS_X_VERSION_MIN_REQUIRED >= 1070 return [m_layer.get() acceleratesDrawing]; #else return false; @@ -563,7 +563,7 @@ bool PlatformCALayer::acceleratesDrawing() const void PlatformCALayer::setAcceleratesDrawing(bool acceleratesDrawing) { -#if !defined(BUILDING_ON_SNOW_LEOPARD) +#if PLATFORM(IOS) || __MAC_OS_X_VERSION_MIN_REQUIRED >= 1070 BEGIN_BLOCK_OBJC_EXCEPTIONS [m_layer.get() setAcceleratesDrawing:acceleratesDrawing]; END_BLOCK_OBJC_EXCEPTIONS @@ -910,7 +910,7 @@ void PlatformCALayer::setTimeOffset(CFTimeInterval value) float PlatformCALayer::contentsScale() const { -#if !defined(BUILDING_ON_SNOW_LEOPARD) +#if PLATFORM(IOS) || __MAC_OS_X_VERSION_MIN_REQUIRED >= 1070 return [m_layer.get() contentsScale]; #else return 1; @@ -919,7 +919,7 @@ float PlatformCALayer::contentsScale() const void PlatformCALayer::setContentsScale(float value) { -#if !defined(BUILDING_ON_SNOW_LEOPARD) +#if PLATFORM(IOS) || __MAC_OS_X_VERSION_MIN_REQUIRED >= 1070 BEGIN_BLOCK_OBJC_EXCEPTIONS [m_layer.get() setContentsScale:value]; END_BLOCK_OBJC_EXCEPTIONS @@ -937,7 +937,7 @@ TiledBacking* PlatformCALayer::tiledBacking() return [tileCacheLayer tiledBacking]; } -#if !defined(BUILDING_ON_SNOW_LEOPARD) +#if PLATFORM(IOS) || __MAC_OS_X_VERSION_MIN_REQUIRED >= 1070 void PlatformCALayer::synchronouslyDisplayTilesInRect(const FloatRect& rect) { if (m_layerType != LayerTypeWebTiledLayer) diff --git a/Source/WebCore/platform/graphics/ca/mac/TileCache.mm b/Source/WebCore/platform/graphics/ca/mac/TileCache.mm index 59d8b1f9b..f79c63b29 100644 --- a/Source/WebCore/platform/graphics/ca/mac/TileCache.mm +++ b/Source/WebCore/platform/graphics/ca/mac/TileCache.mm @@ -36,7 +36,7 @@ using namespace std; -#if !defined(BUILDING_ON_SNOW_LEOPARD) +#if PLATFORM(IOS) || __MAC_OS_X_VERSION_MIN_REQUIRED >= 1070 @interface CALayer (WebCALayerDetails) - (void)setAcceleratesDrawing:(BOOL)flag; @end @@ -157,7 +157,7 @@ void TileCache::setScale(CGFloat scale) if (m_scale == scale && m_deviceScaleFactor == deviceScaleFactor) return; -#if !defined(BUILDING_ON_SNOW_LEOPARD) +#if PLATFORM(IOS) || __MAC_OS_X_VERSION_MIN_REQUIRED >= 1070 Vector<FloatRect> dirtyRects; m_deviceScaleFactor = deviceScaleFactor; @@ -182,7 +182,7 @@ void TileCache::setScale(CGFloat scale) void TileCache::setAcceleratesDrawing(bool acceleratesDrawing) { -#if !defined(BUILDING_ON_SNOW_LEOPARD) +#if PLATFORM(IOS) || __MAC_OS_X_VERSION_MIN_REQUIRED >= 1070 if (m_acceleratesDrawing == acceleratesDrawing) return; @@ -401,7 +401,7 @@ RetainPtr<WebTileLayer> TileCache::createTileLayer(const IntRect& tileRect) [layer.get() setName:@"Tile"]; #endif -#if !defined(BUILDING_ON_SNOW_LEOPARD) +#if PLATFORM(IOS) || __MAC_OS_X_VERSION_MIN_REQUIRED >= 1070 [layer.get() setContentsScale:m_deviceScaleFactor]; [layer.get() setAcceleratesDrawing:m_acceleratesDrawing]; #endif diff --git a/Source/WebCore/platform/graphics/ca/win/CACFLayerTreeHost.h b/Source/WebCore/platform/graphics/ca/win/CACFLayerTreeHost.h index 2b82377d8..6628b92be 100644 --- a/Source/WebCore/platform/graphics/ca/win/CACFLayerTreeHost.h +++ b/Source/WebCore/platform/graphics/ca/win/CACFLayerTreeHost.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2009 Apple Inc. All rights reserved. + * Copyright (C) 2009, 2010, 2011, 2012 Apple Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -46,6 +46,10 @@ struct WKCACFContext; typedef struct CGImage* CGImageRef; +#if USE(AVFOUNDATION) +struct GraphicsDeviceAdapter; +#endif + namespace WebCore { class CACFLayerTreeHostClient; @@ -66,6 +70,9 @@ public: virtual void resize() = 0; void flushPendingGraphicsLayerChangesSoon(); virtual void setShouldInvertColors(bool); +#if USE(AVFOUNDATION) + virtual GraphicsDeviceAdapter* graphicsDeviceAdapter() const { return 0; } +#endif // AbstractCACFLayerTreeHost virtual void flushPendingLayerChangesNow(); diff --git a/Source/WebCore/platform/graphics/ca/win/LegacyCACFLayerTreeHost.h b/Source/WebCore/platform/graphics/ca/win/LegacyCACFLayerTreeHost.h index bfa530b92..5662fed5c 100644 --- a/Source/WebCore/platform/graphics/ca/win/LegacyCACFLayerTreeHost.h +++ b/Source/WebCore/platform/graphics/ca/win/LegacyCACFLayerTreeHost.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2011 Apple Inc. All rights reserved. + * Copyright (C) 2011, 2012 Apple Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -64,6 +64,10 @@ private: virtual void paint(); virtual void render(const Vector<CGRect>& dirtyRects = Vector<CGRect>()); +#if USE(AVFOUNDATION) + virtual GraphicsDeviceAdapter* graphicsDeviceAdapter() const OVERRIDE { return 0; } +#endif + Timer<LegacyCACFLayerTreeHost> m_renderTimer; COMPtr<IDirect3DDevice9> m_d3dDevice; WKCACFContext* m_context; diff --git a/Source/WebCore/platform/graphics/ca/win/WKCACFViewLayerTreeHost.cpp b/Source/WebCore/platform/graphics/ca/win/WKCACFViewLayerTreeHost.cpp index 2b47a3e1d..d945c3e2e 100644 --- a/Source/WebCore/platform/graphics/ca/win/WKCACFViewLayerTreeHost.cpp +++ b/Source/WebCore/platform/graphics/ca/win/WKCACFViewLayerTreeHost.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2011 Apple Inc. All rights reserved. + * Copyright (C) 2011, 2012 Apple Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -61,6 +61,7 @@ SOFT_LINK(WebKitQuartzCoreAdditions, WKCACFViewSetContextDidChangeCallback, void SOFT_LINK(WebKitQuartzCoreAdditions, WKCACFViewGetLastCommitTime, CFTimeInterval, __cdecl, (WKCACFViewRef view), (view)) SOFT_LINK(WebKitQuartzCoreAdditions, WKCACFViewSetContextUserData, void, __cdecl, (WKCACFViewRef view, void* userData), (view, userData)) SOFT_LINK_OPTIONAL(WebKitQuartzCoreAdditions, WKCACFViewSetShouldInvertColors, void, _cdecl, (WKCACFViewRef view, bool shouldInvertColors)) +SOFT_LINK_OPTIONAL(WebKitQuartzCoreAdditions, WKCACFViewGetD3DDevice9, IDirect3DDevice9*, _cdecl, (WKCACFViewRef view)) PassRefPtr<WKCACFViewLayerTreeHost> WKCACFViewLayerTreeHost::create() { @@ -175,6 +176,16 @@ void WKCACFViewLayerTreeHost::setShouldInvertColors(bool shouldInvertColors) WKCACFViewSetShouldInvertColorsPtr()(m_view.get(), shouldInvertColors); } +#if USE(AVFOUNDATION) +GraphicsDeviceAdapter* WKCACFViewLayerTreeHost::graphicsDeviceAdapter() const +{ + if (!WKCACFViewGetD3DDevice9Ptr()) + return 0; + + return reinterpret_cast<GraphicsDeviceAdapter*>(WKCACFViewGetD3DDevice9Ptr()(m_view.get())); +} +#endif + } // namespace WebCore #endif // USE(ACCELERATED_COMPOSITING) diff --git a/Source/WebCore/platform/graphics/ca/win/WKCACFViewLayerTreeHost.h b/Source/WebCore/platform/graphics/ca/win/WKCACFViewLayerTreeHost.h index 2660e43d1..567157125 100644 --- a/Source/WebCore/platform/graphics/ca/win/WKCACFViewLayerTreeHost.h +++ b/Source/WebCore/platform/graphics/ca/win/WKCACFViewLayerTreeHost.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2011 Apple Inc. All rights reserved. + * Copyright (C) 2011, 2012 Apple Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -54,6 +54,9 @@ private: virtual void render(const Vector<CGRect>& dirtyRects = Vector<CGRect>()); virtual CFTimeInterval lastCommitTime() const; virtual void setShouldInvertColors(bool); +#if USE(AVFOUNDATION) + virtual GraphicsDeviceAdapter* graphicsDeviceAdapter() const OVERRIDE; +#endif RetainPtr<WKCACFViewRef> m_view; bool m_viewNeedsUpdate; diff --git a/Source/WebCore/platform/graphics/cairo/ImageBufferCairo.cpp b/Source/WebCore/platform/graphics/cairo/ImageBufferCairo.cpp index 5e5f56853..3b4c9ccf3 100644 --- a/Source/WebCore/platform/graphics/cairo/ImageBufferCairo.cpp +++ b/Source/WebCore/platform/graphics/cairo/ImageBufferCairo.cpp @@ -29,7 +29,6 @@ #include "config.h" #include "ImageBuffer.h" -#include "Base64.h" #include "BitmapImage.h" #include "CairoUtilities.h" #include "Color.h" @@ -43,6 +42,7 @@ #include "RefPtrCairo.h" #include <cairo.h> #include <wtf/Vector.h> +#include <wtf/text/Base64.h> using namespace std; diff --git a/Source/WebCore/platform/graphics/cg/GraphicsContextCG.cpp b/Source/WebCore/platform/graphics/cg/GraphicsContextCG.cpp index 748946820..2657d5412 100644 --- a/Source/WebCore/platform/graphics/cg/GraphicsContextCG.cpp +++ b/Source/WebCore/platform/graphics/cg/GraphicsContextCG.cpp @@ -54,12 +54,12 @@ #if PLATFORM(MAC) || (PLATFORM(CHROMIUM) && OS(DARWIN)) -#ifndef BUILDING_ON_LEOPARD +#if PLATFORM(IOS) || __MAC_OS_X_VERSION_MAX_ALLOWED >= 1060 // Building on 10.6 or later: kCGInterpolationMedium is defined in the CGInterpolationQuality enum. #define HAVE_CG_INTERPOLATION_MEDIUM 1 #endif -#ifndef TARGETING_LEOPARD +#if PLATFORM(IOS) || __MAC_OS_X_VERSION_MIN_REQUIRED >= 1060 // Targeting 10.6 or later: use kCGInterpolationMedium. #define WTF_USE_CG_INTERPOLATION_MEDIUM 1 #endif @@ -1181,7 +1181,7 @@ void GraphicsContext::setPlatformShadow(const FloatSize& offset, float blur, con blurRadius = min(blurRadius, narrowPrecisionToCGFloat(1000.0)); -#if defined(BUILDING_ON_SNOW_LEOPARD) || defined(BUILDING_ON_LION) +#if !PLATFORM(IOS) && __MAC_OS_X_VERSION_MIN_REQUIRED <= 1070 if (!isAcceleratedContext()) { // Work around <rdar://problem/5539388> by ensuring that the offsets will get truncated // to the desired integer. Also see: <rdar://problem/10056277> @@ -1598,7 +1598,7 @@ InterpolationQuality GraphicsContext::imageInterpolationQuality() const void GraphicsContext::setAllowsFontSmoothing(bool allowsFontSmoothing) { UNUSED_PARAM(allowsFontSmoothing); -#if !defined(BUILDING_ON_LEOPARD) +#if PLATFORM(IOS) || __MAC_OS_X_VERSION_MIN_REQUIRED >= 1060 CGContextRef context = platformContext(); CGContextSetAllowsFontSmoothing(context, allowsFontSmoothing); #endif diff --git a/Source/WebCore/platform/graphics/cg/ImageBufferCG.cpp b/Source/WebCore/platform/graphics/cg/ImageBufferCG.cpp index 81982a188..21e9db4c2 100644 --- a/Source/WebCore/platform/graphics/cg/ImageBufferCG.cpp +++ b/Source/WebCore/platform/graphics/cg/ImageBufferCG.cpp @@ -28,7 +28,6 @@ #include "config.h" #include "ImageBuffer.h" -#include "Base64.h" #include "BitmapImage.h" #include "GraphicsContext.h" #include "GraphicsContextCG.h" @@ -42,6 +41,7 @@ #include <wtf/OwnArrayPtr.h> #include <wtf/RetainPtr.h> #include <wtf/UnusedParam.h> +#include <wtf/text/Base64.h> #include <wtf/text/WTFString.h> #if PLATFORM(MAC) || PLATFORM(CHROMIUM) @@ -52,7 +52,7 @@ #include <IOSurface/IOSurface.h> #endif -#if defined(BUILDING_ON_LION) +#if !PLATFORM(IOS) && __MAC_OS_X_VERSION_MIN_REQUIRED == 1070 #include <wtf/CurrentTime.h> #endif @@ -183,7 +183,7 @@ ImageBuffer::ImageBuffer(const IntSize& size, float resolutionScale, ColorSpace m_context->scale(FloatSize(1, -1)); m_context->translate(0, -size.height()); m_context->setIsAcceleratedContext(accelerateRendering); -#if defined(BUILDING_ON_LION) +#if !PLATFORM(IOS) && __MAC_OS_X_VERSION_MIN_REQUIRED == 1070 m_data.m_lastFlushTime = currentTimeMS(); #endif success = true; @@ -195,7 +195,7 @@ ImageBuffer::~ImageBuffer() GraphicsContext* ImageBuffer::context() const { -#if defined(BUILDING_ON_LION) +#if !PLATFORM(IOS) && __MAC_OS_X_VERSION_MIN_REQUIRED == 1070 // Force a flush if last flush was more than 20ms ago if (m_context->isAcceleratedContext()) { double elapsedTime = currentTimeMS() - m_data.m_lastFlushTime; @@ -250,7 +250,7 @@ NativeImagePtr ImageBuffer::copyNativeImage(BackingStoreCopy copyBehavior) const #if USE(IOSURFACE_CANVAS_BACKING_STORE) else { image = wkIOSurfaceContextCreateImage(context()->platformContext()); -#if defined(BUILDING_ON_LION) +#if !PLATFORM(IOS) && __MAC_OS_X_VERSION_MIN_REQUIRED == 1070 m_data.m_lastFlushTime = currentTimeMS(); #endif } @@ -310,7 +310,7 @@ PassRefPtr<Uint8ClampedArray> ImageBuffer::getUnmultipliedImageData(const IntRec { if (m_context->isAcceleratedContext()) { CGContextFlush(context()->platformContext()); -#if defined(BUILDING_ON_LION) +#if !PLATFORM(IOS) && __MAC_OS_X_VERSION_MIN_REQUIRED == 1070 m_data.m_lastFlushTime = currentTimeMS(); #endif } @@ -321,7 +321,7 @@ PassRefPtr<Uint8ClampedArray> ImageBuffer::getPremultipliedImageData(const IntRe { if (m_context->isAcceleratedContext()) { CGContextFlush(context()->platformContext()); -#if defined(BUILDING_ON_LION) +#if !PLATFORM(IOS) && __MAC_OS_X_VERSION_MIN_REQUIRED == 1070 m_data.m_lastFlushTime = currentTimeMS(); #endif } diff --git a/Source/WebCore/platform/graphics/cg/ImageBufferDataCG.cpp b/Source/WebCore/platform/graphics/cg/ImageBufferDataCG.cpp index 5e3ae78a8..649d9b766 100644 --- a/Source/WebCore/platform/graphics/cg/ImageBufferDataCG.cpp +++ b/Source/WebCore/platform/graphics/cg/ImageBufferDataCG.cpp @@ -62,7 +62,7 @@ ImageBufferData::ImageBufferData(const IntSize&) #if USE(ACCELERATE) -#ifndef TARGETING_SNOW_LEOPARD +#if __MAC_OS_X_VERSION_MAX_ALLOWED >= 1070 static bool haveVImageRoundingErrorFix() { return true; } #else // The vImage unpremultiply routine had a rounding bug before 10.6.7 <rdar://problem/8631548> @@ -72,7 +72,7 @@ static bool haveVImageRoundingErrorFix() static bool result = (Gestalt(gestaltSystemVersion, &version) == noErr && version > 0x1066); return result; } -#endif // TARGETING_SNOW_LEOPARD +#endif // __MAC_OS_X_VERSION_MAX_ALLOWED >= 1070 #if USE(IOSURFACE_CANVAS_BACKING_STORE) static void convertScanline(void* data, size_t tileNumber, bool premultiply) diff --git a/Source/WebCore/platform/graphics/cg/ImageBufferDataCG.h b/Source/WebCore/platform/graphics/cg/ImageBufferDataCG.h index 6233c6c2c..8e61edff9 100644 --- a/Source/WebCore/platform/graphics/cg/ImageBufferDataCG.h +++ b/Source/WebCore/platform/graphics/cg/ImageBufferDataCG.h @@ -30,7 +30,7 @@ #include <wtf/RetainPtr.h> #include <wtf/Uint8ClampedArray.h> -#if (PLATFORM(MAC) && USE(CA) && !defined(BUILDING_ON_LEOPARD) && !defined(BUILDING_ON_SNOW_LEOPARD)) +#if (PLATFORM(MAC) && USE(CA) && (PLATFORM(IOS) || __MAC_OS_X_VERSION_MIN_REQUIRED >= 1070)) #define WTF_USE_IOSURFACE_CANVAS_BACKING_STORE 1 #endif @@ -54,7 +54,7 @@ public: Checked<unsigned, RecordOverflow> m_bytesPerRow; CGColorSpaceRef m_colorSpace; RetainPtr<IOSurfaceRef> m_surface; -#if defined(BUILDING_ON_LION) +#if !PLATFORM(IOS) && __MAC_OS_X_VERSION_MIN_REQUIRED == 1070 mutable double m_lastFlushTime; #endif diff --git a/Source/WebCore/platform/graphics/cg/ImageCG.cpp b/Source/WebCore/platform/graphics/cg/ImageCG.cpp index fed911aeb..2c0cca22b 100644 --- a/Source/WebCore/platform/graphics/cg/ImageCG.cpp +++ b/Source/WebCore/platform/graphics/cg/ImageCG.cpp @@ -269,7 +269,7 @@ void Image::drawPattern(GraphicsContext* ctxt, const FloatRect& tileRect, const // FIXME: We cannot use CGContextDrawTiledImage with scaled tiles on Leopard, because it suffers from rounding errors. Snow Leopard is ok. float scaledTileWidth = tileRect.width() * narrowPrecisionToFloat(patternTransform.a()); float w = CGImageGetWidth(tileImage); -#ifdef BUILDING_ON_LEOPARD +#if !PLATFORM(IOS) && __MAC_OS_X_VERSION_MIN_REQUIRED == 1050 if (w == size().width() && h == size().height() && scaledTileWidth == tileRect.width() && scaledTileHeight == tileRect.height()) #else if (w == size().width() && h == size().height()) diff --git a/Source/WebCore/platform/graphics/cg/ImageSourceCG.cpp b/Source/WebCore/platform/graphics/cg/ImageSourceCG.cpp index 43353650c..7cf02968e 100644 --- a/Source/WebCore/platform/graphics/cg/ImageSourceCG.cpp +++ b/Source/WebCore/platform/graphics/cg/ImageSourceCG.cpp @@ -85,7 +85,7 @@ ImageSource::~ImageSource() void ImageSource::clear(bool destroyAllFrames, size_t, SharedBuffer* data, bool allDataReceived) { -#if !defined(BUILDING_ON_LEOPARD) +#if !PLATFORM(MAC) || __MAC_OS_X_VERSION_MIN_REQUIRED >= 1060 // Recent versions of ImageIO discard previously decoded image frames if the client // application no longer holds references to them, so there's no need to throw away // the decoder unless we're explicitly asked to destroy all of the frames. @@ -116,7 +116,7 @@ static CFDictionaryRef imageSourceOptions(ImageSource::ShouldSkipMetadata skipMe if (!options) { const unsigned numOptions = 3; -#if defined(BUILDING_ON_LION) || defined(BUILDING_ON_SNOW_LEOPARD) +#if PLATFORM(MAC) && !PLATFORM(IOS) && __MAC_OS_X_VERSION_MIN_REQUIRED <= 1070 // Lion and Snow Leopard only return Orientation when kCGImageSourceSkipMetaData is false, // and incorrectly return cached metadata if an image is queried once with kCGImageSourceSkipMetaData true // and then subsequently with kCGImageSourceSkipMetaData false. diff --git a/Source/WebCore/platform/graphics/cg/PathCG.cpp b/Source/WebCore/platform/graphics/cg/PathCG.cpp index 6cc937836..e7dee39d3 100644 --- a/Source/WebCore/platform/graphics/cg/PathCG.cpp +++ b/Source/WebCore/platform/graphics/cg/PathCG.cpp @@ -175,7 +175,7 @@ FloatRect Path::boundingRect() const // does not, but only exists on 10.6 and above. CGRect bound = CGRectZero; -#if !defined(BUILDING_ON_LEOPARD) +#if !PLATFORM(MAC) || __MAC_OS_X_VERSION_MIN_REQUIRED >= 1060 bound = CGPathGetPathBoundingBox(m_path); #else bound = CGPathGetBoundingBox(m_path); @@ -236,7 +236,7 @@ void Path::addArcTo(const FloatPoint& p1, const FloatPoint& p2, float radius) void Path::platformAddPathForRoundedRect(const FloatRect& rect, const FloatSize& topLeftRadius, const FloatSize& topRightRadius, const FloatSize& bottomLeftRadius, const FloatSize& bottomRightRadius) { -#if PLATFORM(MAC) && (!defined(BUILDING_ON_LEOPARD) && !defined(BUILDING_ON_SNOW_LEOPARD)) +#if PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 1070 bool equalWidths = (topLeftRadius.width() == topRightRadius.width() && topRightRadius.width() == bottomLeftRadius.width() && bottomLeftRadius.width() == bottomRightRadius.width()); bool equalHeights = (topLeftRadius.height() == bottomLeftRadius.height() && bottomLeftRadius.height() == topRightRadius.height() && topRightRadius.height() == bottomRightRadius.height()); diff --git a/Source/WebCore/platform/graphics/chromium/BitmapCanvasLayerTextureUpdater.cpp b/Source/WebCore/platform/graphics/chromium/BitmapCanvasLayerTextureUpdater.cpp index f869c58a2..d75cf054d 100644 --- a/Source/WebCore/platform/graphics/chromium/BitmapCanvasLayerTextureUpdater.cpp +++ b/Source/WebCore/platform/graphics/chromium/BitmapCanvasLayerTextureUpdater.cpp @@ -33,6 +33,7 @@ #include "LayerPainterChromium.h" #include "PlatformColor.h" #include "PlatformContextSkia.h" +#include "TextureAllocator.h" #include "cc/CCGraphicsContext.h" #include "skia/ext/platform_canvas.h" diff --git a/Source/WebCore/platform/graphics/chromium/BitmapCanvasLayerTextureUpdater.h b/Source/WebCore/platform/graphics/chromium/BitmapCanvasLayerTextureUpdater.h index d97968c03..276e2b391 100644 --- a/Source/WebCore/platform/graphics/chromium/BitmapCanvasLayerTextureUpdater.h +++ b/Source/WebCore/platform/graphics/chromium/BitmapCanvasLayerTextureUpdater.h @@ -38,6 +38,7 @@ namespace WebCore { class LayerPainterChromium; class CCGraphicsContext; +class TextureAllocator; // This class rasterizes the contentRect into a skia bitmap canvas. It then updates // textures by copying from the canvas into the texture, using MapSubImage if diff --git a/Source/WebCore/platform/graphics/chromium/BitmapSkPictureCanvasLayerTextureUpdater.cpp b/Source/WebCore/platform/graphics/chromium/BitmapSkPictureCanvasLayerTextureUpdater.cpp index 23cffea94..86fb2c8c3 100644 --- a/Source/WebCore/platform/graphics/chromium/BitmapSkPictureCanvasLayerTextureUpdater.cpp +++ b/Source/WebCore/platform/graphics/chromium/BitmapSkPictureCanvasLayerTextureUpdater.cpp @@ -34,6 +34,7 @@ #include "PlatformColor.h" #include "SkCanvas.h" #include "SkDevice.h" +#include "TextureAllocator.h" #include "cc/CCGraphicsContext.h" namespace WebCore { diff --git a/Source/WebCore/platform/graphics/chromium/BitmapSkPictureCanvasLayerTextureUpdater.h b/Source/WebCore/platform/graphics/chromium/BitmapSkPictureCanvasLayerTextureUpdater.h index 787b39937..9f1388827 100644 --- a/Source/WebCore/platform/graphics/chromium/BitmapSkPictureCanvasLayerTextureUpdater.h +++ b/Source/WebCore/platform/graphics/chromium/BitmapSkPictureCanvasLayerTextureUpdater.h @@ -34,6 +34,8 @@ namespace WebCore { +class TextureAllocator; + // This class records the contentRect into an SkPicture, then software rasterizes // the SkPicture into bitmaps for each tile. This implements CCSettings::perTilePainting. class BitmapSkPictureCanvasLayerTextureUpdater : public SkPictureCanvasLayerTextureUpdater { diff --git a/Source/WebCore/platform/graphics/chromium/CanvasLayerTextureUpdater.cpp b/Source/WebCore/platform/graphics/chromium/CanvasLayerTextureUpdater.cpp index be8484b75..782780a40 100644 --- a/Source/WebCore/platform/graphics/chromium/CanvasLayerTextureUpdater.cpp +++ b/Source/WebCore/platform/graphics/chromium/CanvasLayerTextureUpdater.cpp @@ -75,8 +75,9 @@ void CanvasLayerTextureUpdater::paintContents(SkCanvas* canvas, const IntRect& c m_painter->paint(canvas, layerRect, opaqueLayerRect); canvas->restore(); - opaqueLayerRect.scale(contentsWidthScale, contentsHeightScale); - resultingOpaqueRect = enclosedIntRect(opaqueLayerRect); + FloatRect opaqueContentRect = opaqueLayerRect; + opaqueContentRect.scale(contentsWidthScale, contentsHeightScale); + resultingOpaqueRect = enclosedIntRect(opaqueContentRect); m_contentRect = contentRect; } diff --git a/Source/WebCore/platform/graphics/chromium/ContentLayerChromium.cpp b/Source/WebCore/platform/graphics/chromium/ContentLayerChromium.cpp index 078d377d0..9f40f7fe1 100644 --- a/Source/WebCore/platform/graphics/chromium/ContentLayerChromium.cpp +++ b/Source/WebCore/platform/graphics/chromium/ContentLayerChromium.cpp @@ -97,14 +97,14 @@ void ContentLayerChromium::update(CCTextureUpdater& updater, const CCOcclusionTr { createTextureUpdaterIfNeeded(); - IntRect layerRect; + IntRect contentRect; - // Always call updateLayerRect() but with an empty layer rectangle when + // Always call updateContentRect() but with an empty layer rectangle when // layer doesn't draw contents. if (drawsContent()) - layerRect = visibleLayerRect(); + contentRect = visibleContentRect(); - updateLayerRect(updater, layerRect, occlusion); + updateContentRect(updater, contentRect, occlusion); m_needsDisplay = false; } @@ -112,7 +112,7 @@ bool ContentLayerChromium::needMoreUpdates() { if (!drawsContent()) return false; - return needsIdlePaint(visibleLayerRect()); + return needsIdlePaint(visibleContentRect()); } void ContentLayerChromium::createTextureUpdaterIfNeeded() diff --git a/Source/WebCore/platform/graphics/chromium/ImageLayerChromium.cpp b/Source/WebCore/platform/graphics/chromium/ImageLayerChromium.cpp index 14164133d..696563acf 100644 --- a/Source/WebCore/platform/graphics/chromium/ImageLayerChromium.cpp +++ b/Source/WebCore/platform/graphics/chromium/ImageLayerChromium.cpp @@ -36,7 +36,6 @@ #include "LayerTextureSubImage.h" #include "LayerTextureUpdater.h" -#include "ManagedTexture.h" #include "PlatformColor.h" #include "cc/CCLayerTreeHost.h" @@ -155,11 +154,11 @@ void ImageLayerChromium::update(CCTextureUpdater& updater, const CCOcclusionTrac if (m_needsDisplay) { m_textureUpdater->setBitmap(m_bitmap); updateTileSizeAndTilingOption(); - invalidateRect(IntRect(IntPoint(), contentBounds())); + invalidateContentRect(IntRect(IntPoint(), contentBounds())); m_needsDisplay = false; } - updateLayerRect(updater, visibleLayerRect(), occlusion); + updateContentRect(updater, visibleContentRect(), occlusion); } void ImageLayerChromium::createTextureUpdaterIfNeeded() diff --git a/Source/WebCore/platform/graphics/chromium/LayerChromium.cpp b/Source/WebCore/platform/graphics/chromium/LayerChromium.cpp index 38b856e63..4ae8db39c 100644 --- a/Source/WebCore/platform/graphics/chromium/LayerChromium.cpp +++ b/Source/WebCore/platform/graphics/chromium/LayerChromium.cpp @@ -732,7 +732,7 @@ void LayerChromium::notifyAnimationFinished(double wallClockTime) Region LayerChromium::visibleContentOpaqueRegion() const { if (opaque()) - return visibleLayerRect(); + return visibleContentRect(); return Region(); } diff --git a/Source/WebCore/platform/graphics/chromium/LayerChromium.h b/Source/WebCore/platform/graphics/chromium/LayerChromium.h index e3ceb94d0..40668f556 100644 --- a/Source/WebCore/platform/graphics/chromium/LayerChromium.h +++ b/Source/WebCore/platform/graphics/chromium/LayerChromium.h @@ -154,8 +154,8 @@ public: void setTransform(const WebKit::WebTransformationMatrix&); bool transformIsAnimating() const; - const IntRect& visibleLayerRect() const { return m_visibleLayerRect; } - void setVisibleLayerRect(const IntRect& visibleLayerRect) { m_visibleLayerRect = visibleLayerRect; } + const IntRect& visibleContentRect() const { return m_visibleContentRect; } + void setVisibleContentRect(const IntRect& visibleContentRect) { m_visibleContentRect = visibleContentRect; } const IntRect& scissorRect() const { return m_scissorRect; } void setScissorRect(const IntRect& scissorRect) { m_scissorRect = scissorRect; } @@ -344,7 +344,7 @@ private: IntSize m_bounds; // Uses layer's content space. - IntRect m_visibleLayerRect; + IntRect m_visibleContentRect; // During drawing, identifies the region outside of which nothing should be drawn. // Currently this is set to layer's clipRect if usesLayerClipping is true, otherwise diff --git a/Source/WebCore/platform/graphics/chromium/LayerRendererChromium.cpp b/Source/WebCore/platform/graphics/chromium/LayerRendererChromium.cpp index 55b5929a3..a72674140 100644 --- a/Source/WebCore/platform/graphics/chromium/LayerRendererChromium.cpp +++ b/Source/WebCore/platform/graphics/chromium/LayerRendererChromium.cpp @@ -43,28 +43,18 @@ #include "SharedGraphicsContext3D.h" #include "SkBitmap.h" #include "SkColor.h" -#include "TextureManager.h" #include "ThrottledTextureUploader.h" #include "TraceEvent.h" #include "TrackingTextureAllocator.h" -#include "cc/CCCheckerboardDrawQuad.h" -#include "cc/CCDebugBorderDrawQuad.h" -#include "cc/CCIOSurfaceDrawQuad.h" #include "cc/CCLayerQuad.h" #include "cc/CCMathUtil.h" #include "cc/CCProxy.h" #include "cc/CCRenderPass.h" -#include "cc/CCRenderPassDrawQuad.h" #include "cc/CCRenderSurfaceFilters.h" #include "cc/CCScopedTexture.h" #include "cc/CCSettings.h" #include "cc/CCSingleThreadProxy.h" -#include "cc/CCSolidColorDrawQuad.h" -#include "cc/CCStreamVideoDrawQuad.h" -#include "cc/CCTextureDrawQuad.h" -#include "cc/CCTileDrawQuad.h" #include "cc/CCVideoLayerImpl.h" -#include "cc/CCYUVVideoDrawQuad.h" #include <public/WebGraphicsContext3D.h> #include <public/WebVideoFrame.h> #include <wtf/CurrentTime.h> @@ -218,8 +208,6 @@ bool LayerRendererChromium::initialize() m_capabilities.usingGpuMemoryManager = extensions.contains("GL_CHROMIUM_gpu_memory_manager"); if (m_capabilities.usingGpuMemoryManager) m_context->setMemoryAllocationChangedCallbackCHROMIUM(this); - else - m_client->setMemoryAllocationLimitBytes(TextureManager::highLimitBytes(viewportSize())); m_capabilities.usingDiscardFramebuffer = extensions.contains("GL_CHROMIUM_discard_framebuffer"); @@ -327,7 +315,7 @@ void LayerRendererChromium::decideRenderPassAllocationsForFrame(const CCRenderPa { HashMap<int, const CCRenderPass*> passesInFrame; for (size_t i = 0; i < renderPassesInDrawOrder.size(); ++i) - passesInFrame.set(renderPassesInDrawOrder[i]->id(), renderPassesInDrawOrder[i].get()); + passesInFrame.set(renderPassesInDrawOrder[i]->id(), renderPassesInDrawOrder[i]); Vector<int> passesToDelete; HashMap<int, OwnPtr<CCScopedTexture> >::const_iterator passIterator; @@ -414,7 +402,7 @@ void LayerRendererChromium::drawRenderPass(const CCRenderPass* renderPass, const drawQuad(it->get()); } -void LayerRendererChromium::drawQuad(const CCDrawQuad* quad) +void LayerRendererChromium::drawQuad(const WebKit::WebCompositorQuad* quad) { IntRect scissorRect = quad->scissorRect(); @@ -430,35 +418,35 @@ void LayerRendererChromium::drawQuad(const CCDrawQuad* quad) GLC(m_context, m_context->disable(GraphicsContext3D::BLEND)); switch (quad->material()) { - case CCDrawQuad::Invalid: + case WebKit::WebCompositorQuad::Invalid: ASSERT_NOT_REACHED(); break; - case CCDrawQuad::Checkerboard: - drawCheckerboardQuad(quad->toCheckerboardDrawQuad()); + case WebKit::WebCompositorQuad::Checkerboard: + drawCheckerboardQuad(CCCheckerboardDrawQuad::materialCast(quad)); break; - case CCDrawQuad::DebugBorder: - drawDebugBorderQuad(quad->toDebugBorderDrawQuad()); + case WebKit::WebCompositorQuad::DebugBorder: + drawDebugBorderQuad(CCDebugBorderDrawQuad::materialCast(quad)); break; - case CCDrawQuad::IOSurfaceContent: - drawIOSurfaceQuad(quad->toIOSurfaceDrawQuad()); + case WebKit::WebCompositorQuad::IOSurfaceContent: + drawIOSurfaceQuad(CCIOSurfaceDrawQuad::materialCast(quad)); break; - case CCDrawQuad::RenderPass: - drawRenderPassQuad(quad->toRenderPassDrawQuad()); + case WebKit::WebCompositorQuad::RenderPass: + drawRenderPassQuad(CCRenderPassDrawQuad::materialCast(quad)); break; - case CCDrawQuad::SolidColor: - drawSolidColorQuad(quad->toSolidColorDrawQuad()); + case WebKit::WebCompositorQuad::SolidColor: + drawSolidColorQuad(WebKit::WebCompositorSolidColorQuad::materialCast(quad)); break; - case CCDrawQuad::StreamVideoContent: - drawStreamVideoQuad(quad->toStreamVideoDrawQuad()); + case WebKit::WebCompositorQuad::StreamVideoContent: + drawStreamVideoQuad(CCStreamVideoDrawQuad::materialCast(quad)); break; - case CCDrawQuad::TextureContent: - drawTextureQuad(quad->toTextureDrawQuad()); + case WebKit::WebCompositorQuad::TextureContent: + drawTextureQuad(WebKit::WebCompositorTextureQuad::materialCast(quad)); break; - case CCDrawQuad::TiledContent: - drawTileQuad(quad->toTileDrawQuad()); + case WebKit::WebCompositorQuad::TiledContent: + drawTileQuad(CCTileDrawQuad::materialCast(quad)); break; - case CCDrawQuad::YUVVideoContent: - drawYUVVideoQuad(quad->toYUVVideoDrawQuad()); + case WebKit::WebCompositorQuad::YUVVideoContent: + drawYUVVideoQuad(CCYUVVideoDrawQuad::materialCast(quad)); break; } } @@ -610,7 +598,7 @@ void LayerRendererChromium::drawRenderPassQuad(const CCRenderPassDrawQuad* quad) if (!contentsTexture || !contentsTexture->id()) return; - WebTransformationMatrix renderTransform = quad->layerTransform(); + WebTransformationMatrix renderTransform = quad->drawTransform(); // Apply a scaling factor to size the quad from 1x1 to its intended size. renderTransform.scale3d(quad->quadRect().width(), quad->quadRect().height(), 1); WebTransformationMatrix contentsDeviceTransform = WebTransformationMatrix(windowMatrix() * projectionMatrix() * renderTransform).to2dTransform(); @@ -633,7 +621,7 @@ void LayerRendererChromium::drawRenderPassQuad(const CCRenderPassDrawQuad* quad) // Draw the background texture if there is one. if (backgroundTexture) { ASSERT(backgroundTexture->size() == quad->quadRect().size()); - copyTextureToFramebuffer(backgroundTexture->id(), quad->quadRect().size(), quad->layerTransform()); + copyTextureToFramebuffer(backgroundTexture->id(), quad->quadRect().size(), quad->drawTransform()); } bool clipped = false; @@ -711,11 +699,11 @@ void LayerRendererChromium::drawRenderPassQuad(const CCRenderPassDrawQuad* quad) GLC(context(), context()->uniform3fv(shaderEdgeLocation, 8, edge)); } - // Map device space quad to surface space. contentsDeviceTransform has no perspective since it was generated with to2dTransform() so we don't need to project. + // Map device space quad to surface space. contentsDeviceTransform has no 3d component since it was generated with to2dTransform() so we don't need to project. FloatQuad surfaceQuad = CCMathUtil::mapQuad(contentsDeviceTransform.inverse(), deviceLayerEdges.floatQuad(), clipped); ASSERT(!clipped); - drawTexturedQuad(quad->layerTransform(), quad->quadRect().width(), quad->quadRect().height(), quad->opacity(), surfaceQuad, + drawTexturedQuad(quad->drawTransform(), quad->quadRect().width(), quad->quadRect().height(), quad->opacity(), surfaceQuad, shaderMatrixLocation, shaderAlphaLocation, shaderQuadLocation); } @@ -807,7 +795,7 @@ void LayerRendererChromium::drawTileQuad(const CCTileDrawQuad* quad) return; bool clipped = false; - FloatQuad deviceLayerQuad = CCMathUtil::mapQuad(deviceTransform, FloatQuad(quad->layerRect()), clipped); + FloatQuad deviceLayerQuad = CCMathUtil::mapQuad(deviceTransform, FloatQuad(quad->visibleContentRect()), clipped); ASSERT(!clipped); TileProgramUniforms uniforms; @@ -891,10 +879,12 @@ void LayerRendererChromium::drawTileQuad(const CCTileDrawQuad* quad) // Create device space quad. CCLayerQuad deviceQuad(leftEdge, topEdge, rightEdge, bottomEdge); - // Map quad to layer space. + // Map device space quad to local space. contentsDeviceTransform has no 3d component since it was generated with to2dTransform() so we don't need to project. WebTransformationMatrix inverseDeviceTransform = deviceTransform.inverse(); localQuad = CCMathUtil::mapQuad(inverseDeviceTransform, deviceQuad.floatQuad(), clipped); - ASSERT(!clipped); + + // We should not ASSERT(!clipped) here, because anti-aliasing inflation may cause deviceQuad to become + // clipped. To our knowledge this scenario does not need to be handled differently than the unclipped case. } else { // Move fragment shader transform to vertex shader. We can do this while // still producing correct results as fragmentTexTransformLocation @@ -968,11 +958,12 @@ void LayerRendererChromium::drawYUVVideoQuad(const CCYUVVideoDrawQuad* quad) }; GLC(context(), context()->uniform3fv(program->fragmentShader().yuvAdjLocation(), 1, yuvAdjust)); - const IntSize& bounds = quad->quadRect().size(); - drawTexturedQuad(quad->layerTransform(), bounds.width(), bounds.height(), quad->opacity(), FloatQuad(), - program->vertexShader().matrixLocation(), - program->fragmentShader().alphaLocation(), - -1); + WebTransformationMatrix quadTransform = quad->quadTransform(); + IntRect quadRect = quad->quadRect(); + quadTransform.translate(quadRect.x() + quadRect.width() / 2.0, quadRect.y() + quadRect.height() / 2.0); + + drawTexturedQuad(quadTransform, quadRect.width(), quadRect.height(), quad->opacity(), FloatQuad(), + program->vertexShader().matrixLocation(), program->fragmentShader().alphaLocation(), -1); // Reset active texture back to texture 0. GLC(context(), context()->activeTexture(GraphicsContext3D::TEXTURE0)); @@ -995,11 +986,12 @@ void LayerRendererChromium::drawStreamVideoQuad(const CCStreamVideoDrawQuad* qua GLC(context(), context()->uniform1i(program->fragmentShader().samplerLocation(), 0)); - const IntSize& bounds = quad->quadRect().size(); - drawTexturedQuad(quad->layerTransform(), bounds.width(), bounds.height(), quad->opacity(), sharedGeometryQuad(), - program->vertexShader().matrixLocation(), - program->fragmentShader().alphaLocation(), - -1); + WebTransformationMatrix quadTransform = quad->quadTransform(); + IntRect quadRect = quad->quadRect(); + quadTransform.translate(quadRect.x() + quadRect.width() / 2.0, quadRect.y() + quadRect.height() / 2.0); + + drawTexturedQuad(quadTransform, quadRect.width(), quadRect.height(), quad->opacity(), sharedGeometryQuad(), + program->vertexShader().matrixLocation(), program->fragmentShader().alphaLocation(), -1); } struct TextureProgramBinding { @@ -1092,9 +1084,11 @@ void LayerRendererChromium::drawIOSurfaceQuad(const CCIOSurfaceDrawQuad* quad) GLC(context(), context()->texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_WRAP_S, GraphicsContext3D::CLAMP_TO_EDGE)); GLC(context(), context()->texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_WRAP_T, GraphicsContext3D::CLAMP_TO_EDGE)); - const IntSize& bounds = quad->quadRect().size(); + WebTransformationMatrix quadTransform = quad->quadTransform(); + IntRect quadRect = quad->quadRect(); + quadTransform.translate(quadRect.x() + quadRect.width() / 2.0, quadRect.y() + quadRect.height() / 2.0); - drawTexturedQuad(quad->layerTransform(), bounds.width(), bounds.height(), quad->opacity(), sharedGeometryQuad(), binding.matrixLocation, binding.alphaLocation, -1); + drawTexturedQuad(quadTransform, quadRect.width(), quadRect.height(), quad->opacity(), sharedGeometryQuad(), binding.matrixLocation, binding.alphaLocation, -1); GLC(context(), context()->bindTexture(Extensions3D::TEXTURE_RECTANGLE_ARB, 0)); } diff --git a/Source/WebCore/platform/graphics/chromium/LayerRendererChromium.h b/Source/WebCore/platform/graphics/chromium/LayerRendererChromium.h index 6afe66806..415520d7f 100644 --- a/Source/WebCore/platform/graphics/chromium/LayerRendererChromium.h +++ b/Source/WebCore/platform/graphics/chromium/LayerRendererChromium.h @@ -37,7 +37,16 @@ #include "Extensions3DChromium.h" #include "TextureCopier.h" #include "TrackingTextureAllocator.h" +#include "cc/CCCheckerboardDrawQuad.h" +#include "cc/CCDebugBorderDrawQuad.h" +#include "cc/CCIOSurfaceDrawQuad.h" +#include "cc/CCRenderPassDrawQuad.h" #include "cc/CCRenderer.h" +#include "cc/CCSolidColorDrawQuad.h" +#include "cc/CCStreamVideoDrawQuad.h" +#include "cc/CCTextureDrawQuad.h" +#include "cc/CCTileDrawQuad.h" +#include "cc/CCYUVVideoDrawQuad.h" #include <wtf/PassOwnPtr.h> namespace WebKit { @@ -46,17 +55,7 @@ class WebGraphicsContext3D; namespace WebCore { -class CCCheckerboardDrawQuad; -class CCDebugBorderDrawQuad; -class CCDrawQuad; -class CCIOSurfaceDrawQuad; -class CCRenderPassDrawQuad; class CCScopedTexture; -class CCSolidColorDrawQuad; -class CCStreamVideoDrawQuad; -class CCTextureDrawQuad; -class CCTileDrawQuad; -class CCYUVVideoDrawQuad; class GeometryBinding; class ScopedEnsureFramebufferAllocation; diff --git a/Source/WebCore/platform/graphics/chromium/ManagedTexture.cpp b/Source/WebCore/platform/graphics/chromium/ManagedTexture.cpp deleted file mode 100644 index 4dabf1beb..000000000 --- a/Source/WebCore/platform/graphics/chromium/ManagedTexture.cpp +++ /dev/null @@ -1,151 +0,0 @@ -/* - * 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 INC. 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 INC. 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" - -#if USE(ACCELERATED_COMPOSITING) - -#include "ManagedTexture.h" - -#include "GraphicsContext3D.h" -#include "cc/CCGraphicsContext.h" -#include <public/WebGraphicsContext3D.h> - -using WebKit::WebGraphicsContext3D; - -namespace WebCore { - -ManagedTexture::ManagedTexture(TextureManager* manager) - : m_textureManager(manager) - , m_token(0) - , m_format(0) - , m_textureId(0) -{ - m_textureManager->registerTexture(this); -} - -ManagedTexture::ManagedTexture(TextureManager* manager, TextureToken token, IntSize size, unsigned format, unsigned textureId) - : m_textureManager(manager) - , m_token(token) - , m_size(size) - , m_format(format) - , m_textureId(textureId) -{ - m_textureManager->registerTexture(this); -} - -ManagedTexture::~ManagedTexture() -{ - if (!m_textureManager) - return; - m_textureManager->unregisterTexture(this); - if (m_token) - m_textureManager->releaseToken(m_token); -} - -void ManagedTexture::setTextureManager(TextureManager* manager) -{ - if (manager == m_textureManager) - return; - - if (m_textureManager) - m_textureManager->unregisterTexture(this); - m_textureManager = manager; - clear(); - if (m_textureManager) - m_textureManager->registerTexture(this); -} - -bool ManagedTexture::isValid(const IntSize& size, unsigned format) -{ - return m_token && size == m_size && format == m_format && m_textureManager && m_textureManager->hasTexture(m_token); -} - -bool ManagedTexture::reserve(const IntSize& size, unsigned format) -{ - if (!m_textureManager) - return false; - - if (!m_token) - m_token = m_textureManager->getToken(); - - bool reserved = true; - if (size == m_size && format == m_format && m_textureManager->hasTexture(m_token)) - m_textureManager->protectTexture(m_token); - else { - m_textureId = 0; - reserved = m_textureManager->requestTexture(m_token, size, format); - if (reserved) { - m_size = size; - m_format = format; - } - } - - return reserved; -} - -void ManagedTexture::unreserve() -{ - if (!m_token || !m_textureManager) - return; - - m_textureManager->unprotectTexture(m_token); -} - -void ManagedTexture::allocate(TextureAllocator* allocator) -{ - ASSERT(m_textureManager->hasTexture(m_token)); - if (!m_textureId) - m_textureId = m_textureManager->allocateTexture(allocator, m_token); -} - -void ManagedTexture::bindTexture(CCGraphicsContext* context, TextureAllocator* allocator) -{ - allocate(allocator); - WebGraphicsContext3D* context3d = context->context3D(); - if (!context3d) { - // FIXME: Implement this path for software compositing. - return; - } - context3d->bindTexture(GraphicsContext3D::TEXTURE_2D, m_textureId); -} - -PassOwnPtr<ManagedTexture> ManagedTexture::steal() -{ - OwnPtr<ManagedTexture> texture = adoptPtr(new ManagedTexture(m_textureManager, m_token, m_size, m_format, m_textureId)); - clear(); - return texture.release(); -} - -void ManagedTexture::clear() -{ - m_token = 0; - m_size = IntSize(); - m_format = 0; - m_textureId = 0; -} - -} - -#endif // USE(ACCELERATED_COMPOSITING) diff --git a/Source/WebCore/platform/graphics/chromium/ManagedTexture.h b/Source/WebCore/platform/graphics/chromium/ManagedTexture.h deleted file mode 100644 index 6e67ebf68..000000000 --- a/Source/WebCore/platform/graphics/chromium/ManagedTexture.h +++ /dev/null @@ -1,86 +0,0 @@ -/* - * 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 INC. 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 INC. 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 ManagedTexture_h -#define ManagedTexture_h - -#include "IntSize.h" -#include "TextureManager.h" - -#include <wtf/FastAllocBase.h> -#include <wtf/Noncopyable.h> -#include <wtf/PassOwnPtr.h> -#include <wtf/RefPtr.h> - -namespace WebCore { - -class CCGraphicsContext; - -class ManagedTexture { - WTF_MAKE_NONCOPYABLE(ManagedTexture); -public: - static PassOwnPtr<ManagedTexture> create(TextureManager* manager) - { - return adoptPtr(new ManagedTexture(manager)); - } - ~ManagedTexture(); - - void setTextureManager(TextureManager*); - void clearManager() { m_textureManager = 0; } - - bool isValid(const IntSize&, unsigned format); - bool reserve(const IntSize&, unsigned format); - void unreserve(); - bool isReserved() - { - return m_textureManager && m_textureManager->isProtected(m_token); - } - - void allocate(TextureAllocator*); - void bindTexture(CCGraphicsContext*, TextureAllocator*); - - IntSize size() const { return m_size; } - unsigned format() const { return m_format; } - unsigned textureId() const { return m_textureId; } - - // Steal token and textureId by instantiates a new texture using existing - // member variables. - PassOwnPtr<ManagedTexture> steal(); - -private: - explicit ManagedTexture(TextureManager*); - ManagedTexture(TextureManager*, TextureToken, IntSize, unsigned format, unsigned textureId); - - void clear(); - - TextureManager* m_textureManager; - TextureToken m_token; - IntSize m_size; - unsigned m_format; - unsigned m_textureId; -}; - -} - -#endif // ManagedTexture_h diff --git a/Source/WebCore/platform/graphics/chromium/RenderSurfaceChromium.h b/Source/WebCore/platform/graphics/chromium/RenderSurfaceChromium.h index 0e7d4e38c..2b608f4e7 100644 --- a/Source/WebCore/platform/graphics/chromium/RenderSurfaceChromium.h +++ b/Source/WebCore/platform/graphics/chromium/RenderSurfaceChromium.h @@ -40,7 +40,6 @@ namespace WebCore { class FilterOperations; class LayerChromium; class LayerRendererChromium; -class ManagedTexture; class RenderSurfaceChromium { WTF_MAKE_NONCOPYABLE(RenderSurfaceChromium); diff --git a/Source/WebCore/platform/graphics/chromium/cc/CCCheckerboardDrawQuad.cpp b/Source/WebCore/platform/graphics/chromium/TextureAllocator.h index aae033514..58de11522 100644 --- a/Source/WebCore/platform/graphics/chromium/cc/CCCheckerboardDrawQuad.cpp +++ b/Source/WebCore/platform/graphics/chromium/TextureAllocator.h @@ -1,42 +1,49 @@ /* - * Copyright (C) 2012 Google Inc. All rights reserved. + * Copyright (C) 2012, 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 + * THIS SOFTWARE IS PROVIDED BY APPLE INC. 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 + * DISCLAIMED. IN NO EVENT SHALL APPLE INC. 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. + * 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 "cc/CCCheckerboardDrawQuad.h" +#ifndef TextureAllocator_h +#define TextureAllocator_h + +#include "GraphicsContext3D.h" +#include "IntRect.h" +#include "IntSize.h" namespace WebCore { -PassOwnPtr<CCCheckerboardDrawQuad> CCCheckerboardDrawQuad::create(const CCSharedQuadState* sharedQuadState, const IntRect& quadRect) -{ - return adoptPtr(new CCCheckerboardDrawQuad(sharedQuadState, quadRect)); -} +class TextureAllocator { +public: + virtual unsigned createTexture(const IntSize&, GC3Denum format) = 0; + virtual void deleteTexture(unsigned texture, const IntSize&, GC3Denum) = 0; + virtual void deleteAllTextures() = 0; -CCCheckerboardDrawQuad::CCCheckerboardDrawQuad(const CCSharedQuadState* sharedQuadState, const IntRect& quadRect) - : CCDrawQuad(sharedQuadState, CCDrawQuad::Checkerboard, quadRect) -{ -} +protected: + virtual ~TextureAllocator() { } +}; } + +#endif + + diff --git a/Source/WebCore/platform/graphics/chromium/TextureManager.cpp b/Source/WebCore/platform/graphics/chromium/TextureManager.cpp deleted file mode 100644 index 485c72228..000000000 --- a/Source/WebCore/platform/graphics/chromium/TextureManager.cpp +++ /dev/null @@ -1,325 +0,0 @@ -/* - * 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 INC. 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 INC. 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" - -#if USE(ACCELERATED_COMPOSITING) - -#include "TextureManager.h" - -#include "ManagedTexture.h" -#include "TraceEvent.h" - -using namespace std; - -namespace WebCore { - - -namespace { -size_t memoryLimitBytes(size_t viewportMultiplier, const IntSize& viewportSize, size_t minMegabytes, size_t maxMegabytes) -{ - if (!viewportMultiplier) - return maxMegabytes * 1024 * 1024; - if (viewportSize.isEmpty()) - return minMegabytes * 1024 * 1024; - return max(minMegabytes * 1024 * 1024, min(maxMegabytes * 1024 * 1024, viewportMultiplier * TextureManager::memoryUseBytes(viewportSize, GraphicsContext3D::RGBA))); -} -} - -size_t TextureManager::highLimitBytes(const IntSize& viewportSize) -{ - size_t viewportMultiplier, minMegabytes, maxMegabytes; -#if OS(ANDROID) - viewportMultiplier = 16; - minMegabytes = 32; - maxMegabytes = 64; -#else - viewportMultiplier = 0; - minMegabytes = 0; - maxMegabytes = 128; -#endif - return memoryLimitBytes(viewportMultiplier, viewportSize, minMegabytes, maxMegabytes); -} - -size_t TextureManager::reclaimLimitBytes(const IntSize& viewportSize) -{ - size_t viewportMultiplier, minMegabytes, maxMegabytes; -#if OS(ANDROID) - viewportMultiplier = 8; - minMegabytes = 16; - maxMegabytes = 32; -#else - viewportMultiplier = 0; - minMegabytes = 0; - maxMegabytes = 64; -#endif - return memoryLimitBytes(viewportMultiplier, viewportSize, minMegabytes, maxMegabytes); -} - -size_t TextureManager::memoryUseBytes(const IntSize& size, GC3Denum textureFormat) -{ - // FIXME: This assumes all textures are 1 byte/component. - const GC3Denum type = GraphicsContext3D::UNSIGNED_BYTE; - unsigned int componentsPerPixel = 4; - unsigned int bytesPerComponent = 1; - if (!GraphicsContext3D::computeFormatAndTypeParameters(textureFormat, type, &componentsPerPixel, &bytesPerComponent)) - ASSERT_NOT_REACHED(); - - return size.width() * size.height() * componentsPerPixel * bytesPerComponent; -} - - -TextureManager::TextureManager(size_t maxMemoryLimitBytes, size_t preferredMemoryLimitBytes, int maxTextureSize) - : m_maxMemoryLimitBytes(maxMemoryLimitBytes) - , m_preferredMemoryLimitBytes(preferredMemoryLimitBytes) - , m_memoryUseBytes(0) - , m_maxTextureSize(maxTextureSize) - , m_nextToken(1) -{ -} - -TextureManager::~TextureManager() -{ - for (HashSet<ManagedTexture*>::iterator it = m_registeredTextures.begin(); it != m_registeredTextures.end(); ++it) - (*it)->clearManager(); -} - -void TextureManager::setMemoryAllocationLimitBytes(size_t memoryLimitBytes) -{ - setMaxMemoryLimitBytes(memoryLimitBytes); -#if defined(OS_ANDROID) - // On android, we are setting the preferred memory limit to half of our - // maximum allocation, because we would like to stay significantly below - // the absolute memory limit whenever we can. Specifically, by limitting - // prepainting only to the halfway memory mark. - setPreferredMemoryLimitBytes(memoryLimitBytes / 2); -#else - setPreferredMemoryLimitBytes(memoryLimitBytes); -#endif -} - -void TextureManager::setMaxMemoryLimitBytes(size_t memoryLimitBytes) -{ - reduceMemoryToLimit(memoryLimitBytes); - ASSERT(currentMemoryUseBytes() <= memoryLimitBytes); - m_maxMemoryLimitBytes = memoryLimitBytes; -} - -void TextureManager::setPreferredMemoryLimitBytes(size_t memoryLimitBytes) -{ - m_preferredMemoryLimitBytes = memoryLimitBytes; -} - -void TextureManager::registerTexture(ManagedTexture* texture) -{ - ASSERT(texture); - ASSERT(!m_registeredTextures.contains(texture)); - - m_registeredTextures.add(texture); -} - -void TextureManager::unregisterTexture(ManagedTexture* texture) -{ - ASSERT(texture); - ASSERT(m_registeredTextures.contains(texture)); - - m_registeredTextures.remove(texture); -} - -TextureToken TextureManager::getToken() -{ - return m_nextToken++; -} - -void TextureManager::releaseToken(TextureToken token) -{ - TextureMap::iterator it = m_textures.find(token); - if (it != m_textures.end()) - removeTexture(token, it->second); -} - -bool TextureManager::hasTexture(TextureToken token) -{ - return m_textures.contains(token); -} - -bool TextureManager::isProtected(TextureToken token) -{ - return token && hasTexture(token) && m_textures.get(token).isProtected; -} - -void TextureManager::protectTexture(TextureToken token) -{ - ASSERT(hasTexture(token)); - TextureInfo info = m_textures.take(token); - info.isProtected = true; - m_textures.add(token, info); - // If someone protects a texture, put it at the end of the LRU list. - m_textureLRUSet.remove(token); - m_textureLRUSet.add(token); -} - -void TextureManager::unprotectTexture(TextureToken token) -{ - TextureMap::iterator it = m_textures.find(token); - if (it != m_textures.end()) - it->second.isProtected = false; -} - -void TextureManager::unprotectAllTextures() -{ - for (TextureMap::iterator it = m_textures.begin(); it != m_textures.end(); ++it) - it->second.isProtected = false; -} - -void TextureManager::evictTexture(TextureToken token, TextureInfo info) -{ - TRACE_EVENT0("cc", "TextureManager::evictTexture"); - removeTexture(token, info); -} - -void TextureManager::reduceMemoryToLimit(size_t limit) -{ - while (m_memoryUseBytes > limit) { - ASSERT(!m_textureLRUSet.isEmpty()); - bool foundCandidate = false; - for (ListHashSet<TextureToken>::iterator lruIt = m_textureLRUSet.begin(); lruIt != m_textureLRUSet.end(); ++lruIt) { - TextureToken token = *lruIt; - TextureInfo info = m_textures.get(token); - if (info.isProtected) - continue; - evictTexture(token, info); - foundCandidate = true; - break; - } - if (!foundCandidate) - return; - } -} - -void TextureManager::addTexture(TextureToken token, TextureInfo info) -{ - ASSERT(!m_textureLRUSet.contains(token)); - ASSERT(!m_textures.contains(token)); - m_memoryUseBytes += memoryUseBytes(info.size, info.format); - m_textures.set(token, info); - m_textureLRUSet.add(token); -} - -void TextureManager::deleteEvictedTextures(TextureAllocator* allocator) -{ - if (allocator) { - for (size_t i = 0; i < m_evictedTextures.size(); ++i) { - if (m_evictedTextures[i].textureId) { -#ifndef NDEBUG - ASSERT(m_evictedTextures[i].allocator == allocator); -#endif - allocator->deleteTexture(m_evictedTextures[i].textureId, m_evictedTextures[i].size, m_evictedTextures[i].format); - } - } - } - m_evictedTextures.clear(); -} - -void TextureManager::evictAndRemoveAllDeletedTextures() -{ - unprotectAllTextures(); - reduceMemoryToLimit(0); - m_evictedTextures.clear(); -} - -void TextureManager::evictAndDeleteAllTextures(TextureAllocator* allocator) -{ - unprotectAllTextures(); - reduceMemoryToLimit(0); - deleteEvictedTextures(allocator); -} - -void TextureManager::removeTexture(TextureToken token, TextureInfo info) -{ - ASSERT(m_textureLRUSet.contains(token)); - ASSERT(m_textures.contains(token)); - m_memoryUseBytes -= memoryUseBytes(info.size, info.format); - m_textures.remove(token); - ASSERT(m_textureLRUSet.contains(token)); - m_textureLRUSet.remove(token); - EvictionEntry entry; - entry.textureId = info.textureId; - entry.size = info.size; - entry.format = info.format; -#ifndef NDEBUG - entry.allocator = info.allocator; -#endif - m_evictedTextures.append(entry); -} - -unsigned TextureManager::allocateTexture(TextureAllocator* allocator, TextureToken token) -{ - TextureMap::iterator it = m_textures.find(token); - ASSERT(it != m_textures.end()); - TextureInfo* info = &it.get()->second; - ASSERT(info->isProtected); - - unsigned textureId = allocator->createTexture(info->size, info->format); - info->textureId = textureId; -#ifndef NDEBUG - info->allocator = allocator; -#endif - return textureId; -} - -bool TextureManager::requestTexture(TextureToken token, IntSize size, unsigned format) -{ - if (size.width() > m_maxTextureSize || size.height() > m_maxTextureSize) - return false; - - TextureMap::iterator it = m_textures.find(token); - if (it != m_textures.end()) { - ASSERT(it->second.size != size || it->second.format != format); - removeTexture(token, it->second); - } - - size_t memoryRequiredBytes = memoryUseBytes(size, format); - if (memoryRequiredBytes > m_maxMemoryLimitBytes) - return false; - - reduceMemoryToLimit(m_maxMemoryLimitBytes - memoryRequiredBytes); - if (m_memoryUseBytes + memoryRequiredBytes > m_maxMemoryLimitBytes) - return false; - - TextureInfo info; - info.size = size; - info.format = format; - info.textureId = 0; - info.isProtected = true; -#ifndef NDEBUG - info.allocator = 0; -#endif - addTexture(token, info); - return true; -} - -} - -#endif // USE(ACCELERATED_COMPOSITING) diff --git a/Source/WebCore/platform/graphics/chromium/TextureManager.h b/Source/WebCore/platform/graphics/chromium/TextureManager.h deleted file mode 100644 index 47a189bcc..000000000 --- a/Source/WebCore/platform/graphics/chromium/TextureManager.h +++ /dev/null @@ -1,140 +0,0 @@ -/* - * 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 INC. 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 INC. 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 TextureManager_h -#define TextureManager_h - -#include "GraphicsContext3D.h" -#include "IntRect.h" -#include "IntSize.h" -#include <wtf/FastAllocBase.h> -#include <wtf/HashMap.h> -#include <wtf/HashSet.h> -#include <wtf/ListHashSet.h> -#include <wtf/Vector.h> - -namespace WebCore { - -class ManagedTexture; -typedef int TextureToken; - -class TextureAllocator { -public: - virtual unsigned createTexture(const IntSize&, GC3Denum format) = 0; - virtual void deleteTexture(unsigned texture, const IntSize&, GC3Denum) = 0; - virtual void deleteAllTextures() = 0; - -protected: - virtual ~TextureAllocator() { } -}; - -class TextureManager { - WTF_MAKE_NONCOPYABLE(TextureManager); -public: - static PassOwnPtr<TextureManager> create(size_t maxMemoryLimitBytes, size_t preferredMemoryLimitBytes, int maxTextureSize) - { - return adoptPtr(new TextureManager(maxMemoryLimitBytes, preferredMemoryLimitBytes, maxTextureSize)); - } - ~TextureManager(); - - // Absolute maximum limit for texture allocations for this instance. - static size_t highLimitBytes(const IntSize& viewportSize); - // Preferred texture size limit given the viewport size. - static size_t reclaimLimitBytes(const IntSize& viewportSize); - - static size_t memoryUseBytes(const IntSize&, GC3Denum format); - - void setMemoryAllocationLimitBytes(size_t); - void setMaxMemoryLimitBytes(size_t); - size_t maxMemoryLimitBytes() { return m_maxMemoryLimitBytes; } - void setPreferredMemoryLimitBytes(size_t); - size_t preferredMemoryLimitBytes() { return m_preferredMemoryLimitBytes; } - - void registerTexture(ManagedTexture*); - void unregisterTexture(ManagedTexture*); - - TextureToken getToken(); - void releaseToken(TextureToken); - bool hasTexture(TextureToken); - - bool requestTexture(TextureToken, IntSize, GC3Denum textureFormat); - - void protectTexture(TextureToken); - void unprotectTexture(TextureToken); - void unprotectAllTextures(); - bool isProtected(TextureToken); - - unsigned allocateTexture(TextureAllocator*, TextureToken); - void deleteEvictedTextures(TextureAllocator*); - - void evictAndRemoveAllDeletedTextures(); - void evictAndDeleteAllTextures(TextureAllocator*); - - void reduceMemoryToLimit(size_t); - size_t currentMemoryUseBytes() const { return m_memoryUseBytes; } - -private: - TextureManager(size_t maxMemoryLimitBytes, size_t preferredMemoryLimitBytes, int maxTextureSize); - - struct TextureInfo { - IntSize size; - GC3Denum format; - unsigned textureId; - bool isProtected; -#ifndef NDEBUG - TextureAllocator* allocator; -#endif - }; - - void addTexture(TextureToken, TextureInfo); - void removeTexture(TextureToken, TextureInfo); - void evictTexture(TextureToken, TextureInfo); - - HashSet<ManagedTexture*> m_registeredTextures; - - typedef HashMap<TextureToken, TextureInfo> TextureMap; - TextureMap m_textures; - ListHashSet<TextureToken> m_textureLRUSet; - - size_t m_maxMemoryLimitBytes; - size_t m_preferredMemoryLimitBytes; - size_t m_memoryUseBytes; - int m_maxTextureSize; - TextureToken m_nextToken; - - struct EvictionEntry { - unsigned textureId; - IntSize size; - GC3Denum format; -#ifndef NDEBUG - TextureAllocator* allocator; -#endif - }; - - Vector<EvictionEntry> m_evictedTextures; -}; - -} - -#endif diff --git a/Source/WebCore/platform/graphics/chromium/TiledLayerChromium.cpp b/Source/WebCore/platform/graphics/chromium/TiledLayerChromium.cpp index 5c4bc05ce..d085c9dd1 100644 --- a/Source/WebCore/platform/graphics/chromium/TiledLayerChromium.cpp +++ b/Source/WebCore/platform/graphics/chromium/TiledLayerChromium.cpp @@ -30,7 +30,6 @@ #include "TiledLayerChromium.h" #include "GraphicsContext3D.h" -#include "ManagedTexture.h" #include "Region.h" #include "TextStream.h" @@ -156,7 +155,7 @@ void TiledLayerChromium::updateBounds() newRegion.subtract(oldRegion); Vector<IntRect> rects = newRegion.rects(); for (size_t i = 0; i < rects.size(); ++i) - invalidateRect(rects[i]); + invalidateContentRect(rects[i]); } void TiledLayerChromium::setTileSize(const IntSize& size) @@ -288,7 +287,7 @@ void TiledLayerChromium::setNeedsDisplayRect(const FloatRect& dirtyRect) FloatRect scaledDirtyRect(dirtyRect); scaledDirtyRect.scale(contentsWidthScale, contentsHeightScale); IntRect dirty = enclosingIntRect(scaledDirtyRect); - invalidateRect(dirty); + invalidateContentRect(dirty); LayerChromium::setNeedsDisplayRect(dirtyRect); } @@ -306,10 +305,10 @@ void TiledLayerChromium::setIsNonCompositedContent(bool isNonCompositedContent) setBorderTexelOption(borderTexelOption); } -void TiledLayerChromium::invalidateRect(const IntRect& layerRect) +void TiledLayerChromium::invalidateContentRect(const IntRect& contentRect) { updateBounds(); - if (m_tiler->isEmpty() || layerRect.isEmpty() || m_skipsDraw) + if (m_tiler->isEmpty() || contentRect.isEmpty() || m_skipsDraw) return; for (CCLayerTilingData::TileMap::const_iterator iter = m_tiler->tiles().begin(); iter != m_tiler->tiles().end(); ++iter) { @@ -319,7 +318,7 @@ void TiledLayerChromium::invalidateRect(const IntRect& layerRect) if (!tile) continue; IntRect bound = m_tiler->tileRect(tile); - bound.intersect(layerRect); + bound.intersect(contentRect); tile->dirtyRect.unite(bound); } } @@ -356,7 +355,7 @@ void TiledLayerChromium::updateTiles(bool idle, int left, int top, int right, in // Create tiles as needed, expanding a dirty rect to contain all // the dirty regions currently being drawn. All dirty tiles that are to be painted // get their updateRect set to dirtyRect and dirtyRect cleared. This way if - // invalidateRect is invoked during updateLayerRect we don't lose the request. + // invalidateContentRect is invoked during updateContentRect we don't lose the request. IntRect paintRect; for (int j = top; j <= bottom; ++j) { for (int i = left; i <= right; ++i) { @@ -377,7 +376,7 @@ void TiledLayerChromium::updateTiles(bool idle, int left, int top, int right, in // When not idle painting, if the visible region of the tile is occluded, don't reserve a texture or update the tile. // If any part of the tile is visible, then we need to update it so the tile is pushed to the impl thread. if (!idle && occlusion) { - IntRect visibleTileRect = intersection(m_tiler->tileBounds(i, j), visibleLayerRect()); + IntRect visibleTileRect = intersection(m_tiler->tileBounds(i, j), visibleContentRect()); if (occlusion->occluded(this, visibleTileRect)) { ASSERT(!tile->updated); continue; @@ -517,21 +516,21 @@ void TiledLayerChromium::updateTiles(bool idle, int left, int top, int right, in void TiledLayerChromium::setTexturePriorities(const CCPriorityCalculator& priorityCalc) { - setTexturePrioritiesInRect(priorityCalc, visibleLayerRect()); + setTexturePrioritiesInRect(priorityCalc, visibleContentRect()); } -void TiledLayerChromium::setTexturePrioritiesInRect(const CCPriorityCalculator& priorityCalc, const IntRect& visibleRect) +void TiledLayerChromium::setTexturePrioritiesInRect(const CCPriorityCalculator& priorityCalc, const IntRect& visibleContentRect) { updateBounds(); resetUpdateState(); - IntRect prepaintRect = idlePaintRect(visibleRect); + IntRect prepaintRect = idlePaintRect(visibleContentRect); bool drawsToRootSurface = !targetRenderSurface()->targetRenderSurface(); // Minimally create the tiles in the desired pre-paint rect. if (!prepaintRect.isEmpty()) { int left, top, right, bottom; - m_tiler->layerRectToTileIndices(prepaintRect, left, top, right, bottom); + m_tiler->contentRectToTileIndices(prepaintRect, left, top, right, bottom); for (int j = top; j <= bottom; ++j) for (int i = left; i <= right; ++i) if (!tileAt(i, j)) @@ -542,9 +541,9 @@ void TiledLayerChromium::setTexturePrioritiesInRect(const CCPriorityCalculator& // These textures must stay alive while the updated textures are incrementally // uploaded, swapped atomically via pushProperties, and finally deleted // after the commit is complete, after which they can be recycled. - if (!visibleRect.isEmpty()) { + if (!visibleContentRect.isEmpty()) { int left, top, right, bottom; - m_tiler->layerRectToTileIndices(visibleRect, left, top, right, bottom); + m_tiler->contentRectToTileIndices(visibleContentRect, left, top, right, bottom); for (int j = top; j <= bottom; ++j) { for (int i = left; i <= right; ++i) { UpdatableTile* tile = tileAt(i, j); @@ -581,10 +580,10 @@ void TiledLayerChromium::setTexturePrioritiesInRect(const CCPriorityCalculator& // can be removed soon with better priorities, but for now paint these layers after // 512 pixels of pre-painting. Later we can just pass an animating flag etc. to the // calculator and it can take care of this special case if we still need it. - if (visibleRect.isEmpty() && !prepaintRect.isEmpty()) + if (visibleContentRect.isEmpty() && !prepaintRect.isEmpty()) tile->managedTexture()->setRequestPriority(priorityCalc.priorityFromDistance(512, drawsToRootSurface)); - else if (!visibleRect.isEmpty()) - tile->managedTexture()->setRequestPriority(priorityCalc.priorityFromDistance(visibleRect, tileRect, drawsToRootSurface)); + else if (!visibleContentRect.isEmpty()) + tile->managedTexture()->setRequestPriority(priorityCalc.priorityFromDistance(visibleContentRect, tileRect, drawsToRootSurface)); } } @@ -593,8 +592,8 @@ Region TiledLayerChromium::visibleContentOpaqueRegion() const if (m_skipsDraw) return Region(); if (opaque()) - return visibleLayerRect(); - return m_tiler->opaqueRegionInLayerRect(visibleLayerRect()); + return visibleContentRect(); + return m_tiler->opaqueRegionInContentRect(visibleContentRect()); } void TiledLayerChromium::resetUpdateState() @@ -611,7 +610,7 @@ void TiledLayerChromium::resetUpdateState() } } -void TiledLayerChromium::updateLayerRect(CCTextureUpdater& updater, const IntRect& contentRect, const CCOcclusionTracker* occlusion) +void TiledLayerChromium::updateContentRect(CCTextureUpdater& updater, const IntRect& contentRect, const CCOcclusionTracker* occlusion) { m_skipsDraw = false; m_skipsIdlePaint = false; @@ -625,7 +624,7 @@ void TiledLayerChromium::updateLayerRect(CCTextureUpdater& updater, const IntRec // Visible painting. Only paint visible tiles if the visible rect isn't empty. if (!contentRect.isEmpty()) { int left, top, right, bottom; - m_tiler->layerRectToTileIndices(contentRect, left, top, right, bottom); + m_tiler->contentRectToTileIndices(contentRect, left, top, right, bottom); updateTiles(false, left, top, right, bottom, updater, occlusion); } @@ -639,7 +638,7 @@ void TiledLayerChromium::updateLayerRect(CCTextureUpdater& updater, const IntRec return; int prepaintLeft, prepaintTop, prepaintRight, prepaintBottom; - m_tiler->layerRectToTileIndices(idlePaintContentRect, prepaintLeft, prepaintTop, prepaintRight, prepaintBottom); + m_tiler->contentRectToTileIndices(idlePaintContentRect, prepaintLeft, prepaintTop, prepaintRight, prepaintBottom); // If the layer is not visible, we have nothing to expand from, so instead we prepaint the outer-most set of tiles. if (contentRect.isEmpty()) { @@ -657,7 +656,7 @@ void TiledLayerChromium::updateLayerRect(CCTextureUpdater& updater, const IntRec } int left, top, right, bottom; - m_tiler->layerRectToTileIndices(contentRect, left, top, right, bottom); + m_tiler->contentRectToTileIndices(contentRect, left, top, right, bottom); // Otherwise, prepaint anything that was occluded but inside the layer's visible region. updateTiles(true, left, top, right, bottom, updater, 0); @@ -693,7 +692,7 @@ void TiledLayerChromium::updateLayerRect(CCTextureUpdater& updater, const IntRec } } -bool TiledLayerChromium::needsIdlePaint(const IntRect& contentRect) +bool TiledLayerChromium::needsIdlePaint(const IntRect& visibleContentRect) { if (m_skipsIdlePaint) return false; @@ -701,17 +700,17 @@ bool TiledLayerChromium::needsIdlePaint(const IntRect& contentRect) if (m_tiler->hasEmptyBounds()) return false; - IntRect idlePaintContentRect = idlePaintRect(contentRect); + IntRect idlePaintContentRect = idlePaintRect(visibleContentRect); if (idlePaintContentRect.isEmpty()) return false; int left, top, right, bottom; - m_tiler->layerRectToTileIndices(idlePaintContentRect, left, top, right, bottom); + m_tiler->contentRectToTileIndices(idlePaintContentRect, left, top, right, bottom); for (int j = top; j <= bottom; ++j) { for (int i = left; i <= right; ++i) { - // If the layerRect is empty, then we are painting the outer-most set of tiles only. - if (contentRect.isEmpty() && i != left && i != right && j != top && j != bottom) + // If the visibleContentRect is empty, then we are painting the outer-most set of tiles only. + if (visibleContentRect.isEmpty() && i != left && i != right && j != top && j != bottom) continue; UpdatableTile* tile = tileAt(i, j); ASSERT(tile); // Did setTexturePriorities get skipped? @@ -728,14 +727,14 @@ bool TiledLayerChromium::needsIdlePaint(const IntRect& contentRect) return false; } -IntRect TiledLayerChromium::idlePaintRect(const IntRect& visibleRect) +IntRect TiledLayerChromium::idlePaintRect(const IntRect& visibleContentRect) { IntRect contentRect(IntPoint::zero(), contentBounds()); // For layers that are animating transforms but not visible at all, we don't know what part // of them is going to become visible. For small layers we return the entire layer, for larger // ones we avoid prepainting the layer at all. - if (visibleRect.isEmpty()) { + if (visibleContentRect.isEmpty()) { bool isSmallLayer = m_tiler->numTilesX() <= 9 && m_tiler->numTilesY() <= 9 && m_tiler->numTilesX() * m_tiler->numTilesY() <= 9; if ((drawTransformIsAnimating() || screenSpaceTransformIsAnimating()) && isSmallLayer) return contentRect; @@ -744,7 +743,7 @@ IntRect TiledLayerChromium::idlePaintRect(const IntRect& visibleRect) // FIXME: This can be made a lot larger now! We should increase // this slowly while insuring it doesn't cause any perf issues. - IntRect prepaintRect = visibleRect; + IntRect prepaintRect = visibleContentRect; prepaintRect.inflateX(m_tiler->tileSize().width()); prepaintRect.inflateY(m_tiler->tileSize().height() * 2); prepaintRect.intersect(contentRect); diff --git a/Source/WebCore/platform/graphics/chromium/TiledLayerChromium.h b/Source/WebCore/platform/graphics/chromium/TiledLayerChromium.h index d2ed45c04..c80c422f9 100644 --- a/Source/WebCore/platform/graphics/chromium/TiledLayerChromium.h +++ b/Source/WebCore/platform/graphics/chromium/TiledLayerChromium.h @@ -77,18 +77,18 @@ protected: virtual void createTextureUpdaterIfNeeded() = 0; // Set invalidations to be potentially repainted during update(). - void invalidateRect(const IntRect& layerRect); + void invalidateContentRect(const IntRect& contentRect); // Reset state on tiles that will be used for updating the layer. void resetUpdateState(); - // Prepare data needed to update textures that intersect with layerRect. - void updateLayerRect(CCTextureUpdater&, const IntRect& layerRect, const CCOcclusionTracker*); + // Prepare data needed to update textures that intersect with contentRect. + void updateContentRect(CCTextureUpdater&, const IntRect& contentRect, const CCOcclusionTracker*); // After preparing an update, returns true if more painting is needed. - bool needsIdlePaint(const IntRect& layerRect); + bool needsIdlePaint(const IntRect& visibleContentRect); - IntRect idlePaintRect(const IntRect& visibleLayerRect); + IntRect idlePaintRect(const IntRect& visibleContentRect); bool skipsDraw() const { return m_skipsDraw; } @@ -104,7 +104,7 @@ private: bool tileOnlyNeedsPartialUpdate(UpdatableTile*); bool tileNeedsBufferedUpdate(UpdatableTile*); - void setTexturePrioritiesInRect(const CCPriorityCalculator&, const IntRect& visibleLayerRect); + void setTexturePrioritiesInRect(const CCPriorityCalculator&, const IntRect& visibleContentRect); void updateTiles(bool idle, int left, int top, int right, int bottom, CCTextureUpdater&, const CCOcclusionTracker*); diff --git a/Source/WebCore/platform/graphics/chromium/TrackingTextureAllocator.cpp b/Source/WebCore/platform/graphics/chromium/TrackingTextureAllocator.cpp index c589a3c6e..7ae29f912 100644 --- a/Source/WebCore/platform/graphics/chromium/TrackingTextureAllocator.cpp +++ b/Source/WebCore/platform/graphics/chromium/TrackingTextureAllocator.cpp @@ -75,7 +75,7 @@ unsigned TrackingTextureAllocator::createTexture(const IntSize& size, GC3Denum f if (size.width() > m_maxTextureSize || size.height() > m_maxTextureSize) return 0; - m_currentMemoryUseBytes += TextureManager::memoryUseBytes(size, format); + m_currentMemoryUseBytes += CCTexture::memorySizeBytes(size, format); unsigned textureId = 0; GLC(m_context, textureId = m_context->createTexture()); @@ -100,7 +100,7 @@ unsigned TrackingTextureAllocator::createTexture(const IntSize& size, GC3Denum f void TrackingTextureAllocator::deleteTexture(unsigned textureId, const IntSize& size, GC3Denum format) { - m_currentMemoryUseBytes -= TextureManager::memoryUseBytes(size, format); + m_currentMemoryUseBytes -= CCTexture::memorySizeBytes(size, format); GLC(m_context, m_context->deleteTexture(textureId)); GLC(m_context, m_context->deleteTexture(textureId)); ASSERT(m_allocatedTextureIds.contains(textureId)); diff --git a/Source/WebCore/platform/graphics/chromium/TrackingTextureAllocator.h b/Source/WebCore/platform/graphics/chromium/TrackingTextureAllocator.h index 78ef40d1b..38f7ca043 100644 --- a/Source/WebCore/platform/graphics/chromium/TrackingTextureAllocator.h +++ b/Source/WebCore/platform/graphics/chromium/TrackingTextureAllocator.h @@ -25,7 +25,7 @@ #ifndef TrackingTextureAllocator_h #define TrackingTextureAllocator_h -#include "TextureManager.h" +#include "TextureAllocator.h" #include <wtf/HashSet.h> #include <wtf/PassRefPtr.h> diff --git a/Source/WebCore/platform/graphics/chromium/cc/CCCheckerboardDrawQuad.h b/Source/WebCore/platform/graphics/chromium/cc/CCCheckerboardDrawQuad.h index 27f8c56bd..35104dcf5 100644 --- a/Source/WebCore/platform/graphics/chromium/cc/CCCheckerboardDrawQuad.h +++ b/Source/WebCore/platform/graphics/chromium/cc/CCCheckerboardDrawQuad.h @@ -26,20 +26,10 @@ #ifndef CCCheckerboardDrawQuad_h #define CCCheckerboardDrawQuad_h -#include "cc/CCDrawQuad.h" -#include <wtf/PassOwnPtr.h> +#include <public/WebCompositorCheckerboardQuad.h> namespace WebCore { - -class CCCheckerboardDrawQuad : public CCDrawQuad { - WTF_MAKE_NONCOPYABLE(CCCheckerboardDrawQuad); -public: - static PassOwnPtr<CCCheckerboardDrawQuad> create(const CCSharedQuadState*, const IntRect&); - -private: - CCCheckerboardDrawQuad(const CCSharedQuadState*, const IntRect&); -}; - +typedef WebKit::WebCompositorCheckerboardQuad CCCheckerboardDrawQuad; } #endif diff --git a/Source/WebCore/platform/graphics/chromium/cc/CCDebugBorderDrawQuad.cpp b/Source/WebCore/platform/graphics/chromium/cc/CCDebugBorderDrawQuad.cpp deleted file mode 100644 index 1527c47c5..000000000 --- a/Source/WebCore/platform/graphics/chromium/cc/CCDebugBorderDrawQuad.cpp +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright (C) 2011 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 "cc/CCDebugBorderDrawQuad.h" - -namespace WebCore { - -PassOwnPtr<CCDebugBorderDrawQuad> CCDebugBorderDrawQuad::create(const CCSharedQuadState* sharedQuadState, const IntRect& quadRect, SkColor color, int width) -{ - return adoptPtr(new CCDebugBorderDrawQuad(sharedQuadState, quadRect, color, width)); -} - -CCDebugBorderDrawQuad::CCDebugBorderDrawQuad(const CCSharedQuadState* sharedQuadState, const IntRect& quadRect, SkColor color, int width) - : CCDrawQuad(sharedQuadState, CCDrawQuad::DebugBorder, quadRect) - , m_color(color) - , m_width(width) -{ - m_quadOpaque = false; - if (SkColorGetA(m_color) < 255) - m_needsBlending = true; -} - -} diff --git a/Source/WebCore/platform/graphics/chromium/cc/CCDebugBorderDrawQuad.h b/Source/WebCore/platform/graphics/chromium/cc/CCDebugBorderDrawQuad.h index ea1cf8476..a72c27417 100644 --- a/Source/WebCore/platform/graphics/chromium/cc/CCDebugBorderDrawQuad.h +++ b/Source/WebCore/platform/graphics/chromium/cc/CCDebugBorderDrawQuad.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2011 Google Inc. All rights reserved. + * Copyright (C) 2012 Google Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -26,27 +26,10 @@ #ifndef CCDebugBorderDrawQuad_h #define CCDebugBorderDrawQuad_h -#include "SkColor.h" -#include "cc/CCDrawQuad.h" -#include <wtf/PassOwnPtr.h> +#include <public/WebCompositorDebugBorderQuad.h> namespace WebCore { - -class CCDebugBorderDrawQuad : public CCDrawQuad { - WTF_MAKE_NONCOPYABLE(CCDebugBorderDrawQuad); -public: - static PassOwnPtr<CCDebugBorderDrawQuad> create(const CCSharedQuadState*, const IntRect&, SkColor, int width); - - SkColor color() const { return m_color; }; - int width() const { return m_width; } - -private: - CCDebugBorderDrawQuad(const CCSharedQuadState*, const IntRect&, SkColor, int width); - - SkColor m_color; - int m_width; -}; - +typedef WebKit::WebCompositorDebugBorderQuad CCDebugBorderDrawQuad; } #endif diff --git a/Source/WebCore/platform/graphics/chromium/cc/CCDrawQuad.cpp b/Source/WebCore/platform/graphics/chromium/cc/CCDrawQuad.cpp deleted file mode 100644 index 601f5621d..000000000 --- a/Source/WebCore/platform/graphics/chromium/cc/CCDrawQuad.cpp +++ /dev/null @@ -1,123 +0,0 @@ -/* - * Copyright (C) 2011 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 "cc/CCDrawQuad.h" - -#include "cc/CCCheckerboardDrawQuad.h" -#include "cc/CCDebugBorderDrawQuad.h" -#include "cc/CCIOSurfaceDrawQuad.h" -#include "cc/CCRenderPassDrawQuad.h" -#include "cc/CCSolidColorDrawQuad.h" -#include "cc/CCStreamVideoDrawQuad.h" -#include "cc/CCTextureDrawQuad.h" -#include "cc/CCTileDrawQuad.h" -#include "cc/CCYUVVideoDrawQuad.h" - -namespace WebCore { - -CCDrawQuad::CCDrawQuad(const CCSharedQuadState* sharedQuadState, Material material, const IntRect& quadRect) - : m_sharedQuadState(sharedQuadState) - , m_material(material) - , m_quadRect(quadRect) - , m_quadVisibleRect(quadRect) - , m_quadOpaque(true) - , m_needsBlending(false) -{ - ASSERT(m_sharedQuadState); - ASSERT(m_material != Invalid); -} - -IntRect CCDrawQuad::opaqueRect() const -{ - if (opacity() != 1) - return IntRect(); - if (m_sharedQuadState->isOpaque() && m_quadOpaque) - return m_quadRect; - return m_opaqueRect; -} - -void CCDrawQuad::setQuadVisibleRect(const IntRect& quadVisibleRect) -{ - m_quadVisibleRect = quadVisibleRect; - m_quadVisibleRect.intersect(m_quadRect); -} - -const CCCheckerboardDrawQuad* CCDrawQuad::toCheckerboardDrawQuad() const -{ - ASSERT(m_material == Checkerboard); - return static_cast<const CCCheckerboardDrawQuad*>(this); -} - -const CCDebugBorderDrawQuad* CCDrawQuad::toDebugBorderDrawQuad() const -{ - ASSERT(m_material == DebugBorder); - return static_cast<const CCDebugBorderDrawQuad*>(this); -} - -const CCIOSurfaceDrawQuad* CCDrawQuad::toIOSurfaceDrawQuad() const -{ - ASSERT(m_material == IOSurfaceContent); - return static_cast<const CCIOSurfaceDrawQuad*>(this); -} - -const CCRenderPassDrawQuad* CCDrawQuad::toRenderPassDrawQuad() const -{ - ASSERT(m_material == RenderPass); - return static_cast<const CCRenderPassDrawQuad*>(this); -} - -const CCSolidColorDrawQuad* CCDrawQuad::toSolidColorDrawQuad() const -{ - ASSERT(m_material == SolidColor); - return static_cast<const CCSolidColorDrawQuad*>(this); -} - -const CCStreamVideoDrawQuad* CCDrawQuad::toStreamVideoDrawQuad() const -{ - ASSERT(m_material == StreamVideoContent); - return static_cast<const CCStreamVideoDrawQuad*>(this); -} - -const CCTextureDrawQuad* CCDrawQuad::toTextureDrawQuad() const -{ - ASSERT(m_material == TextureContent); - return static_cast<const CCTextureDrawQuad*>(this); -} -const CCTileDrawQuad* CCDrawQuad::toTileDrawQuad() const -{ - ASSERT(m_material == TiledContent); - return static_cast<const CCTileDrawQuad*>(this); -} - -const CCYUVVideoDrawQuad* CCDrawQuad::toYUVVideoDrawQuad() const -{ - ASSERT(m_material == YUVVideoContent); - return static_cast<const CCYUVVideoDrawQuad*>(this); -} - - -} diff --git a/Source/WebCore/platform/graphics/chromium/cc/CCDrawQuad.h b/Source/WebCore/platform/graphics/chromium/cc/CCDrawQuad.h index 756b68036..5f536a85a 100644 --- a/Source/WebCore/platform/graphics/chromium/cc/CCDrawQuad.h +++ b/Source/WebCore/platform/graphics/chromium/cc/CCDrawQuad.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2011 Google Inc. All rights reserved. + * Copyright (C) 2012 Google Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -26,91 +26,10 @@ #ifndef CCDrawQuad_h #define CCDrawQuad_h -#include "cc/CCSharedQuadState.h" +#include <public/WebCompositorQuad.h> namespace WebCore { - -class CCCheckerboardDrawQuad; -class CCDebugBorderDrawQuad; -class CCIOSurfaceDrawQuad; -class CCRenderPassDrawQuad; -class CCSolidColorDrawQuad; -class CCStreamVideoDrawQuad; -class CCTextureDrawQuad; -class CCTileDrawQuad; -class CCYUVVideoDrawQuad; - -// CCDrawQuad is a bag of data used for drawing a quad. Because different -// materials need different bits of per-quad data to render, classes that derive -// from CCDrawQuad store additional data in their derived instance. The Material -// enum is used to "safely" upcast to the derived class. -class CCDrawQuad { - WTF_MAKE_NONCOPYABLE(CCDrawQuad); -public: - const IntRect& quadRect() const { return m_quadRect; } - const WebKit::WebTransformationMatrix& quadTransform() const { return m_sharedQuadState->quadTransform(); } - const WebKit::WebTransformationMatrix& layerTransform() const { return m_sharedQuadState->layerTransform(); } - const IntRect& layerRect() const { return m_sharedQuadState->layerRect(); } - const IntRect& scissorRect() const { return m_sharedQuadState->scissorRect(); } - float opacity() const { return m_sharedQuadState->opacity(); } - // For the purposes of blending, what part of the contents of this quad are opaque? - IntRect opaqueRect() const; - bool needsBlending() const { return m_needsBlending || !opaqueRect().contains(m_quadVisibleRect); } - bool isLayerAxisAlignedIntRect() const { return m_sharedQuadState->isLayerAxisAlignedIntRect(); } - - // Allows changing the rect that gets drawn to make it smaller. Parameter passed - // in will be clipped to quadRect(). - void setQuadVisibleRect(const IntRect&); - const IntRect& quadVisibleRect() const { return m_quadVisibleRect; } - - enum Material { - Invalid, - Checkerboard, - DebugBorder, - IOSurfaceContent, - RenderPass, - TextureContent, - SolidColor, - TiledContent, - YUVVideoContent, - StreamVideoContent, - }; - - Material material() const { return m_material; } - bool isDebugQuad() const { return m_material == DebugBorder; } - - const CCCheckerboardDrawQuad* toCheckerboardDrawQuad() const; - const CCDebugBorderDrawQuad* toDebugBorderDrawQuad() const; - const CCIOSurfaceDrawQuad* toIOSurfaceDrawQuad() const; - const CCRenderPassDrawQuad* toRenderPassDrawQuad() const; - const CCSolidColorDrawQuad* toSolidColorDrawQuad() const; - const CCStreamVideoDrawQuad* toStreamVideoDrawQuad() const; - const CCTextureDrawQuad* toTextureDrawQuad() const; - const CCTileDrawQuad* toTileDrawQuad() const; - const CCYUVVideoDrawQuad* toYUVVideoDrawQuad() const; - - const CCSharedQuadState* sharedQuadState() const { return m_sharedQuadState; } - -protected: - CCDrawQuad(const CCSharedQuadState*, Material, const IntRect&); - - const CCSharedQuadState* m_sharedQuadState; - - Material m_material; - IntRect m_quadRect; - IntRect m_quadVisibleRect; - - // By default, the shared quad state determines whether or not this quad is - // opaque or needs blending. Derived classes can override with these - // variables. - bool m_quadOpaque; - bool m_needsBlending; - - // Be default, this rect is empty. It is used when the shared quad state and above - // variables determine that the quad is not fully opaque but may be partially opaque. - IntRect m_opaqueRect; -}; - +typedef WebKit::WebCompositorQuad CCDrawQuad; } #endif diff --git a/Source/WebCore/platform/graphics/chromium/cc/CCGraphicsContext.h b/Source/WebCore/platform/graphics/chromium/cc/CCGraphicsContext.h index 405885ffb..be8c8a557 100644 --- a/Source/WebCore/platform/graphics/chromium/cc/CCGraphicsContext.h +++ b/Source/WebCore/platform/graphics/chromium/cc/CCGraphicsContext.h @@ -48,6 +48,12 @@ public: WebKit::WebGraphicsContext3D* context3D() { return m_context3D.get(); } + void flush() + { + if (m_context3D) + m_context3D->flush(); + } + private: CCGraphicsContext() { } explicit CCGraphicsContext(PassOwnPtr<WebKit::WebGraphicsContext3D> context3D) diff --git a/Source/WebCore/platform/graphics/chromium/cc/CCHeadsUpDisplay.cpp b/Source/WebCore/platform/graphics/chromium/cc/CCHeadsUpDisplay.cpp index 731f770c0..be19983ef 100644 --- a/Source/WebCore/platform/graphics/chromium/cc/CCHeadsUpDisplay.cpp +++ b/Source/WebCore/platform/graphics/chromium/cc/CCHeadsUpDisplay.cpp @@ -31,7 +31,6 @@ #include "GraphicsContext3D.h" #include "LayerRendererChromium.h" #include "PlatformCanvas.h" -#include "TextureManager.h" #include "cc/CCDebugRectHistory.h" #include "cc/CCFrameRateCounter.h" #include "cc/CCLayerTreeHostImpl.h" diff --git a/Source/WebCore/platform/graphics/chromium/cc/CCIOSurfaceDrawQuad.cpp b/Source/WebCore/platform/graphics/chromium/cc/CCIOSurfaceDrawQuad.cpp deleted file mode 100644 index 2fdb4efcb..000000000 --- a/Source/WebCore/platform/graphics/chromium/cc/CCIOSurfaceDrawQuad.cpp +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (C) 2012 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 "cc/CCIOSurfaceDrawQuad.h" - -namespace WebCore { - -PassOwnPtr<CCIOSurfaceDrawQuad> CCIOSurfaceDrawQuad::create(const CCSharedQuadState* sharedQuadState, const IntRect& quadRect, const IntSize& ioSurfaceSize, unsigned ioSurfaceTextureId) -{ - return adoptPtr(new CCIOSurfaceDrawQuad(sharedQuadState, quadRect, ioSurfaceSize, ioSurfaceTextureId)); -} - -CCIOSurfaceDrawQuad::CCIOSurfaceDrawQuad(const CCSharedQuadState* sharedQuadState, const IntRect& quadRect, const IntSize& ioSurfaceSize, unsigned ioSurfaceTextureId) - : CCDrawQuad(sharedQuadState, CCDrawQuad::IOSurfaceContent, quadRect) - , m_ioSurfaceSize(ioSurfaceSize) - , m_ioSurfaceTextureId(ioSurfaceTextureId) -{ -} - -} diff --git a/Source/WebCore/platform/graphics/chromium/cc/CCIOSurfaceDrawQuad.h b/Source/WebCore/platform/graphics/chromium/cc/CCIOSurfaceDrawQuad.h index 27f863ee6..77d326cbd 100644 --- a/Source/WebCore/platform/graphics/chromium/cc/CCIOSurfaceDrawQuad.h +++ b/Source/WebCore/platform/graphics/chromium/cc/CCIOSurfaceDrawQuad.h @@ -26,26 +26,10 @@ #ifndef CCIOSurfaceDrawQuad_h #define CCIOSurfaceDrawQuad_h -#include "cc/CCDrawQuad.h" -#include <wtf/PassOwnPtr.h> +#include <public/WebCompositorIOSurfaceQuad.h> namespace WebCore { - -class CCIOSurfaceDrawQuad : public CCDrawQuad { - WTF_MAKE_NONCOPYABLE(CCIOSurfaceDrawQuad); -public: - static PassOwnPtr<CCIOSurfaceDrawQuad> create(const CCSharedQuadState*, const IntRect&, const IntSize& ioSurfaceSize, unsigned ioSurfaceTextureId); - - const IntSize& ioSurfaceSize() const { return m_ioSurfaceSize; } - unsigned ioSurfaceTextureId() const { return m_ioSurfaceTextureId; } - -private: - CCIOSurfaceDrawQuad(const CCSharedQuadState*, const IntRect&, const IntSize& ioSurfaceSize, unsigned ioSurfaceTextureId); - - IntSize m_ioSurfaceSize; - unsigned m_ioSurfaceTextureId; -}; - +typedef WebKit::WebCompositorIOSurfaceQuad CCIOSurfaceDrawQuad; } #endif diff --git a/Source/WebCore/platform/graphics/chromium/cc/CCLayerImpl.cpp b/Source/WebCore/platform/graphics/chromium/cc/CCLayerImpl.cpp index 44772156d..9a88376c2 100644 --- a/Source/WebCore/platform/graphics/chromium/cc/CCLayerImpl.cpp +++ b/Source/WebCore/platform/graphics/chromium/cc/CCLayerImpl.cpp @@ -147,7 +147,7 @@ bool CCLayerImpl::descendantDrawsContent() PassOwnPtr<CCSharedQuadState> CCLayerImpl::createSharedQuadState() const { - return CCSharedQuadState::create(quadTransform(), drawTransform(), visibleLayerRect(), m_scissorRect, drawOpacity(), opaque()); + return CCSharedQuadState::create(quadTransform(), m_visibleContentRect, m_scissorRect, m_drawOpacity, m_opaque); } void CCLayerImpl::willDraw(CCRenderer*, CCGraphicsContext*) @@ -172,8 +172,8 @@ void CCLayerImpl::appendDebugBorderQuad(CCQuadCuller& quadList, const CCSharedQu if (!hasDebugBorders()) return; - IntRect layerRect(IntPoint(), contentBounds()); - quadList.append(CCDebugBorderDrawQuad::create(sharedQuadState, layerRect, debugBorderColor(), debugBorderWidth())); + IntRect contentRect(IntPoint(), contentBounds()); + quadList.append(CCDebugBorderDrawQuad::create(sharedQuadState, contentRect, debugBorderColor(), debugBorderWidth())); } unsigned CCLayerImpl::contentsTextureId() const @@ -613,7 +613,7 @@ void CCLayerImpl::setDoubleSided(bool doubleSided) Region CCLayerImpl::visibleContentOpaqueRegion() const { if (opaque()) - return visibleLayerRect(); + return visibleContentRect(); return Region(); } diff --git a/Source/WebCore/platform/graphics/chromium/cc/CCLayerImpl.h b/Source/WebCore/platform/graphics/chromium/cc/CCLayerImpl.h index 00a351b22..2b9a49bd3 100644 --- a/Source/WebCore/platform/graphics/chromium/cc/CCLayerImpl.h +++ b/Source/WebCore/platform/graphics/chromium/cc/CCLayerImpl.h @@ -34,6 +34,7 @@ #include "cc/CCInputHandler.h" #include "cc/CCLayerAnimationController.h" #include "cc/CCRenderSurface.h" +#include "cc/CCSharedQuadState.h" #include <public/WebFilterOperations.h> #include <public/WebTransformationMatrix.h> #include <wtf/OwnPtr.h> @@ -48,7 +49,6 @@ class CCLayerSorter; class CCLayerTreeHostImpl; class CCQuadCuller; class CCRenderer; -class CCSharedQuadState; class LayerChromium; class CCLayerImpl : public CCLayerAnimationControllerClient { @@ -227,8 +227,8 @@ public: CCInputHandlerClient::ScrollStatus tryScroll(const IntPoint& viewportPoint, CCInputHandlerClient::ScrollInputType) const; - const IntRect& visibleLayerRect() const { return m_visibleLayerRect; } - void setVisibleLayerRect(const IntRect& visibleLayerRect) { m_visibleLayerRect = visibleLayerRect; } + const IntRect& visibleContentRect() const { return m_visibleContentRect; } + void setVisibleContentRect(const IntRect& visibleContentRect) { m_visibleContentRect = visibleContentRect; } bool doubleSided() const { return m_doubleSided; } void setDoubleSided(bool); @@ -332,7 +332,7 @@ private: bool m_layerSurfacePropertyChanged; // Uses layer's content space. - IntRect m_visibleLayerRect; + IntRect m_visibleContentRect; bool m_masksToBounds; bool m_opaque; float m_opacity; diff --git a/Source/WebCore/platform/graphics/chromium/cc/CCLayerTilingData.cpp b/Source/WebCore/platform/graphics/chromium/cc/CCLayerTilingData.cpp index 823a316a3..49d23366c 100644 --- a/Source/WebCore/platform/graphics/chromium/cc/CCLayerTilingData.cpp +++ b/Source/WebCore/platform/graphics/chromium/cc/CCLayerTilingData.cpp @@ -99,12 +99,12 @@ void CCLayerTilingData::reset() m_tiles.clear(); } -void CCLayerTilingData::layerRectToTileIndices(const IntRect& layerRect, int& left, int& top, int& right, int& bottom) const +void CCLayerTilingData::contentRectToTileIndices(const IntRect& contentRect, int& left, int& top, int& right, int& bottom) const { - left = m_tilingData.tileXIndexFromSrcCoord(layerRect.x()); - top = m_tilingData.tileYIndexFromSrcCoord(layerRect.y()); - right = m_tilingData.tileXIndexFromSrcCoord(layerRect.maxX() - 1); - bottom = m_tilingData.tileYIndexFromSrcCoord(layerRect.maxY() - 1); + left = m_tilingData.tileXIndexFromSrcCoord(contentRect.x()); + top = m_tilingData.tileYIndexFromSrcCoord(contentRect.y()); + right = m_tilingData.tileXIndexFromSrcCoord(contentRect.maxX() - 1); + bottom = m_tilingData.tileYIndexFromSrcCoord(contentRect.maxY() - 1); } IntRect CCLayerTilingData::tileRect(const Tile* tile) const @@ -114,21 +114,21 @@ IntRect CCLayerTilingData::tileRect(const Tile* tile) const return tileRect; } -Region CCLayerTilingData::opaqueRegionInLayerRect(const IntRect& layerRect) const +Region CCLayerTilingData::opaqueRegionInContentRect(const IntRect& contentRect) const { - if (layerRect.isEmpty()) + if (contentRect.isEmpty()) return Region(); Region opaqueRegion; int left, top, right, bottom; - layerRectToTileIndices(layerRect, left, top, right, bottom); + contentRectToTileIndices(contentRect, left, top, right, bottom); for (int j = top; j <= bottom; ++j) { for (int i = left; i <= right; ++i) { Tile* tile = tileAt(i, j); if (!tile) continue; - IntRect tileOpaqueRect = intersection(layerRect, tile->opaqueRect()); + IntRect tileOpaqueRect = intersection(contentRect, tile->opaqueRect()); opaqueRegion.unite(tileOpaqueRect); } } @@ -141,7 +141,7 @@ void CCLayerTilingData::setBounds(const IntSize& size) // Any tiles completely outside our new bounds are invalid and should be dropped. int left, top, right, bottom; - layerRectToTileIndices(IntRect(IntPoint(), size), left, top, right, bottom); + contentRectToTileIndices(IntRect(IntPoint(), size), left, top, right, bottom); Vector<TileMapKey> invalidTileKeys; for (TileMap::const_iterator it = m_tiles.begin(); it != m_tiles.end(); ++it) { if (it->first.first > right || it->first.second > bottom) diff --git a/Source/WebCore/platform/graphics/chromium/cc/CCLayerTilingData.h b/Source/WebCore/platform/graphics/chromium/cc/CCLayerTilingData.h index 081fe844e..25ff179ca 100644 --- a/Source/WebCore/platform/graphics/chromium/cc/CCLayerTilingData.h +++ b/Source/WebCore/platform/graphics/chromium/cc/CCLayerTilingData.h @@ -98,10 +98,10 @@ public: void setBounds(const IntSize&); IntSize bounds() const; - void layerRectToTileIndices(const IntRect&, int &left, int &top, int &right, int &bottom) const; + void contentRectToTileIndices(const IntRect&, int &left, int &top, int &right, int &bottom) const; IntRect tileRect(const Tile*) const; - Region opaqueRegionInLayerRect(const IntRect&) const; + Region opaqueRegionInContentRect(const IntRect&) const; void reset(); diff --git a/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHost.cpp b/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHost.cpp index 414b20526..da2cb32a0 100644 --- a/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHost.cpp +++ b/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHost.cpp @@ -27,7 +27,6 @@ #include "cc/CCLayerTreeHost.h" #include "LayerChromium.h" -#include "ManagedTexture.h" #include "Region.h" #include "TraceEvent.h" #include "TreeSynchronizer.h" @@ -153,6 +152,7 @@ void CCLayerTreeHost::initializeLayerRenderer() m_settings.maxPartialTextureUpdates = min(m_settings.maxPartialTextureUpdates, m_proxy->maxPartialTextureUpdates()); m_contentsTextureManager = CCPrioritizedTextureManager::create(0, m_proxy->layerRendererCapabilities().maxTextureSize); + m_surfaceMemoryPlaceholder = m_contentsTextureManager->createTexture(IntSize(), GraphicsContext3D::RGBA); m_layerRendererInitialized = true; @@ -490,8 +490,6 @@ void CCLayerTreeHost::updateLayers(LayerChromium* rootLayer, CCTextureUpdater& u // Reset partial texture update requests. m_partialTextureUpdateRequests = 0; - prioritizeTextures(updateList); - bool needMoreUpdates = paintLayerContents(updateList, updater); if (m_triggerIdleUpdates && needMoreUpdates) setNeedsCommit(); @@ -500,13 +498,20 @@ void CCLayerTreeHost::updateLayers(LayerChromium* rootLayer, CCTextureUpdater& u updateList[i]->clearRenderSurface(); } -void CCLayerTreeHost::prioritizeTextures(const LayerList& updateList) +void CCLayerTreeHost::setPrioritiesForSurfaces(size_t surfaceMemoryBytes) +{ + // Surfaces have a place holder for their memory since they are managed + // independantly but should still be tracked and reduce other memory usage. + m_surfaceMemoryPlaceholder->setTextureManager(m_contentsTextureManager.get()); + m_surfaceMemoryPlaceholder->setRequestPriority(CCPriorityCalculator::renderSurfacePriority()); + m_surfaceMemoryPlaceholder->setToSelfManagedMemoryPlaceholder(surfaceMemoryBytes); +} + +void CCLayerTreeHost::setPrioritiesForLayers(const LayerList& updateList) { // Use BackToFront since it's cheap and this isn't order-dependent. typedef CCLayerIterator<LayerChromium, Vector<RefPtr<LayerChromium> >, RenderSurfaceChromium, CCLayerIteratorActions::BackToFront> CCLayerIteratorType; - m_contentsTextureManager->clearPriorities(); - CCPriorityCalculator calculator; CCLayerIteratorType end = CCLayerIteratorType::end(&updateList); for (CCLayerIteratorType it = CCLayerIteratorType::begin(&updateList); it != end; ++it) { @@ -519,7 +524,25 @@ void CCLayerTreeHost::prioritizeTextures(const LayerList& updateList) it->replicaLayer()->maskLayer()->setTexturePriorities(calculator); } } +} + +void CCLayerTreeHost::prioritizeTextures(const LayerList& renderSurfaceLayerList, CCOverdrawMetrics& metrics) +{ + m_contentsTextureManager->clearPriorities(); + + size_t memoryForRenderSurfacesMetric = calculateMemoryForRenderSurfaces(renderSurfaceLayerList); + + setPrioritiesForLayers(renderSurfaceLayerList); + setPrioritiesForSurfaces(memoryForRenderSurfacesMetric); + metrics.didUseContentsTextureMemoryBytes(m_contentsTextureManager->memoryAboveCutoffBytes()); + metrics.didUseRenderSurfaceTextureMemoryBytes(memoryForRenderSurfacesMetric); + + m_contentsTextureManager->prioritizeTextures(); +} + +size_t CCLayerTreeHost::calculateMemoryForRenderSurfaces(const LayerList& updateList) +{ size_t readbackBytes = 0; size_t maxBackgroundTextureBytes = 0; size_t contentsTextureBytes = 0; @@ -529,7 +552,7 @@ void CCLayerTreeHost::prioritizeTextures(const LayerList& updateList) LayerChromium* renderSurfaceLayer = updateList[i].get(); RenderSurfaceChromium* renderSurface = renderSurfaceLayer->renderSurface(); - size_t bytes = TextureManager::memoryUseBytes(renderSurface->contentRect().size(), GraphicsContext3D::RGBA); + size_t bytes = CCTexture::memorySizeBytes(renderSurface->contentRect().size(), GraphicsContext3D::RGBA); contentsTextureBytes += bytes; if (renderSurface->backgroundFilters().isEmpty()) @@ -538,11 +561,9 @@ void CCLayerTreeHost::prioritizeTextures(const LayerList& updateList) if (bytes > maxBackgroundTextureBytes) maxBackgroundTextureBytes = bytes; if (!readbackBytes) - readbackBytes = TextureManager::memoryUseBytes(m_deviceViewportSize, GraphicsContext3D::RGBA); + readbackBytes = CCTexture::memorySizeBytes(m_deviceViewportSize, GraphicsContext3D::RGBA); } - size_t renderSurfacesBytes = readbackBytes + maxBackgroundTextureBytes + contentsTextureBytes; - - m_contentsTextureManager->prioritizeTextures(renderSurfacesBytes); + return readbackBytes + maxBackgroundTextureBytes + contentsTextureBytes; } bool CCLayerTreeHost::paintMasksForRenderSurface(LayerChromium* renderSurfaceLayer, CCTextureUpdater& updater) @@ -574,7 +595,9 @@ bool CCLayerTreeHost::paintLayerContents(const LayerList& renderSurfaceLayerList bool needMoreUpdates = false; bool recordMetricsForFrame = true; // FIXME: In the future, disable this when about:tracing is off. CCOcclusionTracker occlusionTracker(IntRect(IntPoint(), deviceViewportSize()), recordMetricsForFrame); - occlusionTracker.setMinimumTrackingSize(CCOcclusionTracker::preferredMinimumTrackingSize()); + occlusionTracker.setMinimumTrackingSize(m_settings.minimumOcclusionTrackingSize); + + prioritizeTextures(renderSurfaceLayerList, occlusionTracker.overdrawMetrics()); CCLayerIteratorType end = CCLayerIteratorType::end(&renderSurfaceLayerList); for (CCLayerIteratorType it = CCLayerIteratorType::begin(&renderSurfaceLayerList); it != end; ++it) { @@ -592,8 +615,6 @@ bool CCLayerTreeHost::paintLayerContents(const LayerList& renderSurfaceLayerList occlusionTracker.leaveLayer(it); } - occlusionTracker.overdrawMetrics().didUseContentsTextureMemoryBytes(m_contentsTextureManager->memoryAboveCutoffBytes()); - occlusionTracker.overdrawMetrics().didUseRenderSurfaceTextureMemoryBytes(m_contentsTextureManager->memoryForRenderSurfacesBytes()); occlusionTracker.overdrawMetrics().recordMetrics(this); return needMoreUpdates; diff --git a/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHost.h b/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHost.h index c2143eae5..bd65650f4 100644 --- a/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHost.h +++ b/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHost.h @@ -51,7 +51,6 @@ class CCLayerChromium; class CCLayerTreeHostImpl; class CCLayerTreeHostImplClient; class CCTextureUpdater; -class ManagedTexture; class Region; class TextureAllocator; class CCPrioritizedTextureManager; @@ -96,6 +95,7 @@ struct CCLayerTreeSettings { , maxPartialTextureUpdates(std::numeric_limits<size_t>::max()) , defaultTileSize(IntSize(256, 256)) , maxUntiledLayerSize(IntSize(512, 512)) + , minimumOcclusionTrackingSize(IntSize(160, 160)) { } bool acceleratePainting; @@ -112,6 +112,7 @@ struct CCLayerTreeSettings { size_t maxPartialTextureUpdates; IntSize defaultTileSize; IntSize maxUntiledLayerSize; + IntSize minimumOcclusionTrackingSize; }; // Provides information on an Impl's rendering capabilities back to the CCLayerTreeHost @@ -284,7 +285,10 @@ private: void updateLayers(LayerChromium*, CCTextureUpdater&); - void prioritizeTextures(const LayerList& updateList); + void prioritizeTextures(const LayerList&, CCOverdrawMetrics&); + void setPrioritiesForSurfaces(size_t surfaceMemoryBytes); + void setPrioritiesForLayers(const LayerList&); + size_t calculateMemoryForRenderSurfaces(const LayerList& updateList); void animateLayers(double monotonicTime); bool animateLayersRecursive(LayerChromium* current, double monotonicTime); @@ -308,6 +312,7 @@ private: RefPtr<LayerChromium> m_rootLayer; OwnPtr<CCPrioritizedTextureManager> m_contentsTextureManager; + OwnPtr<CCPrioritizedTexture> m_surfaceMemoryPlaceholder; CCLayerTreeSettings m_settings; diff --git a/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHostCommon.cpp b/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHostCommon.cpp index 51ae04802..1c677555a 100644 --- a/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHostCommon.cpp +++ b/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHostCommon.cpp @@ -153,7 +153,7 @@ static bool isSurfaceBackFaceVisible(LayerType* layer, const WebTransformationMa } template<typename LayerType> -static IntRect calculateVisibleLayerRect(LayerType* layer) +static IntRect calculateVisibleContentRect(LayerType* layer) { ASSERT(layer->targetRenderSurface()); @@ -176,8 +176,8 @@ static IntRect calculateVisibleLayerRect(LayerType* layer) bounds.height() / static_cast<double>(contentBounds.height())); transform.translate(-contentBounds.width() / 2.0, -contentBounds.height() / 2.0); - IntRect visibleLayerRect = CCLayerTreeHostCommon::calculateVisibleRect(targetSurfaceRect, layerBoundRect, transform); - return visibleLayerRect; + IntRect visibleContentRect = CCLayerTreeHostCommon::calculateVisibleRect(targetSurfaceRect, layerBoundRect, transform); + return visibleContentRect; } static bool isScaleOrTranslation(const WebTransformationMatrix& m) @@ -219,7 +219,7 @@ static bool layerShouldBeSkipped(LayerType* layer) // // Some additional conditions need to be computed at a later point after the recursion is finished. // - the intersection of render surface content and layer clipRect is empty - // - the visibleLayerRect is empty + // - the visibleContentRect is empty // // Note, if the layer should not have been drawn due to being fully transparent, // we would have skipped the entire subtree and never made it into this function, @@ -261,6 +261,11 @@ static inline bool subtreeShouldBeSkipped(LayerChromium* layer) template<typename LayerType> static bool subtreeShouldRenderToSeparateSurface(LayerType* layer, bool axisAlignedWithRespectToParent) { + // The root layer has a special render surface that is set up externally, so + // it shouldn't be treated as a surface in this code. + if (!layer->parent()) + return false; + // Cache this value, because otherwise it walks the entire subtree several times. bool descendantDrawsContent = layer->descendantDrawsContent(); @@ -833,7 +838,7 @@ static bool calculateDrawTransformsInternal(LayerType* layer, LayerType* rootLay } // FIXME: Instead of using the following function to set visibility rects on a second -// tree pass, revise calculateVisibleLayerRect() so that this can be done in a single +// tree pass, revise calculateVisibleContentRect() so that this can be done in a single // pass inside calculateDrawTransformsInternal<>(). template<typename LayerType, typename LayerList, typename RenderSurfaceType> static void calculateVisibleAndScissorRectsInternal(const LayerList& renderSurfaceLayerList, const FloatRect& rootScissorRect) @@ -846,13 +851,13 @@ static void calculateVisibleAndScissorRectsInternal(const LayerList& renderSurfa if (it.representsTargetRenderSurface()) { LayerType* maskLayer = it->maskLayer(); if (maskLayer) - maskLayer->setVisibleLayerRect(IntRect(IntPoint(), it->contentBounds())); + maskLayer->setVisibleContentRect(IntRect(IntPoint(), it->contentBounds())); LayerType* replicaMaskLayer = it->replicaLayer() ? it->replicaLayer()->maskLayer() : 0; if (replicaMaskLayer) - replicaMaskLayer->setVisibleLayerRect(IntRect(IntPoint(), it->contentBounds())); + replicaMaskLayer->setVisibleContentRect(IntRect(IntPoint(), it->contentBounds())); } else if (it.representsItself()) { - IntRect visibleLayerRect = calculateVisibleLayerRect(*it); - it->setVisibleLayerRect(visibleLayerRect); + IntRect visibleContentRect = calculateVisibleContentRect(*it); + it->setVisibleContentRect(visibleContentRect); IntRect scissorRect = calculateLayerScissorRect<LayerType, RenderSurfaceType>(*it, rootScissorRect); it->setScissorRect(scissorRect); diff --git a/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHostImpl.cpp b/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHostImpl.cpp index 26a09e70f..ada3c8e3b 100644 --- a/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHostImpl.cpp +++ b/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHostImpl.cpp @@ -42,6 +42,7 @@ #include "cc/CCLayerTreeHostCommon.h" #include "cc/CCOverdrawMetrics.h" #include "cc/CCPageScaleAnimation.h" +#include "cc/CCPrioritizedTextureManager.h" #include "cc/CCRenderPassDrawQuad.h" #include "cc/CCSettings.h" #include "cc/CCSingleThreadProxy.h" @@ -122,7 +123,7 @@ CCLayerTreeHostImpl::CCLayerTreeHostImpl(const CCLayerTreeSettings& settings, CC , m_deviceScaleFactor(1) , m_visible(true) , m_contentsTexturesWerePurgedSinceLastCommit(false) - , m_memoryAllocationLimitBytes(TextureManager::highLimitBytes(viewportSize())) + , m_memoryAllocationLimitBytes(CCPrioritizedTextureManager::defaultMemoryAllocationLimit()) , m_headsUpDisplay(CCHeadsUpDisplay::create()) , m_pageScale(1) , m_pageScaleDelta(1) @@ -295,17 +296,16 @@ bool CCLayerTreeHostImpl::calculateRenderPasses(FrameData& frame) CCLayerImpl* renderSurfaceLayer = (*frame.renderSurfaceLayerList)[surfaceIndex]; CCRenderSurface* renderSurface = renderSurfaceLayer->renderSurface(); - // FIXME: Make this unique across all CCLayerTreeHostImpls. - int globalRenderPassId = renderSurfaceLayer->id(); - - OwnPtr<CCRenderPass> pass = CCRenderPass::create(renderSurface, globalRenderPassId); + int renderPassId = renderSurfaceLayer->id(); + OwnPtr<CCRenderPass> pass = CCRenderPass::create(renderSurface, renderPassId); surfacePassMap.add(renderSurface, pass.get()); - frame.renderPasses.append(pass.release()); + frame.renderPasses.append(pass.get()); + frame.renderPassesById.add(renderPassId, pass.release()); } bool recordMetricsForFrame = true; // FIXME: In the future, disable this when about:tracing is off. CCOcclusionTrackerImpl occlusionTracker(enclosingIntRect(m_rootScissorRect), recordMetricsForFrame); - occlusionTracker.setMinimumTrackingSize(CCOcclusionTrackerImpl::preferredMinimumTrackingSize()); + occlusionTracker.setMinimumTrackingSize(m_settings.minimumOcclusionTrackingSize); if (settings().showOccludingRects) occlusionTracker.setOccludingScreenSpaceRectsContainer(&frame.occludingScreenSpaceRects); @@ -329,7 +329,7 @@ bool CCLayerTreeHostImpl::calculateRenderPasses(FrameData& frame) if (it.representsContributingRenderSurface() && !it->renderSurface()->scissorRect().isEmpty()) { CCRenderPass* contributingRenderPass = surfacePassMap.get(it->renderSurface()); pass->appendQuadsForRenderSurfaceLayer(*it, contributingRenderPass, &occlusionTracker); - } else if (it.representsItself() && !occlusionTracker.occluded(*it, it->visibleLayerRect()) && !it->visibleLayerRect().isEmpty() && !it->scissorRect().isEmpty()) { + } else if (it.representsItself() && !occlusionTracker.occluded(*it, it->visibleContentRect()) && !it->visibleContentRect().isEmpty() && !it->scissorRect().isEmpty()) { it->willDraw(m_layerRenderer.get(), context()); frame.willDrawLayers.append(*it); @@ -406,19 +406,26 @@ IntSize CCLayerTreeHostImpl::contentSize() const return m_rootScrollLayerImpl->children()[0]->contentBounds(); } -// static -void CCLayerTreeHostImpl::removeRenderPassesRecursive(CCRenderPassList& passes, size_t bottomPass, const CCRenderPass* firstToRemove, CCRenderPassList& skippedPasses) +static inline CCRenderPass* findRenderPassById(int renderPassId, const CCLayerTreeHostImpl::FrameData& frame) +{ + CCRenderPassIdHashMap::const_iterator it = frame.renderPassesById.find(renderPassId); + ASSERT(it != frame.renderPassesById.end()); + return it->second.get(); +} + +static void removeRenderPassesRecursive(int removeRenderPassId, CCLayerTreeHostImpl::FrameData& frame) { - size_t removeIndex = passes.find(firstToRemove); + CCRenderPass* removeRenderPass = findRenderPassById(removeRenderPassId, frame); + size_t removeIndex = frame.renderPasses.find(removeRenderPass); // The pass was already removed by another quad - probably the original, and we are the replica. if (removeIndex == notFound) return; - OwnPtr<CCRenderPass> removedPass = passes[removeIndex].release(); - passes.remove(removeIndex); + const CCRenderPass* removedPass = frame.renderPasses[removeIndex]; + frame.renderPasses.remove(removeIndex); - // Now follow up for all RenderPass quads and remove their render passes recursively. + // Now follow up for all RenderPass quads and remove their RenderPasses recursively. const CCQuadList& quadList = removedPass->quadList(); CCQuadList::constBackToFrontIterator quadListIterator = quadList.backToFrontBegin(); for (; quadListIterator != quadList.backToFrontEnd(); ++quadListIterator) { @@ -426,36 +433,32 @@ void CCLayerTreeHostImpl::removeRenderPassesRecursive(CCRenderPassList& passes, if (currentQuad->material() != CCDrawQuad::RenderPass) continue; - CCRenderPassDrawQuad* renderPassQuad = static_cast<CCRenderPassDrawQuad*>(currentQuad); - const CCRenderPass* nextRenderPass = renderPassQuad->renderPass(); - - // Our search is now limited up to the pass that we just removed. - // Substitute removeIndex for bottomPass now. - removeRenderPassesRecursive(passes, removeIndex, nextRenderPass, skippedPasses); + int nextRemoveRenderPassId = CCRenderPassDrawQuad::materialCast(currentQuad)->renderPassId(); + removeRenderPassesRecursive(nextRemoveRenderPassId, frame); } - skippedPasses.append(removedPass.release()); } -bool CCLayerTreeHostImpl::CullRenderPassesWithCachedTextures::shouldRemoveRenderPass(const CCRenderPassList&, const CCRenderPassDrawQuad& quad) const +bool CCLayerTreeHostImpl::CullRenderPassesWithCachedTextures::shouldRemoveRenderPass(const CCRenderPassDrawQuad& quad, const FrameData&) const { return quad.contentsChangedSinceLastFrame().isEmpty() && m_renderer.haveCachedResourcesForRenderPassId(quad.renderPassId()); } -bool CCLayerTreeHostImpl::CullRenderPassesWithNoQuads::shouldRemoveRenderPass(const CCRenderPassList& passList, const CCRenderPassDrawQuad& quad) const +bool CCLayerTreeHostImpl::CullRenderPassesWithNoQuads::shouldRemoveRenderPass(const CCRenderPassDrawQuad& quad, const FrameData& frame) const { - size_t passIndex = passList.find(quad.renderPass()); + const CCRenderPass* renderPass = findRenderPassById(quad.renderPassId(), frame); + size_t passIndex = frame.renderPasses.find(renderPass); ASSERT(passIndex != notFound); // If any quad or RenderPass draws into this RenderPass, then keep it. - const CCQuadList& quadList = passList[passIndex]->quadList(); + const CCQuadList& quadList = frame.renderPasses[passIndex]->quadList(); for (CCQuadList::constBackToFrontIterator quadListIterator = quadList.backToFrontBegin(); quadListIterator != quadList.backToFrontEnd(); ++quadListIterator) { CCDrawQuad* currentQuad = quadListIterator->get(); if (currentQuad->material() != CCDrawQuad::RenderPass) return false; - const CCRenderPassDrawQuad* quadInPass = static_cast<CCRenderPassDrawQuad*>(currentQuad); - if (passList.contains(quadInPass->renderPass())) + const CCRenderPass* contributingPass = findRenderPassById(CCRenderPassDrawQuad::materialCast(currentQuad)->renderPassId(), frame); + if (frame.renderPasses.contains(contributingPass)) return false; } return true; @@ -470,7 +473,7 @@ template<typename RenderPassCuller> void CCLayerTreeHostImpl::removeRenderPasses(RenderPassCuller culler, FrameData& frame) { for (size_t it = culler.renderPassListBegin(frame.renderPasses); it != culler.renderPassListEnd(frame.renderPasses); it = culler.renderPassListNext(it)) { - CCRenderPass* currentPass = frame.renderPasses[it].get(); + const CCRenderPass* currentPass = frame.renderPasses[it]; const CCQuadList& quadList = currentPass->quadList(); CCQuadList::constBackToFrontIterator quadListIterator = quadList.backToFrontBegin(); @@ -481,7 +484,7 @@ void CCLayerTreeHostImpl::removeRenderPasses(RenderPassCuller culler, FrameData& continue; CCRenderPassDrawQuad* renderPassQuad = static_cast<CCRenderPassDrawQuad*>(currentQuad); - if (!culler.shouldRemoveRenderPass(frame.renderPasses, *renderPassQuad)) + if (!culler.shouldRemoveRenderPass(*renderPassQuad, frame)) continue; // We are changing the vector in the middle of iteration. Because we @@ -490,7 +493,7 @@ void CCLayerTreeHostImpl::removeRenderPasses(RenderPassCuller culler, FrameData& // change. So, capture the iterator position from the end of the // list, and restore it after the change. int positionFromEnd = frame.renderPasses.size() - it; - removeRenderPassesRecursive(frame.renderPasses, it, renderPassQuad->renderPass(), frame.skippedPasses); + removeRenderPassesRecursive(renderPassQuad->renderPassId(), frame); it = frame.renderPasses.size() - positionFromEnd; ASSERT(it >= 0); } @@ -504,6 +507,7 @@ bool CCLayerTreeHostImpl::prepareToDraw(FrameData& frame) frame.renderSurfaceLayerList = &m_renderSurfaceLayerList; frame.renderPasses.clear(); + frame.renderPassesById.clear(); frame.renderSurfaceLayerList->clear(); frame.willDrawLayers.clear(); @@ -542,13 +546,13 @@ void CCLayerTreeHostImpl::drawLayers(const FrameData& frame) // RenderWidget. // The root RenderPass is the last one to be drawn. - CCRenderPass* rootRenderPass = frame.renderPasses.last().get(); + const CCRenderPass* rootRenderPass = frame.renderPasses.last(); m_fpsCounter->markBeginningOfFrame(currentTime()); m_layerRenderer->beginDrawingFrame(rootRenderPass); for (size_t i = 0; i < frame.renderPasses.size(); ++i) { - CCRenderPass* renderPass = frame.renderPasses[i].get(); + const CCRenderPass* renderPass = frame.renderPasses[i]; FloatRect rootScissorRectInCurrentSurface = renderPass->targetSurface()->computeRootScissorRectInCurrentSurface(m_rootScissorRect); m_layerRenderer->drawRenderPass(renderPass, rootScissorRectInCurrentSurface); diff --git a/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHostImpl.h b/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHostImpl.h index 49f2fc62b..753aa384a 100644 --- a/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHostImpl.h +++ b/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHostImpl.h @@ -85,7 +85,7 @@ public: struct FrameData { Vector<IntRect> occludingScreenSpaceRects; CCRenderPassList renderPasses; - CCRenderPassList skippedPasses; + CCRenderPassIdHashMap renderPassesById; CCLayerList* renderSurfaceLayerList; CCLayerList willDrawLayers; }; @@ -180,7 +180,7 @@ public: class CullRenderPassesWithCachedTextures { public: - bool shouldRemoveRenderPass(const CCRenderPassList&, const CCRenderPassDrawQuad&) const; + bool shouldRemoveRenderPass(const CCRenderPassDrawQuad&, const FrameData&) const; // Iterates from the root first, in order to remove the surfaces closest // to the root with cached textures, and all surfaces that draw into @@ -196,7 +196,7 @@ public: class CullRenderPassesWithNoQuads { public: - bool shouldRemoveRenderPass(const CCRenderPassList&, const CCRenderPassDrawQuad&) const; + bool shouldRemoveRenderPass(const CCRenderPassDrawQuad&, const FrameData&) const; // Iterates in draw order, so that when a surface is removed, and its // target becomes empty, then its target can be removed also. @@ -244,8 +244,6 @@ private: void setBackgroundTickingEnabled(bool); IntSize contentSize() const; - static void removeRenderPassesRecursive(CCRenderPassList& passes, size_t bottomPass, const CCRenderPass* firstToRemove, CCRenderPassList& skippedPasses); - void sendDidLoseContextRecursive(CCLayerImpl*); void clearRenderSurfaces(); bool ensureRenderSurfaceLayerList(); diff --git a/Source/WebCore/platform/graphics/chromium/cc/CCOcclusionTracker.cpp b/Source/WebCore/platform/graphics/chromium/cc/CCOcclusionTracker.cpp index b49ff9083..6124ddc9c 100644 --- a/Source/WebCore/platform/graphics/chromium/cc/CCOcclusionTracker.cpp +++ b/Source/WebCore/platform/graphics/chromium/cc/CCOcclusionTracker.cpp @@ -310,10 +310,10 @@ static inline WebTransformationMatrix contentToTargetSurfaceTransform(const Laye template<typename LayerType> static inline void addOcclusionBehindLayer(Region& region, const LayerType* layer, const WebTransformationMatrix& transform, const Region& opaqueContents, const IntRect& scissorRect, const IntSize& minimumTrackingSize, Vector<IntRect>* occludingScreenSpaceRects) { - ASSERT(layer->visibleLayerRect().contains(opaqueContents.bounds())); + ASSERT(layer->visibleContentRect().contains(opaqueContents.bounds())); bool clipped; - FloatQuad visibleTransformedQuad = CCMathUtil::mapQuad(transform, FloatQuad(layer->visibleLayerRect()), clipped); + FloatQuad visibleTransformedQuad = CCMathUtil::mapQuad(transform, FloatQuad(layer->visibleContentRect()), clipped); // FIXME: Find a rect interior to each transformed quad. if (clipped || !visibleTransformedQuad.isRectilinear()) return; diff --git a/Source/WebCore/platform/graphics/chromium/cc/CCOcclusionTracker.h b/Source/WebCore/platform/graphics/chromium/cc/CCOcclusionTracker.h index 027fab71d..0ca966d96 100644 --- a/Source/WebCore/platform/graphics/chromium/cc/CCOcclusionTracker.h +++ b/Source/WebCore/platform/graphics/chromium/cc/CCOcclusionTracker.h @@ -70,8 +70,6 @@ public: void setMinimumTrackingSize(const IntSize& size) { m_minimumTrackingSize = size; } - static IntSize preferredMinimumTrackingSize() { return IntSize(160, 160); } - // The following is used for visualization purposes. void setOccludingScreenSpaceRectsContainer(Vector<IntRect>* rects) { m_occludingScreenSpaceRects = rects; } diff --git a/Source/WebCore/platform/graphics/chromium/cc/CCPrioritizedTexture.cpp b/Source/WebCore/platform/graphics/chromium/cc/CCPrioritizedTexture.cpp index d8cc17485..1df771386 100644 --- a/Source/WebCore/platform/graphics/chromium/cc/CCPrioritizedTexture.cpp +++ b/Source/WebCore/platform/graphics/chromium/cc/CCPrioritizedTexture.cpp @@ -29,6 +29,7 @@ #include "CCPrioritizedTextureManager.h" #include "CCPriorityCalculator.h" #include "LayerRendererChromium.h" +#include "TextureAllocator.h" #include <algorithm> using namespace std; @@ -38,16 +39,17 @@ namespace WebCore { CCPrioritizedTexture::CCPrioritizedTexture(CCPrioritizedTextureManager* manager, IntSize size, GC3Denum format) : m_size(size) , m_format(format) - , m_memorySizeBytes(0) + , m_bytes(0) , m_priority(CCPriorityCalculator::lowestPriority()) , m_isAbovePriorityCutoff(false) - , m_currentBacking(0) + , m_isSelfManaged(false) + , m_backing(0) , m_manager(0) { // m_manager is set in registerTexture() so validity can be checked. ASSERT(format || size.isEmpty()); if (format) - m_memorySizeBytes = TextureManager::memoryUseBytes(size, format); + m_bytes = CCTexture::memorySizeBytes(size, format); if (manager) manager->registerTexture(this); } @@ -74,8 +76,8 @@ void CCPrioritizedTexture::setDimensions(IntSize size, GC3Denum format) m_isAbovePriorityCutoff = false; m_format = format; m_size = size; - m_memorySizeBytes = TextureManager::memoryUseBytes(size, format); - ASSERT(m_manager || !m_currentBacking); + m_bytes = CCTexture::memorySizeBytes(size, format); + ASSERT(m_manager || !m_backing); if (m_manager) m_manager->returnBackingTexture(this); } @@ -97,8 +99,8 @@ void CCPrioritizedTexture::acquireBackingTexture(TextureAllocator* allocator) unsigned CCPrioritizedTexture::textureId() { - if (m_currentBacking) - return m_currentBacking->textureId(); + if (m_backing) + return m_backing->id(); return 0; } @@ -107,7 +109,7 @@ void CCPrioritizedTexture::bindTexture(CCGraphicsContext* context, TextureAlloca ASSERT(m_isAbovePriorityCutoff); if (m_isAbovePriorityCutoff) acquireBackingTexture(allocator); - ASSERT(m_currentBacking); + ASSERT(m_backing); WebKit::WebGraphicsContext3D* context3d = context->context3D(); if (!context3d) { // FIXME: Implement this path for software compositing. @@ -121,7 +123,7 @@ void CCPrioritizedTexture::framebufferTexture2D(CCGraphicsContext* context, Text ASSERT(m_isAbovePriorityCutoff); if (m_isAbovePriorityCutoff) acquireBackingTexture(allocator); - ASSERT(m_currentBacking); + ASSERT(m_backing); WebKit::WebGraphicsContext3D* context3d = context->context3D(); if (!context3d) { // FIXME: Implement this path for software compositing. @@ -130,11 +132,30 @@ void CCPrioritizedTexture::framebufferTexture2D(CCGraphicsContext* context, Text context3d->framebufferTexture2D(GraphicsContext3D::FRAMEBUFFER, GraphicsContext3D::COLOR_ATTACHMENT0, GraphicsContext3D::TEXTURE_2D, textureId(), 0); } -void CCPrioritizedTexture::setCurrentBacking(CCPrioritizedTexture::Backing* backing) +void CCPrioritizedTexture::link(Backing* backing) { - if (m_currentBacking == backing) - return; - m_currentBacking = backing; + ASSERT(backing); + ASSERT(!backing->m_owner); + ASSERT(!m_backing); + + m_backing = backing; + m_backing->m_owner = this; +} + +void CCPrioritizedTexture::unlink() +{ + ASSERT(m_backing); + ASSERT(m_backing->m_owner == this); + + m_backing->m_owner = 0; + m_backing = 0; +} + +void CCPrioritizedTexture::setToSelfManagedMemoryPlaceholder(size_t bytes) +{ + setDimensions(IntSize(), GraphicsContext3D::RGBA); + setIsSelfManaged(true); + m_bytes = bytes; } } // namespace WebCore diff --git a/Source/WebCore/platform/graphics/chromium/cc/CCPrioritizedTexture.h b/Source/WebCore/platform/graphics/chromium/cc/CCPrioritizedTexture.h index 9ea2fb1e4..46073c5f3 100644 --- a/Source/WebCore/platform/graphics/chromium/cc/CCPrioritizedTexture.h +++ b/Source/WebCore/platform/graphics/chromium/cc/CCPrioritizedTexture.h @@ -26,16 +26,17 @@ #define CCPrioritizedTexture_h #include "CCPriorityCalculator.h" +#include "CCTexture.h" #include "GraphicsContext3D.h" #include "IntRect.h" #include "IntSize.h" -#include "TextureManager.h" namespace WebCore { class CCPrioritizedTextureManager; class CCPriorityCalculator; class CCGraphicsContext; +class TextureAllocator; class CCPrioritizedTexture { WTF_MAKE_NONCOPYABLE(CCPrioritizedTexture); @@ -57,7 +58,7 @@ public: void setDimensions(IntSize, GC3Denum format); GC3Denum format() const { return m_format; } IntSize size() const { return m_size; } - size_t memorySizeBytes() const { return m_memorySizeBytes; } + size_t bytes() const { return m_bytes; } // Set priority for the requested texture. void setRequestPriority(int priority) { m_priority = priority; } @@ -68,12 +69,12 @@ public: bool canAcquireBackingTexture() const { return m_isAbovePriorityCutoff; } // This returns whether we still have a backing texture. This can continue - // to be true even after canAquireBackingTexture() becomes false. In this + // to be true even after canAcquireBackingTexture() becomes false. In this // case the texture can be used but shouldn't be updated since it will get // taken away "soon". - bool haveBackingTexture() const { return !!currentBacking(); } + bool haveBackingTexture() const { return !!backing(); } - // If canAquireBackingTexture() is true acquireBackingTexture() will acquire + // If canAcquireBackingTexture() is true acquireBackingTexture() will acquire // a backing texture for use. Call this whenever the texture is actually needed. void acquireBackingTexture(TextureAllocator*); @@ -81,48 +82,39 @@ public: // (all textures are visible) but we can still squeeze into the limit // by not painting occluded textures. In this case the manager // refuses all visible textures and requestLate() will enable - // canAquireBackingTexture() on a call-order basis. We might want to + // canAcquireBackingTexture() on a call-order basis. We might want to // just remove this in the future (carefully) and just make sure we don't // regress OOMs situations. bool requestLate(); - // These functions will aquire the texture if possible. If neither haveBackingTexture() - // nor canAquireBackingTexture() is true, an ID of zero will be used/returned. + // These functions will acquire the texture if possible. If neither haveBackingTexture() + // nor canAcquireBackingTexture() is true, an ID of zero will be used/returned. void bindTexture(CCGraphicsContext*, TextureAllocator*); void framebufferTexture2D(CCGraphicsContext*, TextureAllocator*); unsigned textureId(); + // Self-managed textures are accounted for when prioritizing other textures, + // but they are not allocated/recycled/deleted, so this needs to be done + // externally. canAcquireBackingTexture() indicates if the texture would have + // been allowed given its priority. + void setIsSelfManaged(bool isSelfManaged) { m_isSelfManaged = isSelfManaged; } + bool isSelfManaged() { return m_isSelfManaged; } + void setToSelfManagedMemoryPlaceholder(size_t bytes); + private: friend class CCPrioritizedTextureManager; - class Backing { + class Backing : public CCTexture { WTF_MAKE_NONCOPYABLE(Backing); public: - IntSize size() const { return m_size; } - GC3Denum format() const { return m_format; } - size_t memorySizeBytes() const { return m_memorySizeBytes; } - unsigned textureId() const { return m_textureId; } - CCPrioritizedTexture* currentTexture() const { return m_currentTexture; } - void setCurrentTexture(CCPrioritizedTexture* current) { m_currentTexture = current; } + Backing(unsigned id, IntSize size, GC3Denum format) + : CCTexture(id, size, format), m_owner(0) { } + ~Backing() { ASSERT(!m_owner); } + CCPrioritizedTexture* owner() { return m_owner; } private: - friend class CCPrioritizedTextureManager; - - Backing(IntSize size, GC3Denum format, unsigned textureId) - : m_size(size) - , m_format(format) - , m_memorySizeBytes(TextureManager::memoryUseBytes(size, format)) - , m_textureId(textureId) - , m_priority(CCPriorityCalculator::lowestPriority()) - , m_currentTexture(0) { } - ~Backing() { ASSERT(!m_currentTexture); } - - IntSize m_size; - GC3Denum m_format; - size_t m_memorySizeBytes; - unsigned m_textureId; - int m_priority; - CCPrioritizedTexture* m_currentTexture; + friend class CCPrioritizedTexture; + CCPrioritizedTexture* m_owner; }; CCPrioritizedTexture(CCPrioritizedTextureManager*, IntSize, GC3Denum format); @@ -131,17 +123,19 @@ private: void setAbovePriorityCutoff(bool isAbovePriorityCutoff) { m_isAbovePriorityCutoff = isAbovePriorityCutoff; } void setManagerInternal(CCPrioritizedTextureManager* manager) { m_manager = manager; } - Backing* currentBacking() const { return m_currentBacking; } - void setCurrentBacking(Backing*); + Backing* backing() const { return m_backing; } + void link(Backing*); + void unlink(); IntSize m_size; GC3Denum m_format; - size_t m_memorySizeBytes; + size_t m_bytes; size_t m_priority; bool m_isAbovePriorityCutoff; + bool m_isSelfManaged; - Backing* m_currentBacking; + Backing* m_backing; CCPrioritizedTextureManager* m_manager; }; diff --git a/Source/WebCore/platform/graphics/chromium/cc/CCPrioritizedTextureManager.cpp b/Source/WebCore/platform/graphics/chromium/cc/CCPrioritizedTextureManager.cpp index 5af53df04..d19e5aa19 100644 --- a/Source/WebCore/platform/graphics/chromium/cc/CCPrioritizedTextureManager.cpp +++ b/Source/WebCore/platform/graphics/chromium/cc/CCPrioritizedTextureManager.cpp @@ -55,7 +55,7 @@ CCPrioritizedTextureManager::~CCPrioritizedTextureManager() destroyBacking(*m_backings.begin(), 0); } -void CCPrioritizedTextureManager::prioritizeTextures(size_t renderSurfacesMemoryBytes) +void CCPrioritizedTextureManager::prioritizeTextures() { TRACE_EVENT0("cc", "CCPrioritizedTextureManager::prioritizeTextures"); @@ -79,31 +79,29 @@ void CCPrioritizedTextureManager::prioritizeTextures(size_t renderSurfacesMemory m_memoryAvailableBytes = m_maxMemoryLimitBytes; m_priorityCutoff = CCPriorityCalculator::lowestPriority(); - bool reservedRenderSurfaces = false; size_t memoryBytes = 0; for (TextureVector::iterator it = sortedTextures.begin(); it != sortedTextures.end(); ++it) { if ((*it)->requestPriority() == CCPriorityCalculator::lowestPriority()) break; - // FIXME: We can make placeholder objects similar to textures to represent the render surface memory request. - if (!reservedRenderSurfaces && CCPriorityCalculator::priorityIsLower((*it)->requestPriority(), CCPriorityCalculator::renderSurfacePriority())) { - size_t newMemoryBytes = memoryBytes + renderSurfacesMemoryBytes; + if ((*it)->isSelfManaged()) { + // Account for self-managed memory immediately by reducing the memory + // available (since it never gets acquired). + size_t newMemoryBytes = memoryBytes + (*it)->bytes(); if (newMemoryBytes > m_memoryAvailableBytes) { m_priorityCutoff = (*it)->requestPriority(); m_memoryAvailableBytes = memoryBytes; break; } - m_memoryAvailableBytes -= renderSurfacesMemoryBytes; - reservedRenderSurfaces = true; - } - - size_t newMemoryBytes = memoryBytes + (*it)->memorySizeBytes(); - if (newMemoryBytes > m_memoryAvailableBytes) { - m_priorityCutoff = (*it)->requestPriority(); - break; + m_memoryAvailableBytes -= (*it)->bytes(); + } else { + size_t newMemoryBytes = memoryBytes + (*it)->bytes(); + if (newMemoryBytes > m_memoryAvailableBytes) { + m_priorityCutoff = (*it)->requestPriority(); + break; + } + memoryBytes = newMemoryBytes; } - - memoryBytes = newMemoryBytes; } // Only allow textures if they are higher than the cutoff. All textures @@ -113,8 +111,8 @@ void CCPrioritizedTextureManager::prioritizeTextures(size_t renderSurfacesMemory for (TextureVector::iterator it = sortedTextures.begin(); it != sortedTextures.end(); ++it) { bool isAbovePriorityCutoff = CCPriorityCalculator::priorityIsHigher((*it)->requestPriority(), m_priorityCutoff); (*it)->setAbovePriorityCutoff(isAbovePriorityCutoff); - if (isAbovePriorityCutoff) - m_memoryAboveCutoffBytes += (*it)->memorySizeBytes(); + if (isAbovePriorityCutoff && !(*it)->isSelfManaged()) + m_memoryAboveCutoffBytes += (*it)->bytes(); } ASSERT(m_memoryAboveCutoffBytes <= m_memoryAvailableBytes); @@ -157,23 +155,24 @@ bool CCPrioritizedTextureManager::requestLate(CCPrioritizedTexture* texture) if (CCPriorityCalculator::priorityIsLower(texture->requestPriority(), m_priorityCutoff)) return false; - size_t newMemoryBytes = m_memoryAboveCutoffBytes + texture->memorySizeBytes(); + size_t newMemoryBytes = m_memoryAboveCutoffBytes + texture->bytes(); if (newMemoryBytes > m_memoryAvailableBytes) return false; m_memoryAboveCutoffBytes = newMemoryBytes; texture->setAbovePriorityCutoff(true); - if (texture->currentBacking()) { - m_backings.remove(texture->currentBacking()); - m_backings.add(texture->currentBacking()); + if (texture->backing()) { + m_backings.remove(texture->backing()); + m_backings.add(texture->backing()); } return true; } void CCPrioritizedTextureManager::acquireBackingTextureIfNeeded(CCPrioritizedTexture* texture, TextureAllocator* allocator) { + ASSERT(!texture->isSelfManaged()); ASSERT(texture->isAbovePriorityCutoff()); - if (texture->currentBacking() || !texture->isAbovePriorityCutoff()) + if (texture->backing() || !texture->isAbovePriorityCutoff()) return; // Find a backing below, by either recycling or allocating. @@ -181,7 +180,7 @@ void CCPrioritizedTextureManager::acquireBackingTextureIfNeeded(CCPrioritizedTex // First try to recycle for (BackingSet::iterator it = m_backings.begin(); it != m_backings.end(); ++it) { - if ((*it)->currentTexture() && (*it)->currentTexture()->isAbovePriorityCutoff()) + if ((*it)->owner() && (*it)->owner()->isAbovePriorityCutoff()) break; if ((*it)->size() == texture->size() && (*it)->format() == texture->format()) { backing = (*it); @@ -191,14 +190,14 @@ void CCPrioritizedTextureManager::acquireBackingTextureIfNeeded(CCPrioritizedTex // Otherwise reduce memory and just allocate a new backing texures. if (!backing) { - reduceMemory(m_memoryAvailableBytes - texture->memorySizeBytes(), allocator); + reduceMemory(m_memoryAvailableBytes - texture->bytes(), allocator); backing = createBacking(texture->size(), texture->format(), allocator); } // Move the used backing texture to the end of the eviction list. - if (backing->currentTexture()) - unlink(backing->currentTexture(), backing); - link(texture, backing); + if (backing->owner()) + backing->owner()->unlink(); + texture->link(backing); m_backings.remove(backing); m_backings.add(backing); } @@ -211,7 +210,7 @@ void CCPrioritizedTextureManager::reduceMemory(size_t limitBytes, TextureAllocat // or until all backings remaining are above the cutoff. while (memoryUseBytes() > limitBytes && m_backings.size() > 0) { BackingSet::iterator it = m_backings.begin(); - if ((*it)->currentTexture() && (*it)->currentTexture()->isAbovePriorityCutoff()) + if ((*it)->owner() && (*it)->owner()->isAbovePriorityCutoff()) break; destroyBacking((*it), allocator); } @@ -229,9 +228,9 @@ void CCPrioritizedTextureManager::reduceMemory(TextureAllocator* allocator) // backing textures (any more than 10%). size_t wastedMemory = 0; for (BackingSet::iterator it = m_backings.begin(); it != m_backings.end(); ++it) { - if ((*it)->currentTexture()) + if ((*it)->owner()) break; - wastedMemory += (*it)->memorySizeBytes(); + wastedMemory += (*it)->bytes(); } size_t tenPercentOfMemory = m_memoryAvailableBytes / 10; if (wastedMemory <= tenPercentOfMemory) @@ -244,8 +243,8 @@ void CCPrioritizedTextureManager::clearAllMemory(TextureAllocator* allocator) // Unlink and destroy all backing textures. while (m_backings.size() > 0) { BackingSet::iterator it = m_backings.begin(); - if ((*it)->currentTexture()) - unlink((*it)->currentTexture(), (*it)); + if ((*it)->owner()) + (*it)->owner()->unlink(); destroyBacking((*it), allocator); } } @@ -258,32 +257,11 @@ void CCPrioritizedTextureManager::allBackingTexturesWereDeleted() clearAllMemory(0); } -void CCPrioritizedTextureManager::unlink(CCPrioritizedTexture* texture, CCPrioritizedTexture::Backing* backing) -{ - ASSERT(texture && backing); - ASSERT(texture->currentBacking() == backing); - ASSERT(backing->currentTexture() == texture); - - texture->setCurrentBacking(0); - backing->setCurrentTexture(0); -} - -void CCPrioritizedTextureManager::link(CCPrioritizedTexture* texture, CCPrioritizedTexture::Backing* backing) -{ - ASSERT(texture && backing); - ASSERT(!texture->currentBacking()); - ASSERT(!backing->currentTexture()); - - texture->setCurrentBacking(backing); - backing->setCurrentTexture(texture); -} - - void CCPrioritizedTextureManager::registerTexture(CCPrioritizedTexture* texture) { ASSERT(texture); ASSERT(!texture->textureManager()); - ASSERT(!texture->currentBacking()); + ASSERT(!texture->backing()); ASSERT(m_textures.find(texture) == m_textures.end()); texture->setManagerInternal(this); @@ -305,11 +283,11 @@ void CCPrioritizedTextureManager::unregisterTexture(CCPrioritizedTexture* textur void CCPrioritizedTextureManager::returnBackingTexture(CCPrioritizedTexture* texture) { - if (texture->currentBacking()) { + if (texture->backing()) { // Move the backing texture to the front for eviction/recycling and unlink it. - m_backings.remove(texture->currentBacking()); - m_backings.insertBefore(m_backings.begin(), texture->currentBacking()); - unlink(texture, texture->currentBacking()); + m_backings.remove(texture->backing()); + m_backings.insertBefore(m_backings.begin(), texture->backing()); + texture->unlink(); } } @@ -317,9 +295,8 @@ CCPrioritizedTexture::Backing* CCPrioritizedTextureManager::createBacking(IntSiz { ASSERT(allocator); - unsigned textureId = allocator->createTexture(size, format); - CCPrioritizedTexture::Backing* backing = new CCPrioritizedTexture::Backing(size, format, textureId); - m_memoryUseBytes += backing->memorySizeBytes(); + CCPrioritizedTexture::Backing* backing = new CCPrioritizedTexture::Backing(allocator->createTexture(size, format), size, format); + m_memoryUseBytes += backing->bytes(); // Put backing texture at the front for eviction, since it isn't in use yet. m_backings.insertBefore(m_backings.begin(), backing); return backing; @@ -328,14 +305,15 @@ CCPrioritizedTexture::Backing* CCPrioritizedTextureManager::createBacking(IntSiz void CCPrioritizedTextureManager::destroyBacking(CCPrioritizedTexture::Backing* backing, TextureAllocator* allocator) { ASSERT(backing); - ASSERT(!backing->currentTexture() || !backing->currentTexture()->isAbovePriorityCutoff()); + ASSERT(!backing->owner() || !backing->owner()->isAbovePriorityCutoff()); + ASSERT(!backing->owner() || !backing->owner()->isSelfManaged()); ASSERT(m_backings.find(backing) != m_backings.end()); if (allocator) - allocator->deleteTexture(backing->textureId(), backing->size(), backing->format()); - if (backing->currentTexture()) - unlink(backing->currentTexture(), backing); - m_memoryUseBytes -= backing->memorySizeBytes(); + allocator->deleteTexture(backing->id(), backing->size(), backing->format()); + if (backing->owner()) + backing->owner()->unlink(); + m_memoryUseBytes -= backing->bytes(); m_backings.remove(backing); delete backing; @@ -351,15 +329,15 @@ void CCPrioritizedTextureManager::assertInvariants() // Backings/textures must be doubly-linked and only to other backings/textures in this manager. for (BackingSet::iterator it = m_backings.begin(); it != m_backings.end(); ++it) { - if ((*it)->currentTexture()) { - ASSERT(m_textures.find((*it)->currentTexture()) != m_textures.end()); - ASSERT((*it)->currentTexture()->currentBacking() == (*it)); + if ((*it)->owner()) { + ASSERT(m_textures.find((*it)->owner()) != m_textures.end()); + ASSERT((*it)->owner()->backing() == (*it)); } } for (TextureSet::iterator it = m_textures.begin(); it != m_textures.end(); ++it) { - if ((*it)->currentBacking()) { - ASSERT(m_backings.find((*it)->currentBacking()) != m_backings.end()); - ASSERT((*it)->currentBacking()->currentTexture() == (*it)); + if ((*it)->backing()) { + ASSERT(m_backings.find((*it)->backing()) != m_backings.end()); + ASSERT((*it)->backing()->owner() == (*it)); } } @@ -368,10 +346,10 @@ void CCPrioritizedTextureManager::assertInvariants() // reduceMemory will not find all textures available for eviction/recycling). bool reachedProtected = false; for (BackingSet::iterator it = m_backings.begin(); it != m_backings.end(); ++it) { - if ((*it)->currentTexture() && (*it)->currentTexture()->isAbovePriorityCutoff()) + if ((*it)->owner() && (*it)->owner()->isAbovePriorityCutoff()) reachedProtected = true; if (reachedProtected) - ASSERT((*it)->currentTexture() && (*it)->currentTexture()->isAbovePriorityCutoff()); + ASSERT((*it)->owner() && (*it)->owner()->isAbovePriorityCutoff()); } } #endif diff --git a/Source/WebCore/platform/graphics/chromium/cc/CCPrioritizedTextureManager.h b/Source/WebCore/platform/graphics/chromium/cc/CCPrioritizedTextureManager.h index 3c70b2b2a..019c45cf4 100644 --- a/Source/WebCore/platform/graphics/chromium/cc/CCPrioritizedTextureManager.h +++ b/Source/WebCore/platform/graphics/chromium/cc/CCPrioritizedTextureManager.h @@ -27,10 +27,10 @@ #include "CCPrioritizedTexture.h" #include "CCPriorityCalculator.h" +#include "CCTexture.h" #include "GraphicsContext3D.h" #include "IntRect.h" #include "IntSize.h" -#include "TextureManager.h" namespace WebCore { @@ -50,18 +50,25 @@ public: } ~CCPrioritizedTextureManager(); + // FIXME (http://crbug.com/137094): This 64MB default is a straggler from the + // old texture manager and is just to give us a default memory allocation before + // we get a callback from the GPU memory manager. We should probaby either: + // - wait for the callback before rendering anything instead + // - push this into the GPU memory manager somehow. + static size_t defaultMemoryAllocationLimit() { return 64 * 1024 * 1024; } + // memoryUseBytes() describes the number of bytes used by existing allocated textures. // memoryAboveCutoffBytes() describes the number of bytes that would be used if all // textures that are above the cutoff were allocated. // memoryUseBytes() <= memoryAboveCutoffBytes() should always be true. size_t memoryUseBytes() const { return m_memoryUseBytes; } size_t memoryAboveCutoffBytes() const { return m_memoryAboveCutoffBytes; } - size_t memoryForRenderSurfacesBytes() const { return m_maxMemoryLimitBytes - m_memoryAvailableBytes; } + size_t memoryForSelfManagedTextures() const { return m_maxMemoryLimitBytes - m_memoryAvailableBytes; } void setMaxMemoryLimitBytes(size_t bytes) { m_maxMemoryLimitBytes = bytes; } size_t maxMemoryLimitBytes() const { return m_maxMemoryLimitBytes; } - void prioritizeTextures(size_t renderSurfacesMemoryBytes); + void prioritizeTextures(); void clearPriorities(); bool requestLate(CCPrioritizedTexture*); @@ -91,8 +98,8 @@ private: // Compare backings. Lowest priority first. static inline bool compareBackings(CCPrioritizedTexture::Backing* a, CCPrioritizedTexture::Backing* b) { - int priorityA = a->currentTexture() ? a->currentTexture()->requestPriority() : CCPriorityCalculator::lowestPriority(); - int priorityB = b->currentTexture() ? b->currentTexture()->requestPriority() : CCPriorityCalculator::lowestPriority(); + int priorityA = a->owner() ? a->owner()->requestPriority() : CCPriorityCalculator::lowestPriority(); + int priorityB = b->owner() ? b->owner()->requestPriority() : CCPriorityCalculator::lowestPriority(); if (priorityA == priorityB) return a < b; return CCPriorityCalculator::priorityIsLower(priorityA, priorityB); @@ -102,9 +109,6 @@ private: void reduceMemory(size_t limit, TextureAllocator*); - void link(CCPrioritizedTexture*, CCPrioritizedTexture::Backing*); - void unlink(CCPrioritizedTexture*, CCPrioritizedTexture::Backing*); - CCPrioritizedTexture::Backing* createBacking(IntSize, GC3Denum format, TextureAllocator*); void destroyBacking(CCPrioritizedTexture::Backing*, TextureAllocator*); diff --git a/Source/WebCore/platform/graphics/chromium/cc/CCPriorityCalculator.h b/Source/WebCore/platform/graphics/chromium/cc/CCPriorityCalculator.h index 68a225be0..a90a07390 100644 --- a/Source/WebCore/platform/graphics/chromium/cc/CCPriorityCalculator.h +++ b/Source/WebCore/platform/graphics/chromium/cc/CCPriorityCalculator.h @@ -28,7 +28,6 @@ #include "GraphicsContext3D.h" #include "IntRect.h" #include "IntSize.h" -#include "TextureManager.h" namespace WebCore { diff --git a/Source/WebCore/platform/graphics/chromium/cc/CCRenderPass.cpp b/Source/WebCore/platform/graphics/chromium/cc/CCRenderPass.cpp index 90a6ee60a..b11100af3 100644 --- a/Source/WebCore/platform/graphics/chromium/cc/CCRenderPass.cpp +++ b/Source/WebCore/platform/graphics/chromium/cc/CCRenderPass.cpp @@ -72,7 +72,7 @@ void CCRenderPass::appendQuadsForRenderSurfaceLayer(CCLayerImpl* layer, const CC OwnPtr<CCSharedQuadState> sharedQuadState = surface->createSharedQuadState(); bool isReplica = false; - surface->appendQuads(quadCuller, sharedQuadState.get(), isReplica, contributingRenderPass); + surface->appendQuads(quadCuller, sharedQuadState.get(), isReplica, contributingRenderPass->id()); m_sharedQuadStateList.append(sharedQuadState.release()); if (!surface->hasReplica()) @@ -81,7 +81,7 @@ void CCRenderPass::appendQuadsForRenderSurfaceLayer(CCLayerImpl* layer, const CC // Add replica after the surface so that it appears below the surface. OwnPtr<CCSharedQuadState> replicaSharedQuadState = surface->createReplicaSharedQuadState(); isReplica = true; - surface->appendQuads(quadCuller, replicaSharedQuadState.get(), isReplica, contributingRenderPass); + surface->appendQuads(quadCuller, replicaSharedQuadState.get(), isReplica, contributingRenderPass->id()); m_sharedQuadStateList.append(replicaSharedQuadState.release()); } diff --git a/Source/WebCore/platform/graphics/chromium/cc/CCRenderPass.h b/Source/WebCore/platform/graphics/chromium/cc/CCRenderPass.h index 47ae2f747..010a7674b 100644 --- a/Source/WebCore/platform/graphics/chromium/cc/CCRenderPass.h +++ b/Source/WebCore/platform/graphics/chromium/cc/CCRenderPass.h @@ -27,16 +27,17 @@ #define CCRenderPass_h #include "SkColor.h" +#include "cc/CCDrawQuad.h" #include "cc/CCOcclusionTracker.h" +#include "cc/CCSharedQuadState.h" +#include <wtf/HashMap.h> #include <wtf/PassOwnPtr.h> #include <wtf/Vector.h> namespace WebCore { -class CCDrawQuad; class CCLayerImpl; class CCRenderSurface; -class CCSharedQuadState; // A list of CCDrawQuad objects, sorted internally in front-to-back order. class CCQuadList : public Vector<OwnPtr<CCDrawQuad> > { @@ -81,7 +82,8 @@ protected: bool m_hasTransparentBackground; }; -typedef Vector<OwnPtr<CCRenderPass> > CCRenderPassList; +typedef Vector<CCRenderPass*> CCRenderPassList; +typedef HashMap<int, OwnPtr<CCRenderPass> > CCRenderPassIdHashMap; } diff --git a/Source/WebCore/platform/graphics/chromium/cc/CCRenderPassDrawQuad.cpp b/Source/WebCore/platform/graphics/chromium/cc/CCRenderPassDrawQuad.cpp index 75bd761d1..59abfbbcc 100644 --- a/Source/WebCore/platform/graphics/chromium/cc/CCRenderPassDrawQuad.cpp +++ b/Source/WebCore/platform/graphics/chromium/cc/CCRenderPassDrawQuad.cpp @@ -27,26 +27,32 @@ #include "cc/CCRenderPassDrawQuad.h" -#include "cc/CCRenderPass.h" +using WebKit::WebCompositorQuad; namespace WebCore { -PassOwnPtr<CCRenderPassDrawQuad> CCRenderPassDrawQuad::create(const CCSharedQuadState* sharedQuadState, const IntRect& quadRect, const CCRenderPass* renderPass, bool isReplica, const WebKit::WebFilterOperations& filters, const WebKit::WebFilterOperations& backgroundFilters, unsigned maskTextureId, const IntRect& contentsChangedSinceLastFrame) +PassOwnPtr<CCRenderPassDrawQuad> CCRenderPassDrawQuad::create(const WebKit::WebCompositorSharedQuadState* sharedQuadState, const IntRect& quadRect, int renderPassId, bool isReplica, const WebKit::WebTransformationMatrix& drawTransform, const WebKit::WebFilterOperations& filters, const WebKit::WebFilterOperations& backgroundFilters, unsigned maskTextureId, const IntRect& contentsChangedSinceLastFrame) { - return adoptPtr(new CCRenderPassDrawQuad(sharedQuadState, quadRect, renderPass, isReplica, filters, backgroundFilters, maskTextureId, contentsChangedSinceLastFrame)); + return adoptPtr(new CCRenderPassDrawQuad(sharedQuadState, quadRect, renderPassId, isReplica, drawTransform, filters, backgroundFilters, maskTextureId, contentsChangedSinceLastFrame)); } -CCRenderPassDrawQuad::CCRenderPassDrawQuad(const CCSharedQuadState* sharedQuadState, const IntRect& quadRect, const CCRenderPass* renderPass, bool isReplica, const WebKit::WebFilterOperations& filters, const WebKit::WebFilterOperations& backgroundFilters, unsigned maskTextureId, const IntRect& contentsChangedSinceLastFrame) - : CCDrawQuad(sharedQuadState, CCDrawQuad::RenderPass, quadRect) - , m_renderPass(renderPass) - , m_renderPassId(renderPass->id()) +CCRenderPassDrawQuad::CCRenderPassDrawQuad(const WebKit::WebCompositorSharedQuadState* sharedQuadState, const IntRect& quadRect, int renderPassId, bool isReplica, const WebKit::WebTransformationMatrix& drawTransform, const WebKit::WebFilterOperations& filters, const WebKit::WebFilterOperations& backgroundFilters, unsigned maskTextureId, const IntRect& contentsChangedSinceLastFrame) + : WebCompositorQuad(sharedQuadState, WebCompositorQuad::RenderPass, quadRect) + , m_renderPassId(renderPassId) , m_isReplica(isReplica) + , m_drawTransform(drawTransform) , m_filters(filters) , m_backgroundFilters(backgroundFilters) , m_maskTextureId(maskTextureId) , m_contentsChangedSinceLastFrame(contentsChangedSinceLastFrame) { - ASSERT(m_renderPass); + ASSERT(m_renderPassId > 0); +} + +const CCRenderPassDrawQuad* CCRenderPassDrawQuad::materialCast(const WebKit::WebCompositorQuad* quad) +{ + ASSERT(quad->material() == WebCompositorQuad::RenderPass); + return static_cast<const CCRenderPassDrawQuad*>(quad); } } diff --git a/Source/WebCore/platform/graphics/chromium/cc/CCRenderPassDrawQuad.h b/Source/WebCore/platform/graphics/chromium/cc/CCRenderPassDrawQuad.h index b63a76446..a12f204ca 100644 --- a/Source/WebCore/platform/graphics/chromium/cc/CCRenderPassDrawQuad.h +++ b/Source/WebCore/platform/graphics/chromium/cc/CCRenderPassDrawQuad.h @@ -26,34 +26,38 @@ #ifndef CCRenderPassDrawQuad_h #define CCRenderPassDrawQuad_h -#include "cc/CCDrawQuad.h" +#include <public/WebCompositorQuad.h> #include <public/WebFilterOperations.h> +#include <public/WebTransformationMatrix.h> #include <wtf/PassOwnPtr.h> namespace WebCore { class CCRenderPass; -class CCRenderPassDrawQuad : public CCDrawQuad { +class CCRenderPassDrawQuad : public WebKit::WebCompositorQuad { WTF_MAKE_NONCOPYABLE(CCRenderPassDrawQuad); public: - static PassOwnPtr<CCRenderPassDrawQuad> create(const CCSharedQuadState*, const IntRect&, const CCRenderPass*, bool isReplica, const WebKit::WebFilterOperations& filters, const WebKit::WebFilterOperations& backgroundFilters, unsigned maskTextureId, const IntRect& contentsChangedSinceLastFrame); + static PassOwnPtr<CCRenderPassDrawQuad> create(const WebKit::WebCompositorSharedQuadState*, const IntRect&, int renderPassId, bool isReplica, const WebKit::WebTransformationMatrix&, const WebKit::WebFilterOperations& filters, const WebKit::WebFilterOperations& backgroundFilters, unsigned maskTextureId, const IntRect& contentsChangedSinceLastFrame); - const CCRenderPass* renderPass() const { return m_renderPass; } int renderPassId() const { return m_renderPassId; } bool isReplica() const { return m_isReplica; } unsigned maskTextureId() const { return m_maskTextureId; } const IntRect& contentsChangedSinceLastFrame() const { return m_contentsChangedSinceLastFrame; } + // FIXME: This should be removed and we should draw the RenderPass with the quadTransform. + const WebKit::WebTransformationMatrix& drawTransform() const { return m_drawTransform; } + const WebKit::WebFilterOperations& filters() const { return m_filters; } const WebKit::WebFilterOperations& backgroundFilters() const { return m_backgroundFilters; } + static const CCRenderPassDrawQuad* materialCast(const WebKit::WebCompositorQuad*); private: - CCRenderPassDrawQuad(const CCSharedQuadState*, const IntRect&, const CCRenderPass*, bool isReplica, const WebKit::WebFilterOperations& filters, const WebKit::WebFilterOperations& backgroundFilters, unsigned maskTextureId, const IntRect& contentsChangedSinceLastFrame); + CCRenderPassDrawQuad(const WebKit::WebCompositorSharedQuadState*, const IntRect&, int renderPassId, bool isReplica, const WebKit::WebTransformationMatrix&, const WebKit::WebFilterOperations& filters, const WebKit::WebFilterOperations& backgroundFilters, unsigned maskTextureId, const IntRect& contentsChangedSinceLastFrame); - const CCRenderPass* m_renderPass; int m_renderPassId; bool m_isReplica; + WebKit::WebTransformationMatrix m_drawTransform; WebKit::WebFilterOperations m_filters; WebKit::WebFilterOperations m_backgroundFilters; unsigned m_maskTextureId; diff --git a/Source/WebCore/platform/graphics/chromium/cc/CCRenderSurface.cpp b/Source/WebCore/platform/graphics/chromium/cc/CCRenderSurface.cpp index d3a85d2da..8bd46bf00 100644 --- a/Source/WebCore/platform/graphics/chromium/cc/CCRenderSurface.cpp +++ b/Source/WebCore/platform/graphics/chromium/cc/CCRenderSurface.cpp @@ -188,13 +188,13 @@ bool CCRenderSurface::surfacePropertyChangedOnlyFromDescendant() const PassOwnPtr<CCSharedQuadState> CCRenderSurface::createSharedQuadState() const { bool isOpaque = false; - return CCSharedQuadState::create(originTransform(), drawTransform(), contentRect(), m_scissorRect, drawOpacity(), isOpaque); + return CCSharedQuadState::create(m_originTransform, m_contentRect, m_scissorRect, m_drawOpacity, isOpaque); } PassOwnPtr<CCSharedQuadState> CCRenderSurface::createReplicaSharedQuadState() const { bool isOpaque = false; - return CCSharedQuadState::create(replicaOriginTransform(), replicaDrawTransform(), contentRect(), m_scissorRect, drawOpacity(), isOpaque); + return CCSharedQuadState::create(m_replicaOriginTransform, m_contentRect, m_scissorRect, m_drawOpacity, isOpaque); } FloatRect CCRenderSurface::computeRootScissorRectInCurrentSurface(const FloatRect& rootScissorRect) const @@ -203,7 +203,7 @@ FloatRect CCRenderSurface::computeRootScissorRectInCurrentSurface(const FloatRec return CCMathUtil::projectClippedRect(inverseScreenSpaceTransform, rootScissorRect); } -void CCRenderSurface::appendQuads(CCQuadCuller& quadList, CCSharedQuadState* sharedQuadState, bool forReplica, const CCRenderPass* renderPass) +void CCRenderSurface::appendQuads(CCQuadCuller& quadList, CCSharedQuadState* sharedQuadState, bool forReplica, int renderPassId) { ASSERT(!forReplica || hasReplica()); @@ -232,9 +232,10 @@ void CCRenderSurface::appendQuads(CCQuadCuller& quadList, CCSharedQuadState* sha } int maskTextureId = maskLayer ? maskLayer->contentsTextureId() : 0; + WebTransformationMatrix drawTransform = forReplica ? m_replicaDrawTransform : m_drawTransform; IntRect contentsChangedSinceLastFrame = contentsChanged() ? m_contentRect : IntRect(); - quadList.appendSurface(CCRenderPassDrawQuad::create(sharedQuadState, contentRect(), renderPass, forReplica, filters(), backgroundFilters(), maskTextureId, contentsChangedSinceLastFrame)); + quadList.appendSurface(CCRenderPassDrawQuad::create(sharedQuadState, contentRect(), renderPassId, forReplica, drawTransform, filters(), backgroundFilters(), maskTextureId, contentsChangedSinceLastFrame)); } } diff --git a/Source/WebCore/platform/graphics/chromium/cc/CCRenderSurface.h b/Source/WebCore/platform/graphics/chromium/cc/CCRenderSurface.h index 894ea5aea..5410befed 100644 --- a/Source/WebCore/platform/graphics/chromium/cc/CCRenderSurface.h +++ b/Source/WebCore/platform/graphics/chromium/cc/CCRenderSurface.h @@ -31,6 +31,7 @@ #include "FloatRect.h" #include "IntRect.h" +#include "cc/CCSharedQuadState.h" #include <public/WebFilterOperations.h> #include <public/WebTransformationMatrix.h> #include <wtf/Noncopyable.h> @@ -41,7 +42,6 @@ namespace WebCore { class CCDamageTracker; class CCQuadCuller; class CCRenderPass; -class CCSharedQuadState; class CCLayerImpl; class LayerRendererChromium; class TextStream; @@ -130,7 +130,7 @@ public: PassOwnPtr<CCSharedQuadState> createSharedQuadState() const; PassOwnPtr<CCSharedQuadState> createReplicaSharedQuadState() const; - void appendQuads(CCQuadCuller&, CCSharedQuadState*, bool forReplica, const CCRenderPass*); + void appendQuads(CCQuadCuller&, CCSharedQuadState*, bool forReplica, int renderPassId); FloatRect computeRootScissorRectInCurrentSurface(const FloatRect& rootScissorRect) const; diff --git a/Source/WebCore/platform/graphics/chromium/cc/CCScopedTexture.cpp b/Source/WebCore/platform/graphics/chromium/cc/CCScopedTexture.cpp index 80f831541..b9f75d184 100644 --- a/Source/WebCore/platform/graphics/chromium/cc/CCScopedTexture.cpp +++ b/Source/WebCore/platform/graphics/chromium/cc/CCScopedTexture.cpp @@ -24,10 +24,9 @@ */ #include "config.h" - #include "cc/CCScopedTexture.h" -#include "TextureManager.h" // For TextureAllocator +#include "TextureAllocator.h" namespace WebCore { diff --git a/Source/WebCore/platform/graphics/chromium/cc/CCScopedTexture.h b/Source/WebCore/platform/graphics/chromium/cc/CCScopedTexture.h index 5a3c4e964..9f7241f51 100644 --- a/Source/WebCore/platform/graphics/chromium/cc/CCScopedTexture.h +++ b/Source/WebCore/platform/graphics/chromium/cc/CCScopedTexture.h @@ -26,6 +26,7 @@ #ifndef CCScopedTexture_h #define CCScopedTexture_h +#include "TextureAllocator.h" #include "cc/CCTexture.h" #if !ASSERT_DISABLED @@ -34,7 +35,6 @@ namespace WebCore { -class TextureAllocator; class CCScopedTexture : protected CCTexture { WTF_MAKE_NONCOPYABLE(CCScopedTexture); diff --git a/Source/WebCore/platform/graphics/chromium/cc/CCSharedQuadState.cpp b/Source/WebCore/platform/graphics/chromium/cc/CCSharedQuadState.cpp deleted file mode 100644 index 5e0681ff5..000000000 --- a/Source/WebCore/platform/graphics/chromium/cc/CCSharedQuadState.cpp +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright (C) 2011 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 "cc/CCSharedQuadState.h" - -#include "cc/CCMathUtil.h" - -using WebKit::WebTransformationMatrix; - -namespace WebCore { - -PassOwnPtr<CCSharedQuadState> CCSharedQuadState::create(const WebTransformationMatrix& quadTransform, const WebTransformationMatrix& layerTransform, const IntRect& layerRect, const IntRect& scissorRect, float opacity, bool opaque) -{ - return adoptPtr(new CCSharedQuadState(quadTransform, layerTransform, layerRect, scissorRect, opacity, opaque)); -} - -CCSharedQuadState::CCSharedQuadState(const WebTransformationMatrix& quadTransform, const WebTransformationMatrix& layerTransform, const IntRect& layerRect, const IntRect& scissorRect, float opacity, bool opaque) - : m_quadTransform(quadTransform) - , m_layerTransform(layerTransform) - , m_layerRect(layerRect) - , m_scissorRect(scissorRect) - , m_opacity(opacity) - , m_opaque(opaque) -{ -} - -bool CCSharedQuadState::isLayerAxisAlignedIntRect() const -{ - // Note: this doesn't consider window or projection matrices. - // Assume that they're orthonormal and have integer scales and translations. - bool clipped = false; - FloatQuad quad = CCMathUtil::mapQuad(quadTransform(), FloatQuad(layerRect()), clipped); - return !clipped && quad.isRectilinear() && quad.boundingBox().isExpressibleAsIntRect(); -} - -} diff --git a/Source/WebCore/platform/graphics/chromium/cc/CCSharedQuadState.h b/Source/WebCore/platform/graphics/chromium/cc/CCSharedQuadState.h index 4540a06f8..79036ddd4 100644 --- a/Source/WebCore/platform/graphics/chromium/cc/CCSharedQuadState.h +++ b/Source/WebCore/platform/graphics/chromium/cc/CCSharedQuadState.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2011 Google Inc. All rights reserved. + * Copyright (C) 2012 Google Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -26,40 +26,10 @@ #ifndef CCSharedQuadState_h #define CCSharedQuadState_h -#include "FloatQuad.h" -#include "IntRect.h" -#include <public/WebTransformationMatrix.h> -#include <wtf/PassOwnPtr.h> +#include <public/WebCompositorSharedQuadState.h> namespace WebCore { - -class CCSharedQuadState { - WTF_MAKE_NONCOPYABLE(CCSharedQuadState); -public: - static PassOwnPtr<CCSharedQuadState> create(const WebKit::WebTransformationMatrix& quadTransform, const WebKit::WebTransformationMatrix& layerTransform, const IntRect& layerRect, const IntRect& scissorRect, float opacity, bool opaque); - - // The transform that quads in a CCDrawQuad should be transformed with. - const WebKit::WebTransformationMatrix& quadTransform() const { return m_quadTransform; } - // The transform that layerRect() should be transformed with. - const WebKit::WebTransformationMatrix& layerTransform() const { return m_layerTransform; } - const IntRect& layerRect() const { return m_layerRect; } - const IntRect& scissorRect() const { return m_scissorRect; } - - float opacity() const { return m_opacity; } - bool isOpaque() const { return m_opaque; } - bool isLayerAxisAlignedIntRect() const; - -private: - CCSharedQuadState(const WebKit::WebTransformationMatrix& quadTransform, const WebKit::WebTransformationMatrix& layerTransform, const IntRect& layerRect, const IntRect& scissorRect, float opacity, bool opaque); - - WebKit::WebTransformationMatrix m_quadTransform; - WebKit::WebTransformationMatrix m_layerTransform; - IntRect m_layerRect; - IntRect m_scissorRect; - float m_opacity; - bool m_opaque; -}; - +typedef WebKit::WebCompositorSharedQuadState CCSharedQuadState; } #endif diff --git a/Source/WebCore/platform/graphics/chromium/cc/CCSolidColorDrawQuad.cpp b/Source/WebCore/platform/graphics/chromium/cc/CCSolidColorDrawQuad.cpp deleted file mode 100644 index 8668369b6..000000000 --- a/Source/WebCore/platform/graphics/chromium/cc/CCSolidColorDrawQuad.cpp +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright (C) 2011 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 "cc/CCSolidColorDrawQuad.h" - -namespace WebCore { - -PassOwnPtr<CCSolidColorDrawQuad> CCSolidColorDrawQuad::create(const CCSharedQuadState* sharedQuadState, const IntRect& quadRect, SkColor color) -{ - return adoptPtr(new CCSolidColorDrawQuad(sharedQuadState, quadRect, color)); -} - -CCSolidColorDrawQuad::CCSolidColorDrawQuad(const CCSharedQuadState* sharedQuadState, const IntRect& quadRect, SkColor color) - : CCDrawQuad(sharedQuadState, CCDrawQuad::SolidColor, quadRect) - , m_color(color) -{ - if (SkColorGetA(m_color) < 255) - m_quadOpaque = false; - else - m_opaqueRect = quadRect; -} - -} diff --git a/Source/WebCore/platform/graphics/chromium/cc/CCSolidColorDrawQuad.h b/Source/WebCore/platform/graphics/chromium/cc/CCSolidColorDrawQuad.h index 83ea34066..b6c0ee025 100644 --- a/Source/WebCore/platform/graphics/chromium/cc/CCSolidColorDrawQuad.h +++ b/Source/WebCore/platform/graphics/chromium/cc/CCSolidColorDrawQuad.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2011 Google Inc. All rights reserved. + * Copyright (C) 2012 Google Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -26,25 +26,10 @@ #ifndef CCSolidColorDrawQuad_h #define CCSolidColorDrawQuad_h -#include "SkColor.h" -#include "cc/CCDrawQuad.h" -#include <wtf/PassOwnPtr.h> +#include <public/WebCompositorSolidColorQuad.h> namespace WebCore { - -class CCSolidColorDrawQuad : public CCDrawQuad { - WTF_MAKE_NONCOPYABLE(CCSolidColorDrawQuad); -public: - static PassOwnPtr<CCSolidColorDrawQuad> create(const CCSharedQuadState*, const IntRect&, SkColor); - - SkColor color() const { return m_color; }; - -private: - CCSolidColorDrawQuad(const CCSharedQuadState*, const IntRect&, SkColor); - - SkColor m_color; -}; - +typedef WebKit::WebCompositorSolidColorQuad CCSolidColorDrawQuad; } #endif diff --git a/Source/WebCore/platform/graphics/chromium/cc/CCStreamVideoDrawQuad.cpp b/Source/WebCore/platform/graphics/chromium/cc/CCStreamVideoDrawQuad.cpp deleted file mode 100644 index 6a1ba2992..000000000 --- a/Source/WebCore/platform/graphics/chromium/cc/CCStreamVideoDrawQuad.cpp +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (C) 2012 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 "cc/CCStreamVideoDrawQuad.h" - -namespace WebCore { - -PassOwnPtr<CCStreamVideoDrawQuad> CCStreamVideoDrawQuad::create(const CCSharedQuadState* sharedQuadState, const IntRect& quadRect, unsigned textureId, const WebKit::WebTransformationMatrix& matrix) -{ - return adoptPtr(new CCStreamVideoDrawQuad(sharedQuadState, quadRect, textureId, matrix)); -} - -CCStreamVideoDrawQuad::CCStreamVideoDrawQuad(const CCSharedQuadState* sharedQuadState, const IntRect& quadRect, unsigned textureId, const WebKit::WebTransformationMatrix& matrix) - : CCDrawQuad(sharedQuadState, CCDrawQuad::StreamVideoContent, quadRect) - , m_textureId(textureId) - , m_matrix(matrix) -{ -} - -} diff --git a/Source/WebCore/platform/graphics/chromium/cc/CCStreamVideoDrawQuad.h b/Source/WebCore/platform/graphics/chromium/cc/CCStreamVideoDrawQuad.h index 3037348d3..a1890611a 100644 --- a/Source/WebCore/platform/graphics/chromium/cc/CCStreamVideoDrawQuad.h +++ b/Source/WebCore/platform/graphics/chromium/cc/CCStreamVideoDrawQuad.h @@ -26,27 +26,10 @@ #ifndef CCStreamVideoDrawQuad_h #define CCStreamVideoDrawQuad_h -#include "cc/CCDrawQuad.h" -#include <public/WebTransformationMatrix.h> -#include <wtf/PassOwnPtr.h> +#include <public/WebCompositorStreamVideoQuad.h> namespace WebCore { - -class CCStreamVideoDrawQuad : public CCDrawQuad { - WTF_MAKE_NONCOPYABLE(CCStreamVideoDrawQuad); -public: - static PassOwnPtr<CCStreamVideoDrawQuad> create(const CCSharedQuadState*, const IntRect&, unsigned textureId, const WebKit::WebTransformationMatrix&); - - unsigned textureId() const { return m_textureId; } - const WebKit::WebTransformationMatrix& matrix() const { return m_matrix; } - -private: - CCStreamVideoDrawQuad(const CCSharedQuadState*, const IntRect&, unsigned textureId, const WebKit::WebTransformationMatrix&); - - unsigned m_textureId; - WebKit::WebTransformationMatrix m_matrix; -}; - +typedef WebKit::WebCompositorStreamVideoQuad CCStreamVideoDrawQuad; } #endif diff --git a/Source/WebCore/platform/graphics/chromium/cc/CCTexture.h b/Source/WebCore/platform/graphics/chromium/cc/CCTexture.h index a29610469..0d5d9f768 100644 --- a/Source/WebCore/platform/graphics/chromium/cc/CCTexture.h +++ b/Source/WebCore/platform/graphics/chromium/cc/CCTexture.h @@ -35,6 +35,10 @@ namespace WebCore { class CCTexture { public: CCTexture() : m_id(0) { } + CCTexture(unsigned id, IntSize size, GC3Denum format) + : m_id(id) + , m_size(size) + , m_format(format) { } unsigned id() const { return m_id; } const IntSize& size() const { return m_size; } diff --git a/Source/WebCore/platform/graphics/chromium/cc/CCTextureDrawQuad.cpp b/Source/WebCore/platform/graphics/chromium/cc/CCTextureDrawQuad.cpp deleted file mode 100644 index bdbca95fb..000000000 --- a/Source/WebCore/platform/graphics/chromium/cc/CCTextureDrawQuad.cpp +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (C) 2012 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 "cc/CCTextureDrawQuad.h" - -namespace WebCore { - -PassOwnPtr<CCTextureDrawQuad> CCTextureDrawQuad::create(const CCSharedQuadState* sharedQuadState, const IntRect& quadRect, unsigned textureId, bool premultipliedAlpha, const FloatRect& uvRect, bool flipped) -{ - return adoptPtr(new CCTextureDrawQuad(sharedQuadState, quadRect, textureId, premultipliedAlpha, uvRect, flipped)); -} - -CCTextureDrawQuad::CCTextureDrawQuad(const CCSharedQuadState* sharedQuadState, const IntRect& quadRect, unsigned textureId, bool premultipliedAlpha, const FloatRect& uvRect, bool flipped) - : CCDrawQuad(sharedQuadState, CCDrawQuad::TextureContent, quadRect) - , m_textureId(textureId) - , m_premultipliedAlpha(premultipliedAlpha) - , m_uvRect(uvRect) - , m_flipped(flipped) -{ -} - -void CCTextureDrawQuad::setNeedsBlending() -{ - m_needsBlending = true; -} - -} diff --git a/Source/WebCore/platform/graphics/chromium/cc/CCTextureDrawQuad.h b/Source/WebCore/platform/graphics/chromium/cc/CCTextureDrawQuad.h index a4baefa13..28c3d9132 100644 --- a/Source/WebCore/platform/graphics/chromium/cc/CCTextureDrawQuad.h +++ b/Source/WebCore/platform/graphics/chromium/cc/CCTextureDrawQuad.h @@ -26,32 +26,10 @@ #ifndef CCTextureDrawQuad_h #define CCTextureDrawQuad_h -#include "cc/CCDrawQuad.h" -#include <wtf/PassOwnPtr.h> +#include <public/WebCompositorTextureQuad.h> namespace WebCore { - -class CCTextureDrawQuad : public CCDrawQuad { - WTF_MAKE_NONCOPYABLE(CCTextureDrawQuad); -public: - static PassOwnPtr<CCTextureDrawQuad> create(const CCSharedQuadState*, const IntRect&, unsigned textureId, bool premultipliedAlpha, const FloatRect& uvRect, bool flipped); - - unsigned textureId() const { return m_textureId; } - bool premultipliedAlpha() const { return m_premultipliedAlpha; } - FloatRect uvRect() const { return m_uvRect; } - bool flipped() const { return m_flipped; } - - void setNeedsBlending(); - -private: - CCTextureDrawQuad(const CCSharedQuadState*, const IntRect&, unsigned texture_id, bool premultipliedAlpha, const FloatRect& uvRect, bool flipped); - - unsigned m_textureId; - bool m_premultipliedAlpha; - FloatRect m_uvRect; - bool m_flipped; -}; - +typedef WebKit::WebCompositorTextureQuad CCTextureDrawQuad; } #endif diff --git a/Source/WebCore/platform/graphics/chromium/cc/CCTextureUpdater.cpp b/Source/WebCore/platform/graphics/chromium/cc/CCTextureUpdater.cpp index 3190d82ff..bc1ed75af 100644 --- a/Source/WebCore/platform/graphics/chromium/cc/CCTextureUpdater.cpp +++ b/Source/WebCore/platform/graphics/chromium/cc/CCTextureUpdater.cpp @@ -39,6 +39,8 @@ using namespace std; namespace WebCore { +static const int kUploadFlushPeriod = 4; + CCTextureUpdater::CCTextureUpdater() : m_entryIndex(0) { @@ -93,12 +95,20 @@ void CCTextureUpdater::update(CCGraphicsContext* context, TextureAllocator* allo uploader->beginUploads(); + int fullUploadCount = 0; size_t maxIndex = min(m_entryIndex + count, m_fullEntries.size()); for (index = m_entryIndex; index < maxIndex; ++index) { UpdateEntry& entry = m_fullEntries[index]; uploader->uploadTexture(context, entry.texture, allocator, entry.sourceRect, entry.destRect); + fullUploadCount++; + if (!(fullUploadCount % kUploadFlushPeriod)) + context->flush(); } + // Make sure there are no dangling uploads without a flush. + if (fullUploadCount % kUploadFlushPeriod) + context->flush(); + bool moreUploads = maxIndex < m_fullEntries.size(); ASSERT(m_partialEntries.size() <= count); @@ -116,8 +126,16 @@ void CCTextureUpdater::update(CCGraphicsContext* context, TextureAllocator* allo for (index = 0; index < m_partialEntries.size(); ++index) { UpdateEntry& entry = m_partialEntries[index]; uploader->uploadTexture(context, entry.texture, allocator, entry.sourceRect, entry.destRect); + if (!((index+1) % kUploadFlushPeriod)) + context->flush(); } + // Make sure there are no dangling partial uploads without a flush. + // Note: We don't need to use (index+1) in this case because index was + // incremented at the end of the for loop. + if (index % kUploadFlushPeriod) + context->flush(); + uploader->endUploads(); } diff --git a/Source/WebCore/platform/graphics/chromium/cc/CCTileDrawQuad.cpp b/Source/WebCore/platform/graphics/chromium/cc/CCTileDrawQuad.cpp deleted file mode 100644 index b35b6f69f..000000000 --- a/Source/WebCore/platform/graphics/chromium/cc/CCTileDrawQuad.cpp +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright (C) 2011 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 "cc/CCTileDrawQuad.h" - -namespace WebCore { - -PassOwnPtr<CCTileDrawQuad> CCTileDrawQuad::create(const CCSharedQuadState* sharedQuadState, const IntRect& quadRect, const IntRect& opaqueRect, Platform3DObject textureId, const IntPoint& textureOffset, const IntSize& textureSize, GC3Dint textureFilter, bool swizzleContents, bool leftEdgeAA, bool topEdgeAA, bool rightEdgeAA, bool bottomEdgeAA) -{ - return adoptPtr(new CCTileDrawQuad(sharedQuadState, quadRect, opaqueRect, textureId, textureOffset, textureSize, textureFilter, swizzleContents, leftEdgeAA, topEdgeAA, rightEdgeAA, bottomEdgeAA)); -} - -CCTileDrawQuad::CCTileDrawQuad(const CCSharedQuadState* sharedQuadState, const IntRect& quadRect, const IntRect& opaqueRect, Platform3DObject textureId, const IntPoint& textureOffset, const IntSize& textureSize, GC3Dint textureFilter, bool swizzleContents, bool leftEdgeAA, bool topEdgeAA, bool rightEdgeAA, bool bottomEdgeAA) - : CCDrawQuad(sharedQuadState, CCDrawQuad::TiledContent, quadRect) - , m_textureId(textureId) - , m_textureOffset(textureOffset) - , m_textureSize(textureSize) - , m_textureFilter(textureFilter) - , m_swizzleContents(swizzleContents) - , m_leftEdgeAA(leftEdgeAA) - , m_topEdgeAA(topEdgeAA) - , m_rightEdgeAA(rightEdgeAA) - , m_bottomEdgeAA(bottomEdgeAA) -{ - if (isAntialiased()) - m_needsBlending = true; - m_opaqueRect = opaqueRect; -} - -} diff --git a/Source/WebCore/platform/graphics/chromium/cc/CCTileDrawQuad.h b/Source/WebCore/platform/graphics/chromium/cc/CCTileDrawQuad.h index 33501a806..d530f4a48 100644 --- a/Source/WebCore/platform/graphics/chromium/cc/CCTileDrawQuad.h +++ b/Source/WebCore/platform/graphics/chromium/cc/CCTileDrawQuad.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2011 Google Inc. All rights reserved. + * Copyright (C) 2012 Google Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -26,44 +26,10 @@ #ifndef CCTileDrawQuad_h #define CCTileDrawQuad_h -#include "GraphicsTypes3D.h" -#include "cc/CCDrawQuad.h" -#include <wtf/PassOwnPtr.h> +#include <public/WebCompositorTileQuad.h> namespace WebCore { - -class CCTileDrawQuad : public CCDrawQuad { - WTF_MAKE_NONCOPYABLE(CCTileDrawQuad); -public: - static PassOwnPtr<CCTileDrawQuad> create(const CCSharedQuadState*, const IntRect& quadRect, const IntRect& opaqueRect, Platform3DObject textureId, const IntPoint& textureOffset, const IntSize& textureSize, GC3Dint textureFilter, bool swizzleContents, bool leftEdgeAA, bool topEdgeAA, bool rightEdgeAA, bool bottomEdgeAA); - - Platform3DObject textureId() const { return m_textureId; } - IntPoint textureOffset() const { return m_textureOffset; } - IntSize textureSize() const { return m_textureSize; } - GC3Dint textureFilter() const { return m_textureFilter; } - bool swizzleContents() const { return m_swizzleContents; } - - bool leftEdgeAA() const { return m_leftEdgeAA; } - bool topEdgeAA() const { return m_topEdgeAA; } - bool rightEdgeAA() const { return m_rightEdgeAA; } - bool bottomEdgeAA() const { return m_bottomEdgeAA; } - - bool isAntialiased() const { return leftEdgeAA() || topEdgeAA() || rightEdgeAA() || bottomEdgeAA(); } - -private: - CCTileDrawQuad(const CCSharedQuadState*, const IntRect& quadRect, const IntRect& opaqueRect, Platform3DObject textureId, const IntPoint& textureOffset, const IntSize& textureSize, GC3Dint textureFilter, bool swizzleContents, bool leftEdgeAA, bool topEdgeAA, bool rightEdgeAA, bool bottomEdgeAA); - - Platform3DObject m_textureId; - IntPoint m_textureOffset; - IntSize m_textureSize; - GC3Dint m_textureFilter; - bool m_swizzleContents; - bool m_leftEdgeAA; - bool m_topEdgeAA; - bool m_rightEdgeAA; - bool m_bottomEdgeAA; -}; - +typedef WebKit::WebCompositorTileQuad CCTileDrawQuad; } #endif diff --git a/Source/WebCore/platform/graphics/chromium/cc/CCTiledLayerImpl.cpp b/Source/WebCore/platform/graphics/chromium/cc/CCTiledLayerImpl.cpp index 564e3696b..1b2108912 100644 --- a/Source/WebCore/platform/graphics/chromium/cc/CCTiledLayerImpl.cpp +++ b/Source/WebCore/platform/graphics/chromium/cc/CCTiledLayerImpl.cpp @@ -54,8 +54,6 @@ static const int debugTileBorderMissingTileColorRed = 255; static const int debugTileBorderMissingTileColorGreen = 0; static const int debugTileBorderMissingTileColorBlue = 0; -class ManagedTexture; - class DrawableTile : public CCLayerTilingData::Tile { WTF_MAKE_NONCOPYABLE(DrawableTile); public: @@ -142,13 +140,13 @@ WebTransformationMatrix CCTiledLayerImpl::quadTransform() const void CCTiledLayerImpl::appendQuads(CCQuadCuller& quadList, const CCSharedQuadState* sharedQuadState, bool& hadMissingTiles) { - const IntRect& layerRect = visibleLayerRect(); + const IntRect& contentRect = visibleContentRect(); - if (!m_tiler || m_tiler->hasEmptyBounds() || layerRect.isEmpty()) + if (!m_tiler || m_tiler->hasEmptyBounds() || contentRect.isEmpty()) return; int left, top, right, bottom; - m_tiler->layerRectToTileIndices(layerRect, left, top, right, bottom); + m_tiler->contentRectToTileIndices(contentRect, left, top, right, bottom); if (hasDebugBorders()) { for (int j = top; j <= bottom; ++j) { @@ -174,7 +172,7 @@ void CCTiledLayerImpl::appendQuads(CCQuadCuller& quadList, const CCSharedQuadSta DrawableTile* tile = tileAt(i, j); IntRect tileRect = m_tiler->tileBounds(i, j); IntRect displayRect = tileRect; - tileRect.intersect(layerRect); + tileRect.intersect(contentRect); // Skip empty tiles. if (tileRect.isEmpty()) @@ -189,7 +187,7 @@ void CCTiledLayerImpl::appendQuads(CCQuadCuller& quadList, const CCSharedQuadSta } IntRect tileOpaqueRect = tile->opaqueRect(); - tileOpaqueRect.intersect(layerRect); + tileOpaqueRect.intersect(contentRect); // Keep track of how the top left has moved, so the texture can be // offset the same amount. @@ -235,8 +233,8 @@ Region CCTiledLayerImpl::visibleContentOpaqueRegion() const if (m_skipsDraw) return Region(); if (opaque()) - return visibleLayerRect(); - return m_tiler->opaqueRegionInLayerRect(visibleLayerRect()); + return visibleContentRect(); + return m_tiler->opaqueRegionInContentRect(visibleContentRect()); } void CCTiledLayerImpl::didLoseContext() diff --git a/Source/WebCore/platform/graphics/chromium/cc/CCVideoLayerImpl.cpp b/Source/WebCore/platform/graphics/chromium/cc/CCVideoLayerImpl.cpp index 3e1f58135..cc349c8e5 100644 --- a/Source/WebCore/platform/graphics/chromium/cc/CCVideoLayerImpl.cpp +++ b/Source/WebCore/platform/graphics/chromium/cc/CCVideoLayerImpl.cpp @@ -35,7 +35,7 @@ #include "LayerTextureSubImage.h" #include "NotImplemented.h" #include "TextStream.h" -#include "TextureManager.h" // For TextureAllocator +#include "TextureAllocator.h" #include "cc/CCGraphicsContext.h" #include "cc/CCLayerTreeHostImpl.h" #include "cc/CCProxy.h" diff --git a/Source/WebCore/platform/graphics/chromium/cc/CCVideoLayerImpl.h b/Source/WebCore/platform/graphics/chromium/cc/CCVideoLayerImpl.h index b2e088fcf..cd5db09bc 100644 --- a/Source/WebCore/platform/graphics/chromium/cc/CCVideoLayerImpl.h +++ b/Source/WebCore/platform/graphics/chromium/cc/CCVideoLayerImpl.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2011 Google Inc. All rights reserved. + * Copyright (C) 2012 Google Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/Source/WebCore/platform/graphics/chromium/cc/CCYUVVideoDrawQuad.cpp b/Source/WebCore/platform/graphics/chromium/cc/CCYUVVideoDrawQuad.cpp index a2d62ba44..43f2e2f6f 100644 --- a/Source/WebCore/platform/graphics/chromium/cc/CCYUVVideoDrawQuad.cpp +++ b/Source/WebCore/platform/graphics/chromium/cc/CCYUVVideoDrawQuad.cpp @@ -27,19 +27,27 @@ #include "cc/CCYUVVideoDrawQuad.h" +using WebKit::WebCompositorQuad; + namespace WebCore { -PassOwnPtr<CCYUVVideoDrawQuad> CCYUVVideoDrawQuad::create(const CCSharedQuadState* sharedQuadState, const IntRect& quadRect, const CCVideoLayerImpl::FramePlane& yPlane, const CCVideoLayerImpl::FramePlane& uPlane, const CCVideoLayerImpl::FramePlane& vPlane) +PassOwnPtr<CCYUVVideoDrawQuad> CCYUVVideoDrawQuad::create(const WebKit::WebCompositorSharedQuadState* sharedQuadState, const IntRect& quadRect, const CCVideoLayerImpl::FramePlane& yPlane, const CCVideoLayerImpl::FramePlane& uPlane, const CCVideoLayerImpl::FramePlane& vPlane) { return adoptPtr(new CCYUVVideoDrawQuad(sharedQuadState, quadRect, yPlane, uPlane, vPlane)); } -CCYUVVideoDrawQuad::CCYUVVideoDrawQuad(const CCSharedQuadState* sharedQuadState, const IntRect& quadRect, const CCVideoLayerImpl::FramePlane& yPlane, const CCVideoLayerImpl::FramePlane& uPlane, const CCVideoLayerImpl::FramePlane& vPlane) - : CCDrawQuad(sharedQuadState, CCDrawQuad::YUVVideoContent, quadRect) +CCYUVVideoDrawQuad::CCYUVVideoDrawQuad(const WebKit::WebCompositorSharedQuadState* sharedQuadState, const IntRect& quadRect, const CCVideoLayerImpl::FramePlane& yPlane, const CCVideoLayerImpl::FramePlane& uPlane, const CCVideoLayerImpl::FramePlane& vPlane) + : WebCompositorQuad(sharedQuadState, WebCompositorQuad::YUVVideoContent, quadRect) , m_yPlane(yPlane) , m_uPlane(uPlane) , m_vPlane(vPlane) { } +const CCYUVVideoDrawQuad* CCYUVVideoDrawQuad::materialCast(const WebKit::WebCompositorQuad* quad) +{ + ASSERT(quad->material() == WebCompositorQuad::YUVVideoContent); + return static_cast<const CCYUVVideoDrawQuad*>(quad); +} + } diff --git a/Source/WebCore/platform/graphics/chromium/cc/CCYUVVideoDrawQuad.h b/Source/WebCore/platform/graphics/chromium/cc/CCYUVVideoDrawQuad.h index 0cd758c5b..6684ad897 100644 --- a/Source/WebCore/platform/graphics/chromium/cc/CCYUVVideoDrawQuad.h +++ b/Source/WebCore/platform/graphics/chromium/cc/CCYUVVideoDrawQuad.h @@ -26,23 +26,24 @@ #ifndef CCYUVVideoDrawQuad_h #define CCYUVVideoDrawQuad_h -#include "cc/CCDrawQuad.h" #include "cc/CCVideoLayerImpl.h" +#include <public/WebCompositorQuad.h> #include <wtf/PassOwnPtr.h> namespace WebCore { -class CCYUVVideoDrawQuad : public CCDrawQuad { +class CCYUVVideoDrawQuad : public WebKit::WebCompositorQuad { WTF_MAKE_NONCOPYABLE(CCYUVVideoDrawQuad); public: - static PassOwnPtr<CCYUVVideoDrawQuad> create(const CCSharedQuadState*, const IntRect&, const CCVideoLayerImpl::FramePlane& yPlane, const CCVideoLayerImpl::FramePlane& uPlane, const CCVideoLayerImpl::FramePlane& vPlane); + static PassOwnPtr<CCYUVVideoDrawQuad> create(const WebKit::WebCompositorSharedQuadState*, const IntRect&, const CCVideoLayerImpl::FramePlane& yPlane, const CCVideoLayerImpl::FramePlane& uPlane, const CCVideoLayerImpl::FramePlane& vPlane); const CCVideoLayerImpl::FramePlane& yPlane() const { return m_yPlane; } const CCVideoLayerImpl::FramePlane& uPlane() const { return m_uPlane; } const CCVideoLayerImpl::FramePlane& vPlane() const { return m_vPlane; } + static const CCYUVVideoDrawQuad* materialCast(const WebKit::WebCompositorQuad*); private: - CCYUVVideoDrawQuad(const CCSharedQuadState*, const IntRect&, const CCVideoLayerImpl::FramePlane& yPlane, const CCVideoLayerImpl::FramePlane& uPlane, const CCVideoLayerImpl::FramePlane& vPlane); + CCYUVVideoDrawQuad(const WebKit::WebCompositorSharedQuadState*, const IntRect&, const CCVideoLayerImpl::FramePlane& yPlane, const CCVideoLayerImpl::FramePlane& uPlane, const CCVideoLayerImpl::FramePlane& vPlane); CCVideoLayerImpl::FramePlane m_yPlane; CCVideoLayerImpl::FramePlane m_uPlane; diff --git a/Source/WebCore/platform/graphics/cocoa/FontPlatformDataCocoa.mm b/Source/WebCore/platform/graphics/cocoa/FontPlatformDataCocoa.mm index f30b181f6..fbfe6379f 100644 --- a/Source/WebCore/platform/graphics/cocoa/FontPlatformDataCocoa.mm +++ b/Source/WebCore/platform/graphics/cocoa/FontPlatformDataCocoa.mm @@ -59,13 +59,13 @@ FontPlatformData::FontPlatformData(NSFont *nsFont, float size, bool isPrinterFon CGFontRef cgFont = 0; loadFont(nsFont, size, m_font, cgFont); -#if !defined(BUILDING_ON_LEOPARD) && !defined(BUILDING_ON_SNOW_LEOPARD) +#if PLATFORM(IOS) || __MAC_OS_X_VERSION_MIN_REQUIRED >= 1070 // FIXME: Chromium: The following code isn't correct for the Chromium port since the sandbox might // have blocked font loading, in which case we'll only have the real loaded font file after the call to loadFont(). { CTFontSymbolicTraits traits = CTFontGetSymbolicTraits(toCTFontRef(m_font)); m_isColorBitmapFont = traits & kCTFontColorGlyphsTrait; -#if !defined(BUILDING_ON_SNOW_LEOPARD) && !defined(BUILDING_ON_LION) && !PLATFORM(IOS) +#if PLATFORM(IOS) || __MAC_OS_X_VERSION_MIN_REQUIRED >= 1080 m_isCompositeFontReference = traits & kCTFontCompositeTrait; #endif } @@ -150,11 +150,11 @@ void FontPlatformData::setFont(NSFont *font) #endif m_cgFont.adoptCF(cgFont); -#if !defined(BUILDING_ON_LEOPARD) && !defined(BUILDING_ON_SNOW_LEOPARD) +#if PLATFORM(IOS) || __MAC_OS_X_VERSION_MIN_REQUIRED >= 1070 { CTFontSymbolicTraits traits = CTFontGetSymbolicTraits(toCTFontRef(m_font)); m_isColorBitmapFont = traits & kCTFontColorGlyphsTrait; -#if !defined(BUILDING_ON_SNOW_LEOPARD) && !defined(BUILDING_ON_LION) +#if PLATFORM(IOS) || __MAC_OS_X_VERSION_MIN_REQUIRED >= 1080 m_isCompositeFontReference = traits & kCTFontCompositeTrait; #endif } @@ -251,7 +251,7 @@ static bool canSetCascadeListForCustomFont() } return systemVersion >= 0x1060; -#elif !defined(BUILDING_ON_LEOPARD) +#elif PLATFORM(IOS) || __MAC_OS_X_VERSION_MIN_REQUIRED >= 1060 return true; #else return false; diff --git a/Source/WebCore/platform/graphics/filters/FEBlend.cpp b/Source/WebCore/platform/graphics/filters/FEBlend.cpp index aa733d90f..363a75b7f 100644 --- a/Source/WebCore/platform/graphics/filters/FEBlend.cpp +++ b/Source/WebCore/platform/graphics/filters/FEBlend.cpp @@ -24,6 +24,7 @@ #if ENABLE(FILTERS) #include "FEBlend.h" +#include "FEBlendNEON.h" #include "Filter.h" #include "FloatPoint.h" @@ -86,26 +87,12 @@ static inline unsigned char lighten(unsigned char colorA, unsigned char colorB, return ((std::max((255 - alphaA) * colorB + colorA * 255, (255 - alphaB) * colorA + colorB * 255)) / 255); } -void FEBlend::platformApplySoftware() +void FEBlend::platformApplyGeneric(PassRefPtr<Uint8ClampedArray> pixelArrayA, PassRefPtr<Uint8ClampedArray> pixelArrayB, + Uint8ClampedArray* dstPixelArray, unsigned pixelArrayLength) { - FilterEffect* in = inputEffect(0); - FilterEffect* in2 = inputEffect(1); - - ASSERT(m_mode > FEBLEND_MODE_UNKNOWN); - ASSERT(m_mode <= FEBLEND_MODE_LIGHTEN); + RefPtr<Uint8ClampedArray> srcPixelArrayA = pixelArrayA; + RefPtr<Uint8ClampedArray> srcPixelArrayB = pixelArrayB; - Uint8ClampedArray* dstPixelArray = createPremultipliedImageResult(); - if (!dstPixelArray) - return; - - IntRect effectADrawingRect = requestedRegionOfInputImageData(in->absolutePaintRect()); - RefPtr<Uint8ClampedArray> srcPixelArrayA = in->asPremultipliedImage(effectADrawingRect); - - IntRect effectBDrawingRect = requestedRegionOfInputImageData(in2->absolutePaintRect()); - RefPtr<Uint8ClampedArray> srcPixelArrayB = in2->asPremultipliedImage(effectBDrawingRect); - - unsigned pixelArrayLength = srcPixelArrayA->length(); - ASSERT(pixelArrayLength == srcPixelArrayB->length()); for (unsigned pixelOffset = 0; pixelOffset < pixelArrayLength; pixelOffset += 4) { unsigned char alphaA = srcPixelArrayA->item(pixelOffset + 3); unsigned char alphaB = srcPixelArrayB->item(pixelOffset + 3); @@ -143,6 +130,45 @@ void FEBlend::platformApplySoftware() } } +void FEBlend::platformApplySoftware() +{ + FilterEffect* in = inputEffect(0); + FilterEffect* in2 = inputEffect(1); + + ASSERT(m_mode > FEBLEND_MODE_UNKNOWN); + ASSERT(m_mode <= FEBLEND_MODE_LIGHTEN); + + Uint8ClampedArray* dstPixelArray = createPremultipliedImageResult(); + if (!dstPixelArray) + return; + + IntRect effectADrawingRect = requestedRegionOfInputImageData(in->absolutePaintRect()); + RefPtr<Uint8ClampedArray> srcPixelArrayA = in->asPremultipliedImage(effectADrawingRect); + + IntRect effectBDrawingRect = requestedRegionOfInputImageData(in2->absolutePaintRect()); + RefPtr<Uint8ClampedArray> srcPixelArrayB = in2->asPremultipliedImage(effectBDrawingRect); + + unsigned pixelArrayLength = srcPixelArrayA->length(); + ASSERT(pixelArrayLength == srcPixelArrayB->length()); + +#if HAVE(ARM_NEON_INTRINSICS) + if (pixelArrayLength >= 8) + platformApplyNEON(srcPixelArrayA->data(), srcPixelArrayB->data(), dstPixelArray->data(), pixelArrayLength); + else { // If there is just one pixel we expand it to two. + ASSERT(pixelArrayLength > 0); + uint32_t sourceA[2] = {0, 0}; + uint32_t sourceBAndDest[2] = {0, 0}; + + sourceA[0] = reinterpret_cast<uint32_t*>(srcPixelArrayA->data())[0]; + sourceBAndDest[0] = reinterpret_cast<uint32_t*>(srcPixelArrayB->data())[0]; + platformApplyNEON(reinterpret_cast<uint8_t*>(sourceA), reinterpret_cast<uint8_t*>(sourceBAndDest), reinterpret_cast<uint8_t*>(sourceBAndDest), 8); + reinterpret_cast<uint32_t*>(dstPixelArray->data())[0] = sourceBAndDest[0]; + } +#else + platformApplyGeneric(srcPixelArrayA, srcPixelArrayB, dstPixelArray, pixelArrayLength); +#endif +} + void FEBlend::dump() { } diff --git a/Source/WebCore/platform/graphics/filters/FEBlend.h b/Source/WebCore/platform/graphics/filters/FEBlend.h index 68cd1d37a..cc72e4aca 100644 --- a/Source/WebCore/platform/graphics/filters/FEBlend.h +++ b/Source/WebCore/platform/graphics/filters/FEBlend.h @@ -45,6 +45,11 @@ public: BlendModeType blendMode() const; bool setBlendMode(BlendModeType); + void platformApplyGeneric(PassRefPtr<Uint8ClampedArray> pixelArrayA, PassRefPtr<Uint8ClampedArray> pixelArrayB, + Uint8ClampedArray* dstPixelArray, unsigned pixelArrayLength); + void platformApplyNEON(unsigned char* srcPixelArrayA, unsigned char* srcPixelArrayB, unsigned char* dstPixelArray, + unsigned colorArrayLength); + virtual void platformApplySoftware(); virtual void dump(); diff --git a/Source/WebCore/platform/graphics/filters/arm/FEBlendNEON.h b/Source/WebCore/platform/graphics/filters/arm/FEBlendNEON.h new file mode 100644 index 000000000..97418f2c1 --- /dev/null +++ b/Source/WebCore/platform/graphics/filters/arm/FEBlendNEON.h @@ -0,0 +1,175 @@ +/* + * Copyright (C) 2012 University of Szeged + * Copyright (C) 2012 Gabor Rapcsanyi + * + * 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 UNIVERSITY OF SZEGED ``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 UNIVERSITY OF SZEGED 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. + */ + +#ifndef FEBlendNEON_h +#define FEBlendNEON_h + +#include <wtf/Platform.h> + +#if ENABLE(FILTERS) && HAVE(ARM_NEON_INTRINSICS) + +#include "FEBlend.h" +#include <arm_neon.h> + +namespace WebCore { + +class FEBlendUtilitiesNEON { +public: + static inline uint16x8_t div255(uint16x8_t num, uint16x8_t sixteenConst255, uint16x8_t sixteenConstOne) + { + uint16x8_t quotient = vshrq_n_u16(num, 8); + uint16x8_t remainder = vaddq_u16(vsubq_u16(num, vmulq_u16(sixteenConst255, quotient)), sixteenConstOne); + return vaddq_u16(quotient, vshrq_n_u16(remainder, 8)); + } + + static inline uint16x8_t normal(uint16x8_t pixelA, uint16x8_t pixelB, uint16x8_t alphaA, uint16x8_t, + uint16x8_t sixteenConst255, uint16x8_t sixteenConstOne) + { + uint16x8_t tmp1 = vsubq_u16(sixteenConst255, alphaA); + uint16x8_t tmp2 = vmulq_u16(tmp1, pixelB); + uint16x8_t tmp3 = div255(tmp2, sixteenConst255, sixteenConstOne); + return vaddq_u16(tmp3, pixelA); + } + + static inline uint16x8_t multiply(uint16x8_t pixelA, uint16x8_t pixelB, uint16x8_t alphaA, uint16x8_t alphaB, + uint16x8_t sixteenConst255, uint16x8_t sixteenConstOne) + { + uint16x8_t tmp1 = vsubq_u16(sixteenConst255, alphaA); + uint16x8_t tmp2 = vmulq_u16(tmp1, pixelB); + uint16x8_t tmp3 = vaddq_u16(vsubq_u16(sixteenConst255, alphaB), pixelB); + uint16x8_t tmp4 = vmulq_u16(tmp3, pixelA); + uint16x8_t tmp5 = vaddq_u16(tmp2, tmp4); + return div255(tmp5, sixteenConst255, sixteenConstOne); + } + + static inline uint16x8_t screen(uint16x8_t pixelA, uint16x8_t pixelB, uint16x8_t, uint16x8_t, + uint16x8_t sixteenConst255, uint16x8_t sixteenConstOne) + { + uint16x8_t tmp1 = vaddq_u16(pixelA, pixelB); + uint16x8_t tmp2 = vmulq_u16(pixelA, pixelB); + uint16x8_t tmp3 = div255(tmp2, sixteenConst255, sixteenConstOne); + return vsubq_u16(tmp1, tmp3); + } + + static inline uint16x8_t darken(uint16x8_t pixelA, uint16x8_t pixelB, uint16x8_t alphaA, uint16x8_t alphaB, + uint16x8_t sixteenConst255, uint16x8_t sixteenConstOne) + { + uint16x8_t tmp1 = vsubq_u16(sixteenConst255, alphaA); + uint16x8_t tmp2 = vmulq_u16(tmp1, pixelB); + uint16x8_t tmp3 = div255(tmp2, sixteenConst255, sixteenConstOne); + uint16x8_t tmp4 = vaddq_u16(tmp3, pixelA); + + uint16x8_t tmp5 = vsubq_u16(sixteenConst255, alphaB); + uint16x8_t tmp6 = vmulq_u16(tmp5, pixelA); + uint16x8_t tmp7 = div255(tmp6, sixteenConst255, sixteenConstOne); + uint16x8_t tmp8 = vaddq_u16(tmp7, pixelB); + + return vminq_u16(tmp4, tmp8); + } + + static inline uint16x8_t lighten(uint16x8_t pixelA, uint16x8_t pixelB, uint16x8_t alphaA, uint16x8_t alphaB, + uint16x8_t sixteenConst255, uint16x8_t sixteenConstOne) + { + uint16x8_t tmp1 = vsubq_u16(sixteenConst255, alphaA); + uint16x8_t tmp2 = vmulq_u16(tmp1, pixelB); + uint16x8_t tmp3 = div255(tmp2, sixteenConst255, sixteenConstOne); + uint16x8_t tmp4 = vaddq_u16(tmp3, pixelA); + + uint16x8_t tmp5 = vsubq_u16(sixteenConst255, alphaB); + uint16x8_t tmp6 = vmulq_u16(tmp5, pixelA); + uint16x8_t tmp7 = div255(tmp6, sixteenConst255, sixteenConstOne); + uint16x8_t tmp8 = vaddq_u16(tmp7, pixelB); + + return vmaxq_u16(tmp4, tmp8); + } +}; + +void FEBlend::platformApplyNEON(unsigned char* srcPixelArrayA, unsigned char* srcPixelArrayB, unsigned char* dstPixelArray, + unsigned colorArrayLength) +{ + uint8_t* sourcePixelA = reinterpret_cast<uint8_t*>(srcPixelArrayA); + uint8_t* sourcePixelB = reinterpret_cast<uint8_t*>(srcPixelArrayB); + uint8_t* destinationPixel = reinterpret_cast<uint8_t*>(dstPixelArray); + + uint16x8_t sixteenConst255 = vdupq_n_u16(255); + uint16x8_t sixteenConstOne = vdupq_n_u16(1); + + unsigned colorOffset = 0; + while (colorOffset < colorArrayLength) { + unsigned char alphaA1 = srcPixelArrayA[colorOffset + 3]; + unsigned char alphaB1 = srcPixelArrayB[colorOffset + 3]; + unsigned char alphaA2 = srcPixelArrayA[colorOffset + 7]; + unsigned char alphaB2 = srcPixelArrayB[colorOffset + 7]; + + uint16x8_t doubblePixelA = vmovl_u8(vld1_u8(sourcePixelA + colorOffset)); + uint16x8_t doubblePixelB = vmovl_u8(vld1_u8(sourcePixelB + colorOffset)); + uint16x8_t alphaA = vcombine_u16(vdup_n_u16(alphaA1), vdup_n_u16(alphaA2)); + uint16x8_t alphaB = vcombine_u16(vdup_n_u16(alphaB1), vdup_n_u16(alphaB2)); + + uint16x8_t result; + switch (m_mode) { + case FEBLEND_MODE_NORMAL: + result = FEBlendUtilitiesNEON::normal(doubblePixelA, doubblePixelB, alphaA, alphaB, sixteenConst255, sixteenConstOne); + break; + case FEBLEND_MODE_MULTIPLY: + result = FEBlendUtilitiesNEON::multiply(doubblePixelA, doubblePixelB, alphaA, alphaB, sixteenConst255, sixteenConstOne); + break; + case FEBLEND_MODE_SCREEN: + result = FEBlendUtilitiesNEON::screen(doubblePixelA, doubblePixelB, alphaA, alphaB, sixteenConst255, sixteenConstOne); + break; + case FEBLEND_MODE_DARKEN: + result = FEBlendUtilitiesNEON::darken(doubblePixelA, doubblePixelB, alphaA, alphaB, sixteenConst255, sixteenConstOne); + break; + case FEBLEND_MODE_LIGHTEN: + result = FEBlendUtilitiesNEON::lighten(doubblePixelA, doubblePixelB, alphaA, alphaB, sixteenConst255, sixteenConstOne); + break; + case FEBLEND_MODE_UNKNOWN: + default: + result = vdupq_n_u16(0); + break; + } + + vst1_u8(destinationPixel + colorOffset, vmovn_u16(result)); + + unsigned char alphaR1 = 255 - ((255 - alphaA1) * (255 - alphaB1)) / 255; + unsigned char alphaR2 = 255 - ((255 - alphaA2) * (255 - alphaB2)) / 255; + + dstPixelArray[colorOffset + 3] = alphaR1; + dstPixelArray[colorOffset + 7] = alphaR2; + + colorOffset += 8; + if (colorOffset > colorArrayLength) { + ASSERT(colorOffset - 4 == colorArrayLength); + colorOffset = colorArrayLength - 8; + } + } +} + +} // namespace WebCore + +#endif // ENABLE(FILTERS) && HAVE(ARM_NEON_INTRINSICS) + +#endif // FEBlendNEON_h diff --git a/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp b/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp index f2b86b27e..fba8252da 100644 --- a/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp +++ b/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp @@ -1624,7 +1624,7 @@ bool MediaPlayerPrivateGStreamer::hasSingleSecurityOrigin() const bool MediaPlayerPrivateGStreamer::supportsFullscreen() const { -#if defined(BUILDING_ON_LEOPARD) +#if PLATFORM(MAC) && !PLATFORM(IOS) && __MAC_OS_X_VERSION_MIN_REQUIRED == 1050 // See <rdar://problem/7389945> return false; #else diff --git a/Source/WebCore/platform/graphics/gtk/ImageBufferGtk.cpp b/Source/WebCore/platform/graphics/gtk/ImageBufferGtk.cpp index ea3430aa5..46ff53b4f 100644 --- a/Source/WebCore/platform/graphics/gtk/ImageBufferGtk.cpp +++ b/Source/WebCore/platform/graphics/gtk/ImageBufferGtk.cpp @@ -19,13 +19,13 @@ #include "config.h" #include "ImageBuffer.h" -#include "Base64.h" #include "GdkCairoUtilities.h" #include <wtf/gobject/GOwnPtr.h> #include "GRefPtrGtk.h" #include "MIMETypeRegistry.h" #include <cairo.h> #include <gtk/gtk.h> +#include <wtf/text/Base64.h> #include <wtf/text/CString.h> #include <wtf/text/WTFString.h> diff --git a/Source/WebCore/platform/graphics/harfbuzz/FontHarfBuzz.cpp b/Source/WebCore/platform/graphics/harfbuzz/FontHarfBuzz.cpp index cc8efeb43..19a0b9a6d 100644 --- a/Source/WebCore/platform/graphics/harfbuzz/FontHarfBuzz.cpp +++ b/Source/WebCore/platform/graphics/harfbuzz/FontHarfBuzz.cpp @@ -187,7 +187,8 @@ void Font::drawComplexText(GraphicsContext* gc, const TextRun& run, HarfBuzzShaper shaper(this, run); if (!shaper.shape(&glyphBuffer)) return; - drawGlyphBuffer(gc, run, glyphBuffer, point); + FloatPoint adjustedPoint = shaper.adjustStartPoint(point); + drawGlyphBuffer(gc, run, glyphBuffer, adjustedPoint); #else SkCanvas* canvas = gc->platformContext()->canvas(); ComplexTextController controller(this, run, point.x(), point.y()); diff --git a/Source/WebCore/platform/graphics/harfbuzz/FontPlatformDataHarfBuzz.cpp b/Source/WebCore/platform/graphics/harfbuzz/FontPlatformDataHarfBuzz.cpp index 695531cc1..48b162474 100644 --- a/Source/WebCore/platform/graphics/harfbuzz/FontPlatformDataHarfBuzz.cpp +++ b/Source/WebCore/platform/graphics/harfbuzz/FontPlatformDataHarfBuzz.cpp @@ -175,31 +175,19 @@ String FontPlatformData::description() const void FontPlatformData::setupPaint(SkPaint* paint) const { - const float ts = m_textSize >= 0 ? m_textSize : 12; + paint->setAntiAlias(m_style.useAntiAlias); + paint->setHinting(static_cast<SkPaint::Hinting>(m_style.hintStyle)); + paint->setEmbeddedBitmapText(m_style.useBitmaps); + paint->setAutohinted(m_style.useAutoHint); + paint->setSubpixelText(m_style.useSubpixelPositioning); + if (m_style.useAntiAlias) + paint->setLCDRenderText(m_style.useSubpixelRendering); - paint->setAntiAlias(m_style.useAntiAlias == FontRenderStyle::NoPreference ? useSkiaAntiAlias : m_style.useAntiAlias); - switch (m_style.useHinting) { - case FontRenderStyle::NoPreference: - paint->setHinting(skiaHinting); - break; - case 0: - paint->setHinting(SkPaint::kNo_Hinting); - break; - default: - paint->setHinting(static_cast<SkPaint::Hinting>(m_style.hintStyle)); - break; - } - - paint->setEmbeddedBitmapText(m_style.useBitmaps == FontRenderStyle::NoPreference ? useSkiaBitmaps : m_style.useBitmaps); + const float ts = m_textSize >= 0 ? m_textSize : 12; paint->setTextSize(SkFloatToScalar(ts)); paint->setTypeface(m_typeface); paint->setFakeBoldText(m_fakeBold); paint->setTextSkewX(m_fakeItalic ? -SK_Scalar1 / 4 : 0); - paint->setAutohinted(m_style.useAutoHint == FontRenderStyle::NoPreference ? useSkiaAutoHint : m_style.useAutoHint); - paint->setSubpixelText(m_style.useSubpixelPositioning == FontRenderStyle::NoPreference ? useSkiaSubpixelPositioning : m_style.useSubpixelPositioning); - - if (m_style.useAntiAlias == 1 || (m_style.useAntiAlias == FontRenderStyle::NoPreference && useSkiaAntiAlias)) - paint->setLCDRenderText(m_style.useSubpixelRendering == FontRenderStyle::NoPreference ? useSkiaSubpixelRendering : m_style.useSubpixelRendering); } SkFontID FontPlatformData::uniqueID() const @@ -272,6 +260,26 @@ HarfbuzzFace* FontPlatformData::harfbuzzFace() const void FontPlatformData::querySystemForRenderStyle() { PlatformSupport::getRenderStyleForStrike(m_family.data(), (((int)m_textSize) << 2) | (m_typeface->style() & 3), &m_style); + + // Fix FontRenderStyle::NoPreference to actual styles. + if (m_style.useAntiAlias == FontRenderStyle::NoPreference) + m_style.useAntiAlias = useSkiaAntiAlias; + + if (!m_style.useHinting) + m_style.hintStyle = SkPaint::kNo_Hinting; + else if (m_style.useHinting == FontRenderStyle::NoPreference) + m_style.hintStyle = skiaHinting; + + if (m_style.useBitmaps == FontRenderStyle::NoPreference) + m_style.useBitmaps = useSkiaBitmaps; + if (m_style.useAutoHint == FontRenderStyle::NoPreference) + m_style.useAutoHint = useSkiaAutoHint; + if (m_style.useSubpixelPositioning == FontRenderStyle::NoPreference) + m_style.useSubpixelPositioning = useSkiaSubpixelPositioning; + if (m_style.useAntiAlias == FontRenderStyle::NoPreference) + m_style.useAntiAlias = useSkiaAntiAlias; + if (m_style.useSubpixelRendering == FontRenderStyle::NoPreference) + m_style.useSubpixelRendering = useSkiaSubpixelRendering; } } // namespace WebCore diff --git a/Source/WebCore/platform/graphics/harfbuzz/FontPlatformDataHarfBuzz.h b/Source/WebCore/platform/graphics/harfbuzz/FontPlatformDataHarfBuzz.h index b4423f400..6f4eca331 100644 --- a/Source/WebCore/platform/graphics/harfbuzz/FontPlatformDataHarfBuzz.h +++ b/Source/WebCore/platform/graphics/harfbuzz/FontPlatformDataHarfBuzz.h @@ -139,6 +139,9 @@ public: HarfbuzzFace* harfbuzzFace() const; #endif + // The returned styles are all actual styles without FontRenderStyle::NoPreference. + const FontRenderStyle& fontRenderStyle() const { return m_style; } + // ------------------------------------------------------------------------- // Global font preferences... diff --git a/Source/WebCore/platform/graphics/harfbuzz/ng/HarfBuzzShaper.cpp b/Source/WebCore/platform/graphics/harfbuzz/ng/HarfBuzzShaper.cpp index 3eed897ba..68d196df1 100644 --- a/Source/WebCore/platform/graphics/harfbuzz/ng/HarfBuzzShaper.cpp +++ b/Source/WebCore/platform/graphics/harfbuzz/ng/HarfBuzzShaper.cpp @@ -32,6 +32,7 @@ #include "HarfBuzzShaper.h" #include "Font.h" +#include "HarfBuzzFace.h" #include "SurrogatePairAwareTextIterator.h" #include "TextRun.h" #include "hb-icu.h" @@ -43,19 +44,47 @@ namespace WebCore { +template<typename T> +class HarfBuzzScopedPtr { +public: + typedef void (*DestroyFunction)(T*); + + HarfBuzzScopedPtr(T* ptr, DestroyFunction destroy) + : m_ptr(ptr) + , m_destroy(destroy) + { + ASSERT(m_destroy); + } + ~HarfBuzzScopedPtr() + { + if (m_ptr) + (*m_destroy)(m_ptr); + } + + T* get() { return m_ptr; } +private: + T* m_ptr; + DestroyFunction m_destroy; +}; + static inline float harfbuzzPositionToFloat(hb_position_t value) { return static_cast<float>(value) / (1 << 16); } -HarfBuzzShaper::HarfBuzzRun::HarfBuzzRun(unsigned numCharacters, TextDirection direction, hb_buffer_t* harfbuzzBuffer) - : m_numCharacters(numCharacters) +HarfBuzzShaper::HarfBuzzRun::HarfBuzzRun(const SimpleFontData* fontData, unsigned startIndex, unsigned numCharacters, TextDirection direction) + : m_fontData(fontData) + , m_startIndex(startIndex) + , m_numCharacters(numCharacters) , m_direction(direction) { +} + +void HarfBuzzShaper::HarfBuzzRun::applyShapeResult(hb_buffer_t* harfbuzzBuffer) +{ m_numGlyphs = hb_buffer_get_length(harfbuzzBuffer); m_glyphs.resize(m_numGlyphs); m_advances.resize(m_numGlyphs); - m_offsets.resize(m_numGlyphs); m_glyphToCharacterIndex.resize(m_numGlyphs); m_logClusters.resize(m_numCharacters); @@ -82,10 +111,9 @@ HarfBuzzShaper::HarfBuzzRun::HarfBuzzRun(unsigned numCharacters, TextDirection d } } -void HarfBuzzShaper::HarfBuzzRun::setGlyphAndPositions(unsigned index, uint16_t glyphId, float x, float y, float advance) +void HarfBuzzShaper::HarfBuzzRun::setGlyphAndAdvance(unsigned index, uint16_t glyphId, float advance) { m_glyphs[index] = glyphId; - m_offsets[index].set(x, y); m_advances[index] = advance; } @@ -106,31 +134,49 @@ int HarfBuzzShaper::HarfBuzzRun::characterIndexForXPosition(int targetX) return rtl() ? 0 : m_numCharacters; } -int HarfBuzzShaper::HarfBuzzRun::xPositionForOffset(unsigned offset) +float HarfBuzzShaper::HarfBuzzRun::xPositionForOffset(unsigned offset) { ASSERT(offset < m_numCharacters); unsigned glyphIndex = m_logClusters[offset]; - ASSERT(glyphIndex < m_numGlyphs); - float position = m_offsets[glyphIndex].x(); + ASSERT(glyphIndex <= m_numGlyphs); + float position = 0; + for (unsigned i = 0; i < glyphIndex; ++i) + position += m_advances[i]; if (rtl()) position += m_advances[glyphIndex]; - return roundf(position); + return position; +} + +static void normalizeCharacters(const UChar* source, UChar* destination, int length) +{ + int position = 0; + bool error = false; + while (position < length) { + UChar32 character; + int nextPosition = position; + U16_NEXT(source, nextPosition, length, character); + if (Font::treatAsSpace(character)) + character = ' '; + else if (Font::treatAsZeroWidthSpaceInComplexScript(character)) + character = zeroWidthSpace; + U16_APPEND(destination, position, length, character, error); + ASSERT_UNUSED(error, !error); + position = nextPosition; + } } HarfBuzzShaper::HarfBuzzShaper(const Font* font, const TextRun& run) : HarfBuzzShaperBase(font, run) - , m_startIndexOfCurrentRun(0) - , m_numCharactersOfCurrentRun(0) - , m_harfbuzzBuffer(0) { - setNormalizedBuffer(); + m_normalizedBuffer = adoptArrayPtr(new UChar[m_run.length() + 1]); + m_normalizedBufferLength = m_run.length(); + normalizeCharacters(m_run.characters(), m_normalizedBuffer.get(), m_normalizedBufferLength); + setPadding(m_run.expansion()); setFontFeatures(); } HarfBuzzShaper::~HarfBuzzShaper() { - if (m_harfbuzzBuffer) - hb_buffer_destroy(m_harfbuzzBuffer); } void HarfBuzzShaper::setFontFeatures() @@ -152,101 +198,101 @@ void HarfBuzzShaper::setFontFeatures() bool HarfBuzzShaper::shape(GlyphBuffer* glyphBuffer) { - m_totalWidth = 0; - while (setupHarfBuzzRun()) { - if (!shapeHarfBuzzRun()) - return false; - setGlyphPositionsForHarfBuzzRun(glyphBuffer); - } - - if (!m_harfbuzzRuns.size()) + if (!collectHarfBuzzRuns()) return false; + m_totalWidth = 0; + if (!shapeHarfBuzzRuns(glyphBuffer)) + return false; + m_totalWidth = roundf(m_totalWidth); return true; } -bool HarfBuzzShaper::setupHarfBuzzRun() +FloatPoint HarfBuzzShaper::adjustStartPoint(const FloatPoint& point) { - m_startIndexOfCurrentRun += m_numCharactersOfCurrentRun; + return point + m_startOffset; +} - // Iterate through the text to take the largest range that stays within - // a single font. - int endOfRunIndex = m_normalizedBufferLength - m_startIndexOfCurrentRun; - SurrogatePairAwareTextIterator iterator(m_normalizedBuffer.get() + m_startIndexOfCurrentRun, 0, endOfRunIndex, endOfRunIndex); +bool HarfBuzzShaper::collectHarfBuzzRuns() +{ + SurrogatePairAwareTextIterator iterator(m_normalizedBuffer.get(), 0, m_normalizedBufferLength, m_normalizedBufferLength); UChar32 character; unsigned clusterLength = 0; + unsigned startIndexOfCurrentRun = 0; if (!iterator.consume(character, clusterLength)) return false; - m_currentFontData = m_font->glyphDataForCharacter(character, false).fontData; + const SimpleFontData* nextFontData = m_font->glyphDataForCharacter(character, false).fontData; UErrorCode errorCode = U_ZERO_ERROR; - UScriptCode currentScript = uscript_getScript(character, &errorCode); + UScriptCode nextScript = uscript_getScript(character, &errorCode); if (U_FAILURE(errorCode)) return false; - if (currentScript == USCRIPT_INHERITED) - currentScript = USCRIPT_COMMON; - for (iterator.advance(clusterLength); iterator.consume(character, clusterLength); iterator.advance(clusterLength)) { - const SimpleFontData* nextFontData = m_font->glyphDataForCharacter(character, false).fontData; - if (nextFontData != m_currentFontData) - break; - UScriptCode nextScript = uscript_getScript(character, &errorCode); - if (U_FAILURE(errorCode)) - return false; - if (currentScript == nextScript || nextScript == USCRIPT_INHERITED || nextScript == USCRIPT_COMMON) - continue; - if (currentScript == USCRIPT_COMMON) - currentScript = nextScript; - else - break; - } - m_numCharactersOfCurrentRun = iterator.currentCharacter(); - - if (!m_harfbuzzBuffer) { - m_harfbuzzBuffer = hb_buffer_create(); - hb_buffer_set_unicode_funcs(m_harfbuzzBuffer, hb_icu_get_unicode_funcs()); - } else - hb_buffer_reset(m_harfbuzzBuffer); - hb_buffer_set_script(m_harfbuzzBuffer, hb_icu_script_to_script(currentScript)); - - // WebKit always sets direction to LTR during width calculation. - // We only set direction when direction is explicitly set to RTL so that - // preventng wrong width calculation. - if (m_run.rtl()) - hb_buffer_set_direction(m_harfbuzzBuffer, HB_DIRECTION_RTL); - - // Determine whether this run needs to be converted to small caps. - // nextScriptRun() will always send us a run of the same case, because a - // case change while in small-caps mode always results in different - // FontData, so we only need to check the first character's case. - if (m_font->isSmallCaps() && u_islower(m_normalizedBuffer[m_startIndexOfCurrentRun])) { - String upperText = String(m_normalizedBuffer.get() + m_startIndexOfCurrentRun, m_numCharactersOfCurrentRun); - upperText.makeUpper(); - m_currentFontData = m_font->glyphDataForCharacter(upperText[0], false, SmallCapsVariant).fontData; - hb_buffer_add_utf16(m_harfbuzzBuffer, upperText.characters(), m_numCharactersOfCurrentRun, 0, m_numCharactersOfCurrentRun); - } else - hb_buffer_add_utf16(m_harfbuzzBuffer, m_normalizedBuffer.get() + m_startIndexOfCurrentRun, m_numCharactersOfCurrentRun, 0, m_numCharactersOfCurrentRun); - return true; + do { + const SimpleFontData* currentFontData = nextFontData; + UScriptCode currentScript = nextScript; + + for (iterator.advance(clusterLength); iterator.consume(character, clusterLength); iterator.advance(clusterLength)) { + nextFontData = m_font->glyphDataForCharacter(character, false).fontData; + if (nextFontData != currentFontData) + break; + nextScript = uscript_getScript(character, &errorCode); + if (U_FAILURE(errorCode)) + return false; + if ((currentScript != nextScript) && (currentScript != USCRIPT_INHERITED)) + break; + } + unsigned numCharactersOfCurrentRun = iterator.currentCharacter() - startIndexOfCurrentRun; + m_harfbuzzRuns.append(HarfBuzzRun::create(currentFontData, startIndexOfCurrentRun, numCharactersOfCurrentRun, m_run.direction())); + currentFontData = nextFontData; + startIndexOfCurrentRun = iterator.currentCharacter(); + } while (iterator.consume(character, clusterLength)); + + return !m_harfbuzzRuns.isEmpty(); } -bool HarfBuzzShaper::shapeHarfBuzzRun() +bool HarfBuzzShaper::shapeHarfBuzzRuns(GlyphBuffer* glyphBuffer) { - FontPlatformData* platformData = const_cast<FontPlatformData*>(&m_currentFontData->platformData()); - HarfBuzzFace* face = platformData->harfbuzzFace(); - if (!face) - return false; - hb_font_t* harfbuzzFont = face->createFont(); - hb_shape(harfbuzzFont, m_harfbuzzBuffer, m_features.size() > 0 ? m_features.data() : 0, m_features.size()); - hb_font_destroy(harfbuzzFont); - m_harfbuzzRuns.append(HarfBuzzRun::create(m_numCharactersOfCurrentRun, m_run.direction(), m_harfbuzzBuffer)); + HarfBuzzScopedPtr<hb_buffer_t> harfbuzzBuffer(hb_buffer_create(), hb_buffer_destroy); + hb_buffer_set_unicode_funcs(harfbuzzBuffer.get(), hb_icu_get_unicode_funcs()); + if (m_run.directionalOverride()) + hb_buffer_set_direction(harfbuzzBuffer.get(), m_run.rtl() ? HB_DIRECTION_RTL : HB_DIRECTION_LTR); + + for (unsigned i = 0; i < m_harfbuzzRuns.size(); ++i) { + unsigned runIndex = m_run.rtl() ? m_harfbuzzRuns.size() - i - 1 : i; + HarfBuzzRun* currentRun = m_harfbuzzRuns[runIndex].get(); + const SimpleFontData* currentFontData = currentRun->fontData(); + + if (m_font->isSmallCaps() && u_islower(m_normalizedBuffer[currentRun->startIndex()])) { + String upperText = String(m_normalizedBuffer.get() + currentRun->startIndex(), currentRun->numCharacters()); + upperText.makeUpper(); + currentFontData = m_font->glyphDataForCharacter(upperText[0], false, SmallCapsVariant).fontData; + hb_buffer_add_utf16(harfbuzzBuffer.get(), upperText.characters(), currentRun->numCharacters(), 0, currentRun->numCharacters()); + } else + hb_buffer_add_utf16(harfbuzzBuffer.get(), m_normalizedBuffer.get() + currentRun->startIndex(), currentRun->numCharacters(), 0, currentRun->numCharacters()); + + FontPlatformData* platformData = const_cast<FontPlatformData*>(¤tFontData->platformData()); + HarfBuzzFace* face = platformData->harfbuzzFace(); + if (!face) + return false; + HarfBuzzScopedPtr<hb_font_t> harfbuzzFont(face->createFont(), hb_font_destroy); + hb_shape(harfbuzzFont.get(), harfbuzzBuffer.get(), m_features.isEmpty() ? 0 : m_features.data(), m_features.size()); + + currentRun->applyShapeResult(harfbuzzBuffer.get()); + setGlyphPositionsForHarfBuzzRun(currentRun, i, harfbuzzBuffer.get(), glyphBuffer); + + hb_buffer_reset(harfbuzzBuffer.get()); + if (m_run.directionalOverride()) + hb_buffer_set_direction(harfbuzzBuffer.get(), m_run.rtl() ? HB_DIRECTION_RTL : HB_DIRECTION_LTR); + } return true; } -void HarfBuzzShaper::setGlyphPositionsForHarfBuzzRun(GlyphBuffer* glyphBuffer) +void HarfBuzzShaper::setGlyphPositionsForHarfBuzzRun(HarfBuzzRun* currentRun, unsigned runIndexInVisualOrder, hb_buffer_t* harfbuzzBuffer, GlyphBuffer* glyphBuffer) { - hb_glyph_info_t* glyphInfos = hb_buffer_get_glyph_infos(m_harfbuzzBuffer, 0); - hb_glyph_position_t* glyphPositions = hb_buffer_get_glyph_positions(m_harfbuzzBuffer, 0); - HarfBuzzRun* currentRun = m_harfbuzzRuns.last().get(); + const SimpleFontData* currentFontData = currentRun->fontData(); + hb_glyph_info_t* glyphInfos = hb_buffer_get_glyph_infos(harfbuzzBuffer, 0); + hb_glyph_position_t* glyphPositions = hb_buffer_get_glyph_positions(harfbuzzBuffer, 0); unsigned numGlyphs = currentRun->numGlyphs(); float totalAdvance = 0; @@ -262,26 +308,29 @@ void HarfBuzzShaper::setGlyphPositionsForHarfBuzzRun(GlyphBuffer* glyphBuffer) nextOffsetX = runEnd ? 0 : harfbuzzPositionToFloat(glyphPositions[i + 1].x_offset); nextOffsetY = runEnd ? 0 : -harfbuzzPositionToFloat(glyphPositions[i + 1].y_offset); - unsigned currentCharacterIndex = m_startIndexOfCurrentRun + glyphInfos[i].cluster; + unsigned currentCharacterIndex = currentRun->startIndex() + glyphInfos[i].cluster; bool isClusterEnd = runEnd || glyphInfos[i].cluster != glyphInfos[i + 1].cluster; float spacing = isClusterEnd ? m_letterSpacing : 0; if (isClusterEnd && isWordEnd(currentCharacterIndex)) spacing += determineWordBreakSpacing(); - if (m_currentFontData->isZeroWidthSpaceGlyph(glyph)) { - currentRun->setGlyphAndPositions(i, glyph, 0, 0, 0); + if (currentFontData->isZeroWidthSpaceGlyph(glyph)) { + currentRun->setGlyphAndAdvance(i, glyph, 0); if (glyphBuffer) - glyphBuffer->add(glyph, m_currentFontData, createGlyphBufferAdvance(0, 0)); + glyphBuffer->add(glyph, currentFontData, createGlyphBufferAdvance(0, 0)); continue; } advance += spacing; - currentRun->setGlyphAndPositions(i, glyph, totalAdvance + offsetX, offsetY, advance); + + currentRun->setGlyphAndAdvance(i, glyph, advance); if (glyphBuffer) { + if (!i && !runIndexInVisualOrder) + m_startOffset.set(offsetX, offsetY); float glyphAdvanceX = advance + nextOffsetX - offsetX; float glyphAdvanceY = nextOffsetY - offsetY; - glyphBuffer->add(glyph, m_currentFontData, createGlyphBufferAdvance(glyphAdvanceX, glyphAdvanceY)); + glyphBuffer->add(glyph, currentFontData, createGlyphBufferAdvance(glyphAdvanceX, glyphAdvanceY)); } totalAdvance += advance; @@ -324,37 +373,46 @@ int HarfBuzzShaper::offsetForPosition(float targetX) FloatRect HarfBuzzShaper::selectionRect(const FloatPoint& point, int height, int from, int to) { - int fromX = -1, toX = -1; - int currentX = 0; - // Iterate through the script runs in logical order, searching for the run covering the positions of interest. + float currentX = 0; + float fromX; + float toX; + bool foundFromX = false; + bool foundToX = false; + + if (m_run.rtl()) + currentX = m_totalWidth; for (unsigned i = 0; i < m_harfbuzzRuns.size(); ++i) { + if (m_run.rtl()) + currentX -= m_harfbuzzRuns[i]->width(); int numCharacters = m_harfbuzzRuns[i]->numCharacters(); - if (fromX == -1 && from >= 0 && from < numCharacters) + if (!foundFromX && from >= 0 && from < numCharacters) { fromX = m_harfbuzzRuns[i]->xPositionForOffset(from) + currentX; - else + foundFromX = true; + } else from -= numCharacters; - if (toX == -1 && to >= 0 && to < numCharacters) + if (!foundToX && to >= 0 && to < numCharacters) { toX = m_harfbuzzRuns[i]->xPositionForOffset(to) + currentX; - else + foundToX = true; + } else to -= numCharacters; - if (fromX != -1 && toX != -1) + if (foundFromX && foundToX) break; - currentX += m_harfbuzzRuns[i]->width(); + if (!m_run.rtl()) + currentX += m_harfbuzzRuns[i]->width(); } // The position in question might be just after the text. - if (fromX == -1) + if (!foundFromX) fromX = 0; - if (toX == -1) + if (!foundToX) toX = m_run.rtl() ? 0 : m_totalWidth; - ASSERT(fromX != -1 && toX != -1); - + // Using floorf() and roundf() as the same as mac port. if (fromX < toX) - return FloatRect(point.x() + fromX, point.y(), toX - fromX, height); - return FloatRect(point.x() + toX, point.y(), fromX - toX, height); + return FloatRect(floorf(point.x() + fromX), point.y(), roundf(toX - fromX), height); + return FloatRect(floorf(point.x() + toX), point.y(), roundf(fromX - toX), height); } } // namespace WebCore diff --git a/Source/WebCore/platform/graphics/harfbuzz/ng/HarfBuzzShaper.h b/Source/WebCore/platform/graphics/harfbuzz/ng/HarfBuzzShaper.h index 7beff5d72..eb3935db1 100644 --- a/Source/WebCore/platform/graphics/harfbuzz/ng/HarfBuzzShaper.h +++ b/Source/WebCore/platform/graphics/harfbuzz/ng/HarfBuzzShaper.h @@ -52,6 +52,7 @@ public: virtual ~HarfBuzzShaper(); bool shape(GlyphBuffer* = 0); + FloatPoint adjustStartPoint(const FloatPoint&); float totalWidth() { return m_totalWidth; } int offsetForPosition(float targetX); FloatRect selectionRect(const FloatPoint&, int height, int from, int to); @@ -59,31 +60,37 @@ public: private: class HarfBuzzRun { public: - static PassOwnPtr<HarfBuzzRun> create(unsigned numCharacters, TextDirection direction, hb_buffer_t* buffer) + static PassOwnPtr<HarfBuzzRun> create(const SimpleFontData* fontData, unsigned startIndex, unsigned numCharacters, TextDirection direction) { - return adoptPtr(new HarfBuzzRun(numCharacters, direction, buffer)); + return adoptPtr(new HarfBuzzRun(fontData, startIndex, numCharacters, direction)); } - void setGlyphAndPositions(unsigned index, uint16_t glyphId, float x, float y, float); + void applyShapeResult(hb_buffer_t*); + void setGlyphAndAdvance(unsigned index, uint16_t glyphId, float advance); void setWidth(float width) { m_width = width; } int characterIndexForXPosition(int targetX); - int xPositionForOffset(unsigned offset); + float xPositionForOffset(unsigned offset); + const SimpleFontData* fontData() { return m_fontData; } + unsigned startIndex() const { return m_startIndex; } unsigned numCharacters() const { return m_numCharacters; } unsigned numGlyphs() const { return m_numGlyphs; } + uint16_t* glyphs() { return &m_glyphs[0]; } + float* advances() { return &m_advances[0]; } float width() { return m_width; } private: - HarfBuzzRun(unsigned numCharacters, TextDirection, hb_buffer_t*); + HarfBuzzRun(const SimpleFontData*, unsigned startIndex, unsigned numCharacters, TextDirection); bool rtl() { return m_direction == RTL; } + const SimpleFontData* m_fontData; + unsigned m_startIndex; size_t m_numCharacters; unsigned m_numGlyphs; TextDirection m_direction; Vector<uint16_t, 256> m_glyphs; Vector<float, 256> m_advances; - Vector<FloatPoint, 256> m_offsets; Vector<uint16_t, 256> m_logClusters; Vector<uint16_t, 256> m_glyphToCharacterIndex; float m_width; @@ -91,19 +98,17 @@ private: void setFontFeatures(); - bool setupHarfBuzzRun(); - bool shapeHarfBuzzRun(); - void setGlyphPositionsForHarfBuzzRun(GlyphBuffer*); + bool collectHarfBuzzRuns(); + bool shapeHarfBuzzRuns(GlyphBuffer*); + void setGlyphPositionsForHarfBuzzRun(HarfBuzzRun*, unsigned runIndexInVisualOrder, hb_buffer_t*, GlyphBuffer*); GlyphBufferAdvance createGlyphBufferAdvance(float, float); Vector<hb_feature_t, 4> m_features; - unsigned m_startIndexOfCurrentRun; - unsigned m_numCharactersOfCurrentRun; - const SimpleFontData* m_currentFontData; - hb_buffer_t* m_harfbuzzBuffer; Vector<OwnPtr<HarfBuzzRun>, 16> m_harfbuzzRuns; + FloatPoint m_startOffset; + float m_totalWidth; }; diff --git a/Source/WebCore/platform/graphics/mac/ComplexTextController.cpp b/Source/WebCore/platform/graphics/mac/ComplexTextController.cpp index a9324d37f..f09cb1303 100644 --- a/Source/WebCore/platform/graphics/mac/ComplexTextController.cpp +++ b/Source/WebCore/platform/graphics/mac/ComplexTextController.cpp @@ -33,7 +33,7 @@ #include <wtf/StdLibExtras.h> #include <wtf/unicode/CharacterNames.h> -#if defined(BUILDING_ON_LEOPARD) +#if (PLATFORM(MAC) || PLATFORM(CHROMIUM)) && !PLATFORM(IOS) && __MAC_OS_X_VERSION_MIN_REQUIRED == 1050 // Undefined when compiling agains the 10.5 SDK. #define kCTVersionNumber10_6 0x00030000 #endif diff --git a/Source/WebCore/platform/graphics/mac/ComplexTextControllerCoreText.mm b/Source/WebCore/platform/graphics/mac/ComplexTextControllerCoreText.mm index e5304533e..83173db61 100644 --- a/Source/WebCore/platform/graphics/mac/ComplexTextControllerCoreText.mm +++ b/Source/WebCore/platform/graphics/mac/ComplexTextControllerCoreText.mm @@ -39,7 +39,7 @@ #include <CoreText/CoreText.h> #endif -#if defined(BUILDING_ON_LEOPARD) +#if !PLATFORM(IOS) && __MAC_OS_X_VERSION_MIN_REQUIRED == 1050 // The following symbols are SPI in 10.5. extern "C" { void CTRunGetAdvances(CTRunRef run, CFRange range, CGSize buffer[]); @@ -218,7 +218,7 @@ void ComplexTextController::collectComplexTextRunsForCharactersCoreText(const UC static CFDictionaryRef ltrTypesetterOptions = CFDictionaryCreate(kCFAllocatorDefault, optionKeys, ltrOptionValues, WTF_ARRAY_LENGTH(optionKeys), &kCFCopyStringDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks); static CFDictionaryRef rtlTypesetterOptions = CFDictionaryCreate(kCFAllocatorDefault, optionKeys, rtlOptionValues, WTF_ARRAY_LENGTH(optionKeys), &kCFCopyStringDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks); -#if !defined(BUILDING_ON_LEOPARD) && !defined(BUILDING_ON_SNOW_LEOPARD) +#if PLATFORM(IOS) || __MAC_OS_X_VERSION_MIN_REQUIRED >= 1070 ProviderInfo info = { cp, length, stringAttributes.get() }; RetainPtr<CTTypesetterRef> typesetter(AdoptCF, wkCreateCTTypesetterWithUniCharProviderAndOptions(&provideStringAndAttributes, 0, &info, m_run.ltr() ? ltrTypesetterOptions : rtlTypesetterOptions)); #else diff --git a/Source/WebCore/platform/graphics/mac/FontCacheMac.mm b/Source/WebCore/platform/graphics/mac/FontCacheMac.mm index 91dd426fe..6b2e05474 100644 --- a/Source/WebCore/platform/graphics/mac/FontCacheMac.mm +++ b/Source/WebCore/platform/graphics/mac/FontCacheMac.mm @@ -52,7 +52,7 @@ static void invalidateFontCache(void*) fontCache()->invalidate(); } -#if !defined(BUILDING_ON_LEOPARD) +#if PLATFORM(IOS) || __MAC_OS_X_VERSION_MIN_REQUIRED >= 1060 static void fontCacheRegisteredFontsChangedNotificationCallback(CFNotificationCenterRef, void* observer, CFStringRef name, const void *, CFDictionaryRef) { ASSERT_UNUSED(observer, observer == fontCache()); @@ -69,7 +69,7 @@ static void fontCacheATSNotificationCallback(ATSFontNotificationInfoRef, void*) void FontCache::platformInit() { wkSetUpFontCache(); -#if !defined(BUILDING_ON_LEOPARD) +#if PLATFORM(IOS) || __MAC_OS_X_VERSION_MIN_REQUIRED >= 1060 CFNotificationCenterAddObserver(CFNotificationCenterGetLocalCenter(), this, fontCacheRegisteredFontsChangedNotificationCallback, kCTFontManagerRegisteredFontsChangedNotification, 0, CFNotificationSuspensionBehaviorDeliverImmediately); #else // kCTFontManagerRegisteredFontsChangedNotification does not exist on Leopard and earlier. diff --git a/Source/WebCore/platform/graphics/mac/FontCustomPlatformData.cpp b/Source/WebCore/platform/graphics/mac/FontCustomPlatformData.cpp index cfddf363f..d3d872153 100644 --- a/Source/WebCore/platform/graphics/mac/FontCustomPlatformData.cpp +++ b/Source/WebCore/platform/graphics/mac/FontCustomPlatformData.cpp @@ -78,7 +78,7 @@ private: FontCustomPlatformData::~FontCustomPlatformData() { -#ifdef BUILDING_ON_LEOPARD +#if !PLATFORM(IOS) && __MAC_OS_X_VERSION_MIN_REQUIRED == 1050 if (m_atsContainer) ATSFontDeactivate(m_atsContainer, NULL, kATSOptionFlagsDefault); #endif @@ -119,7 +119,7 @@ FontCustomPlatformData* createFontCustomPlatformData(SharedBuffer* buffer) RetainPtr<CGFontRef> cgFontRef; -#ifndef BUILDING_ON_LEOPARD +#if PLATFORM(IOS) || __MAC_OS_X_VERSION_MIN_REQUIRED >= 1060 RetainPtr<CFDataRef> bufferData(AdoptCF, buffer->createCFData()); RetainPtr<CGDataProviderRef> dataProvider(AdoptCF, CGDataProviderCreateWithCFData(bufferData.get())); @@ -157,7 +157,7 @@ FontCustomPlatformData* createFontCustomPlatformData(SharedBuffer* buffer) ATSFontDeactivate(containerRef, NULL, kATSOptionFlagsDefault); return 0; } -#endif // !defined(BUILDING_ON_LEOPARD) +#endif // PLATFORM(IOS) || __MAC_OS_X_VERSION_MIN_REQUIRED >= 1060 FontCustomPlatformData* fontCustomPlatformData = new FontCustomPlatformData(containerRef, cgFontRef.leakRef()); #if USE(SKIA_ON_MAC_CHROMIUM) diff --git a/Source/WebCore/platform/graphics/mac/FontMac.mm b/Source/WebCore/platform/graphics/mac/FontMac.mm index 4afb5fbdb..608123cbd 100644 --- a/Source/WebCore/platform/graphics/mac/FontMac.mm +++ b/Source/WebCore/platform/graphics/mac/FontMac.mm @@ -71,7 +71,7 @@ static bool hasBrokenCTFontGetVerticalTranslationsForGlyphs() isCached = true; } return result; -#elif defined(BUILDING_ON_SNOW_LEOPARD) +#elif !PLATFORM(IOS) && __MAC_OS_X_VERSION_MIN_REQUIRED == 1060 return true; #else return false; @@ -119,7 +119,7 @@ static void showGlyphsWithAdvances(const FloatPoint& point, const SimpleFontData } else CGContextShowGlyphsWithAdvances(context, glyphs, advances, count); } -#if !defined(BUILDING_ON_LEOPARD) && !defined(BUILDING_ON_SNOW_LEOPARD) +#if PLATFORM(IOS) || __MAC_OS_X_VERSION_MIN_REQUIRED >= 1070 else { if (!count) return; diff --git a/Source/WebCore/platform/graphics/mac/GraphicsContextMac.mm b/Source/WebCore/platform/graphics/mac/GraphicsContextMac.mm index e08591df4..e3d4f3346 100644 --- a/Source/WebCore/platform/graphics/mac/GraphicsContextMac.mm +++ b/Source/WebCore/platform/graphics/mac/GraphicsContextMac.mm @@ -129,7 +129,7 @@ void GraphicsContext::drawLineForDocumentMarker(const FloatPoint& point, float w patternColor = grammarPatternColor.get(); break; } -#if PLATFORM(MAC) && !defined(BUILDING_ON_LEOPARD) && !defined(BUILDING_ON_SNOW_LEOPARD) +#if PLATFORM(MAC) && (PLATFORM(IOS) || __MAC_OS_X_VERSION_MIN_REQUIRED >= 1070) // To support correction panel. case DocumentMarkerAutocorrectionReplacementLineStyle: case DocumentMarkerDictationAlternativesLineStyle: diff --git a/Source/WebCore/platform/graphics/mac/MediaPlayerPrivateQTKit.mm b/Source/WebCore/platform/graphics/mac/MediaPlayerPrivateQTKit.mm index cd161a3f2..2e849af61 100644 --- a/Source/WebCore/platform/graphics/mac/MediaPlayerPrivateQTKit.mm +++ b/Source/WebCore/platform/graphics/mac/MediaPlayerPrivateQTKit.mm @@ -267,7 +267,7 @@ void MediaPlayerPrivateQTKit::createQTMovie(const String& url) NSMutableDictionary *movieAttributes = commonMovieAttributes(); [movieAttributes setValue:cocoaURL forKey:QTMovieURLAttribute]; -#if !defined(BUILDING_ON_LEOPARD) +#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1060 CFDictionaryRef proxySettings = CFNetworkCopySystemProxySettings(); CFArrayRef proxiesForURL = CFNetworkCopyProxiesForURL((CFURLRef)cocoaURL, proxySettings); BOOL willUseProxy = YES; @@ -392,7 +392,7 @@ void MediaPlayerPrivateQTKit::createQTMovie(NSURL *url, NSDictionary *movieAttri selector:@selector(didEnd:) name:QTMovieDidEndNotification object:m_qtMovie.get()]; -#if defined(BUILDING_ON_SNOW_LEOPARD) +#if __MAC_OS_X_VERSION_MIN_REQUIRED == 1060 [[NSNotificationCenter defaultCenter] addObserver:m_objcObserver.get() selector:@selector(layerHostChanged:) name:@"WebKitLayerHostChanged" @@ -876,7 +876,7 @@ bool MediaPlayerPrivateQTKit::hasAudio() const bool MediaPlayerPrivateQTKit::supportsFullscreen() const { -#ifndef BUILDING_ON_LEOPARD +#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1060 return true; #else // See <rdar://problem/7389945> @@ -903,7 +903,7 @@ void MediaPlayerPrivateQTKit::setClosedCaptionsVisible(bool closedCaptionsVisibl if (metaDataAvailable()) { wkQTMovieSetShowClosedCaptions(m_qtMovie.get(), closedCaptionsVisible); -#if USE(ACCELERATED_COMPOSITING) && !defined(BUILDING_ON_LEOPARD) +#if USE(ACCELERATED_COMPOSITING) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 1060 if (closedCaptionsVisible && m_qtVideoLayer) { // Captions will be rendered upside down unless we flag the movie as flipped (again). See <rdar://7408440>. [m_qtVideoLayer.get() setGeometryFlipped:YES]; @@ -1001,7 +1001,7 @@ void MediaPlayerPrivateQTKit::cacheMovieScale() NSSize initialSize = NSZeroSize; NSSize naturalSize = [[m_qtMovie.get() attributeForKey:QTMovieNaturalSizeAttribute] sizeValue]; -#ifndef BUILDING_ON_LEOPARD +#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1060 // QTMovieCurrentSizeAttribute is not allowed with instances of QTMovie that have been // opened with QTMovieOpenForPlaybackAttribute, so ask for the display transform attribute instead. NSAffineTransform *displayTransform = [m_qtMovie.get() attributeForKey:@"QTMoviePreferredTransformAttribute"]; @@ -1236,7 +1236,7 @@ void MediaPlayerPrivateQTKit::didEnd() } #if USE(ACCELERATED_COMPOSITING) && !(PLATFORM(QT) && USE(QTKIT)) -#if defined(BUILDING_ON_SNOW_LEOPARD) +#if __MAC_OS_X_VERSION_MIN_REQUIRED == 1060 static bool layerIsDescendentOf(PlatformLayer* child, PlatformLayer* descendent) { if (!child || !descendent) @@ -1253,7 +1253,7 @@ static bool layerIsDescendentOf(PlatformLayer* child, PlatformLayer* descendent) void MediaPlayerPrivateQTKit::layerHostChanged(PlatformLayer* rootLayer) { -#if defined(BUILDING_ON_SNOW_LEOPARD) +#if __MAC_OS_X_VERSION_MIN_REQUIRED == 1060 if (!rootLayer) return; diff --git a/Source/WebCore/platform/graphics/mac/SimpleFontDataMac.mm b/Source/WebCore/platform/graphics/mac/SimpleFontDataMac.mm index d5d55606d..487591a74 100644 --- a/Source/WebCore/platform/graphics/mac/SimpleFontDataMac.mm +++ b/Source/WebCore/platform/graphics/mac/SimpleFontDataMac.mm @@ -82,7 +82,7 @@ static NSString *webFallbackFontFamily(void) } #if !ERROR_DISABLED -#if defined(__LP64__) || (!defined(BUILDING_ON_LEOPARD) && !defined(BUILDING_ON_SNOW_LEOPARD)) +#if defined(__LP64__) || PLATFORM(IOS) || __MAC_OS_X_VERSION_MIN_REQUIRED >= 1070 static NSString* pathFromFont(NSFont*) { // FMGetATSFontRefFromFont is not available. As pathFromFont is only used for debugging purposes, @@ -233,7 +233,7 @@ void SimpleFontData::platformInit() NSString *familyName = [m_platformData.font() familyName]; if ([familyName isEqualToString:@"Times"] || [familyName isEqualToString:@"Helvetica"] || [familyName isEqualToString:@"Courier"]) ascent += floorf(((ascent + descent) * 0.15f) + 0.5f); -#if defined(BUILDING_ON_LEOPARD) +#if !PLATFORM(IOS) && __MAC_OS_X_VERSION_MIN_REQUIRED == 1050 else if ([familyName isEqualToString:@"Geeza Pro"]) { // Geeza Pro has glyphs that draw slightly above the ascent or far below the descent. Adjust // those vertical metrics to better match reality, so that diacritics at the bottom of one line diff --git a/Source/WebCore/platform/graphics/mac/WebLayer.h b/Source/WebCore/platform/graphics/mac/WebLayer.h index bb0f444bc..1266bb749 100644 --- a/Source/WebCore/platform/graphics/mac/WebLayer.h +++ b/Source/WebCore/platform/graphics/mac/WebLayer.h @@ -36,7 +36,7 @@ namespace WebCore { class PlatformCALayerClient; } -#if defined(BUILDING_ON_LEOPARD) +#if !PLATFORM(IOS) && __MAC_OS_X_VERSION_MIN_REQUIRED == 1050 @interface CALayer(WebLayerInternal) - (CGAffineTransform)contentsTransform; - (void)setContentsTransform:(CGAffineTransform)t; diff --git a/Source/WebCore/platform/graphics/mac/WebLayer.mm b/Source/WebCore/platform/graphics/mac/WebLayer.mm index 97e9f2882..d783e494a 100644 --- a/Source/WebCore/platform/graphics/mac/WebLayer.mm +++ b/Source/WebCore/platform/graphics/mac/WebLayer.mm @@ -84,7 +84,7 @@ void drawLayerContents(CGContextRef context, CALayer *layer, WebCore::PlatformCA AffineTransform transform = CGContextGetCTM(context); ThemeMac::setFocusRingClipRect(transform.mapRect(clipBounds)); -#if !defined(BUILDING_ON_SNOW_LEOPARD) +#if PLATFORM(IOS) || __MAC_OS_X_VERSION_MIN_REQUIRED >= 1070 __block GraphicsContext* ctx = &graphicsContext; wkCALayerEnumerateRectsBeingDrawnWithBlock(layer, context, ^(CGRect rect){ diff --git a/Source/WebCore/platform/graphics/opengl/Extensions3DOpenGLCommon.cpp b/Source/WebCore/platform/graphics/opengl/Extensions3DOpenGLCommon.cpp index 57723560c..5a628810d 100644 --- a/Source/WebCore/platform/graphics/opengl/Extensions3DOpenGLCommon.cpp +++ b/Source/WebCore/platform/graphics/opengl/Extensions3DOpenGLCommon.cpp @@ -26,7 +26,7 @@ #include "config.h" -#if ENABLE(WEBGL) +#if USE(3D_GRAPHICS) #include "Extensions3DOpenGLCommon.h" #include "ANGLEWebKitBridge.h" @@ -145,4 +145,4 @@ void Extensions3DOpenGLCommon::initializeAvailableExtensions() } // namespace WebCore -#endif // ENABLE(WEBGL) +#endif // USE(3D_GRAPHICS) diff --git a/Source/WebCore/platform/graphics/opengl/Extensions3DOpenGLES.cpp b/Source/WebCore/platform/graphics/opengl/Extensions3DOpenGLES.cpp index e21f559ad..fed5492c6 100644 --- a/Source/WebCore/platform/graphics/opengl/Extensions3DOpenGLES.cpp +++ b/Source/WebCore/platform/graphics/opengl/Extensions3DOpenGLES.cpp @@ -25,10 +25,11 @@ */ #include "config.h" -#if ENABLE(WEBGL) +#if USE(3D_GRAPHICS) #include "Extensions3DOpenGLES.h" #include "GraphicsContext3D.h" +#include "NotImplemented.h" #include <EGL/egl.h> #include <wtf/Vector.h> @@ -68,6 +69,21 @@ void Extensions3DOpenGLES::renderbufferStorageMultisampleIMG(unsigned long targe m_context->synthesizeGLError(GL_INVALID_OPERATION); } +void Extensions3DOpenGLES::blitFramebuffer(long srcX0, long srcY0, long srcX1, long srcY1, long dstX0, long dstY0, long dstX1, long dstY1, unsigned long mask, unsigned long filter) +{ + notImplemented(); +} + +void Extensions3DOpenGLES::renderbufferStorageMultisample(unsigned long target, unsigned long samples, unsigned long internalformat, unsigned long width, unsigned long height) +{ + notImplemented(); +} + +void Extensions3DOpenGLES::copyTextureCHROMIUM(GC3Denum, Platform3DObject, Platform3DObject, GC3Dint, GC3Denum) +{ + notImplemented(); +} + Platform3DObject Extensions3DOpenGLES::createVertexArrayOES() { m_context->makeContextCurrent(); @@ -129,8 +145,8 @@ bool Extensions3DOpenGLES::supportsExtension(const String& name) m_glIsVertexArrayOES = reinterpret_cast<PFNGLISVERTEXARRAYOESPROC>(eglGetProcAddress("glIsVertexArrayOES")); m_supportsOESvertexArrayObject = true; } else if (name == "GL_IMG_multisampled_render_to_texture" && !m_supportsIMGMultisampledRenderToTexture) { - m_glFramebufferTexture2DMultisampleIMG = reinterpret_cast<PFNGLFRAMEBUFFERTEXTURE2DMULTISAMPLEIMGPROC>(eglGetProcAddress("glFramebufferTexture2DMultisampleIMG")); - m_glRenderbufferStorageMultisampleIMG = reinterpret_cast<PFNGLRENDERBUFFERSTORAGEMULTISAMPLEIMGPROC>(eglGetProcAddress("glRenderbufferStorageMultisampleIMG")); + m_glFramebufferTexture2DMultisampleIMG = reinterpret_cast<PFNGLFRAMEBUFFERTEXTURE2DMULTISAMPLEIMG>(eglGetProcAddress("glFramebufferTexture2DMultisampleIMG")); + m_glRenderbufferStorageMultisampleIMG = reinterpret_cast<PFNGLRENDERBUFFERSTORAGEMULTISAMPLEIMG>(eglGetProcAddress("glRenderbufferStorageMultisampleIMG")); m_supportsIMGMultisampledRenderToTexture = true; } return true; @@ -146,4 +162,4 @@ String Extensions3DOpenGLES::getExtensions() } // namespace WebCore -#endif // ENABLE(WEBGL) +#endif // USE(3D_GRAPHICS) diff --git a/Source/WebCore/platform/graphics/opengl/Extensions3DOpenGLES.h b/Source/WebCore/platform/graphics/opengl/Extensions3DOpenGLES.h index 3c460f9e2..c3cc59571 100644 --- a/Source/WebCore/platform/graphics/opengl/Extensions3DOpenGLES.h +++ b/Source/WebCore/platform/graphics/opengl/Extensions3DOpenGLES.h @@ -41,6 +41,11 @@ public: virtual void framebufferTexture2DMultisampleIMG(unsigned long target, unsigned long attachment, unsigned long textarget, unsigned int texture, int level, unsigned long samples); virtual void renderbufferStorageMultisampleIMG(unsigned long target, unsigned long samples, unsigned long internalformat, unsigned long width, unsigned long height); + // Extension3D methods + virtual void blitFramebuffer(long srcX0, long srcY0, long srcX1, long srcY1, long dstX0, long dstY0, long dstX1, long dstY1, unsigned long mask, unsigned long filter); + virtual void renderbufferStorageMultisample(unsigned long target, unsigned long samples, unsigned long internalformat, unsigned long width, unsigned long height); + virtual void copyTextureCHROMIUM(GC3Denum, Platform3DObject, Platform3DObject, GC3Dint, GC3Denum); + virtual Platform3DObject createVertexArrayOES(); virtual void deleteVertexArrayOES(Platform3DObject); virtual GC3Dboolean isVertexArrayOES(Platform3DObject); @@ -57,8 +62,8 @@ protected: bool m_supportsOESvertexArrayObject; bool m_supportsIMGMultisampledRenderToTexture; - PFNGLFRAMEBUFFERTEXTURE2DMULTISAMPLEIMGPROC m_glFramebufferTexture2DMultisampleIMG; - PFNGLRENDERBUFFERSTORAGEMULTISAMPLEIMGPROC m_glRenderbufferStorageMultisampleIMG; + PFNGLFRAMEBUFFERTEXTURE2DMULTISAMPLEIMG m_glFramebufferTexture2DMultisampleIMG; + PFNGLRENDERBUFFERSTORAGEMULTISAMPLEIMG m_glRenderbufferStorageMultisampleIMG; PFNGLBINDVERTEXARRAYOESPROC m_glBindVertexArrayOES; PFNGLDELETEVERTEXARRAYSOESPROC m_glDeleteVertexArraysOES; PFNGLGENVERTEXARRAYSOESPROC m_glGenVertexArraysOES; diff --git a/Source/WebCore/platform/graphics/opengl/GraphicsContext3DOpenGL.cpp b/Source/WebCore/platform/graphics/opengl/GraphicsContext3DOpenGL.cpp index 6753444f8..fd450141c 100644 --- a/Source/WebCore/platform/graphics/opengl/GraphicsContext3DOpenGL.cpp +++ b/Source/WebCore/platform/graphics/opengl/GraphicsContext3DOpenGL.cpp @@ -284,7 +284,7 @@ void GraphicsContext3D::clearDepth(GC3Dclampf depth) bool GraphicsContext3D::systemAllowsMultisamplingOnATICards() const { #if PLATFORM(MAC) -#if !defined(BUILDING_ON_SNOW_LEOPARD) && !defined(BUILDING_ON_LION) +#if PLATFORM(IOS) || __MAC_OS_X_VERSION_MIN_REQUIRED >= 1080 return true; #else ASSERT(isMainThread()); diff --git a/Source/WebCore/platform/graphics/opengl/GraphicsContext3DOpenGLES.cpp b/Source/WebCore/platform/graphics/opengl/GraphicsContext3DOpenGLES.cpp index e4ac6876e..26281909b 100644 --- a/Source/WebCore/platform/graphics/opengl/GraphicsContext3DOpenGLES.cpp +++ b/Source/WebCore/platform/graphics/opengl/GraphicsContext3DOpenGLES.cpp @@ -34,7 +34,9 @@ #include "Extensions3DOpenGLES.h" #include "IntRect.h" #include "IntSize.h" +#if PLATFORM(BLACKBERRY) #include "LayerWebKitThread.h" +#endif #include "NotImplemented.h" #include "OpenGLESShims.h" @@ -113,6 +115,75 @@ void GraphicsContext3D::readPixelsAndConvertToBGRAIfNecessary(int x, int y, int } } +bool GraphicsContext3D::reshapeFBOs(const IntSize& size) +{ + const int width = size.width(); + const int height = size.height(); + GLuint colorFormat = 0, pixelDataType = 0; + if (m_attrs.alpha) { + m_internalColorFormat = GL_RGBA; + colorFormat = GL_RGBA; + pixelDataType = GL_UNSIGNED_BYTE; + } else { + m_internalColorFormat = GL_RGB; + colorFormat = GL_RGB; + pixelDataType = GL_UNSIGNED_SHORT_5_6_5; + } + + // We don't allow the logic where stencil is required and depth is not. + // See GraphicsContext3D::validateAttributes. + bool supportPackedDepthStencilBuffer = (m_attrs.stencil || m_attrs.depth) && getExtensions()->supports("GL_OES_packed_depth_stencil"); + + // Resize regular FBO. + bool mustRestoreFBO = false; + if (m_boundFBO != m_fbo) { + mustRestoreFBO = true; + ::glBindFramebufferEXT(GraphicsContext3D::FRAMEBUFFER, m_fbo); + } + + ::glBindTexture(GL_TEXTURE_2D, m_texture); + ::glTexImage2D(GL_TEXTURE_2D, 0, m_internalColorFormat, width, height, 0, colorFormat, pixelDataType, 0); + ::glFramebufferTexture2DEXT(GraphicsContext3D::FRAMEBUFFER, GraphicsContext3D::COLOR_ATTACHMENT0, GL_TEXTURE_2D, m_texture, 0); + + ::glBindTexture(GL_TEXTURE_2D, m_compositorTexture); + ::glTexImage2D(GL_TEXTURE_2D, 0, m_internalColorFormat, width, height, 0, colorFormat, GL_UNSIGNED_BYTE, 0); + ::glBindTexture(GL_TEXTURE_2D, 0); + + // We don't support antialiasing yet. See GraphicsContext3D::validateAttributes. + ASSERT(!m_attrs.antialias); + + if (m_attrs.stencil || m_attrs.depth) { + // Use a 24 bit depth buffer where we know we have it. + if (supportPackedDepthStencilBuffer) { + ::glBindTexture(GL_TEXTURE_2D, m_depthStencilBuffer); + ::glTexImage2D(GL_TEXTURE_2D, 0, GraphicsContext3D::DEPTH_STENCIL, width, height, 0, GraphicsContext3D::DEPTH_STENCIL, GraphicsContext3D::UNSIGNED_INT_24_8, 0); + if (m_attrs.stencil) + ::glFramebufferTexture2D(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_TEXTURE_2D, m_depthStencilBuffer, 0); + if (m_attrs.depth) + ::glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, m_depthStencilBuffer, 0); + ::glBindTexture(GL_TEXTURE_2D, 0); + } else { + if (m_attrs.stencil) { + ::glBindRenderbufferEXT(GraphicsContext3D::RENDERBUFFER, m_stencilBuffer); + ::glRenderbufferStorageEXT(GraphicsContext3D::RENDERBUFFER, GL_STENCIL_INDEX8, width, height); + ::glFramebufferRenderbufferEXT(GraphicsContext3D::FRAMEBUFFER, GraphicsContext3D::STENCIL_ATTACHMENT, GraphicsContext3D::RENDERBUFFER, m_stencilBuffer); + } + if (m_attrs.depth) { + ::glBindRenderbufferEXT(GraphicsContext3D::RENDERBUFFER, m_depthBuffer); + ::glRenderbufferStorageEXT(GraphicsContext3D::RENDERBUFFER, GL_DEPTH_COMPONENT16, width, height); + ::glFramebufferRenderbufferEXT(GraphicsContext3D::FRAMEBUFFER, GraphicsContext3D::DEPTH_ATTACHMENT, GraphicsContext3D::RENDERBUFFER, m_depthBuffer); + } + ::glBindRenderbufferEXT(GraphicsContext3D::RENDERBUFFER, 0); + } + } + if (glCheckFramebufferStatusEXT(GraphicsContext3D::FRAMEBUFFER) != GraphicsContext3D::FRAMEBUFFER_COMPLETE) { + // FIXME: cleanup + notImplemented(); + } + + return mustRestoreFBO; +} + void GraphicsContext3D::resolveMultisamplingIfNecessary(const IntRect& rect) { // FIXME: We don't support antialiasing yet. diff --git a/Source/WebCore/platform/graphics/qt/GraphicsContext3DQt.cpp b/Source/WebCore/platform/graphics/qt/GraphicsContext3DQt.cpp index c7191e35b..84729d992 100644 --- a/Source/WebCore/platform/graphics/qt/GraphicsContext3DQt.cpp +++ b/Source/WebCore/platform/graphics/qt/GraphicsContext3DQt.cpp @@ -19,7 +19,11 @@ #include "config.h" #include "GraphicsContext3D.h" +#if USE(OPENGL_ES_2) +#include "Extensions3DOpenGLES.h" +#else #include "Extensions3DOpenGL.h" +#endif #include "GraphicsContext.h" #include "GraphicsSurface.h" #include "HostWindow.h" diff --git a/Source/WebCore/platform/graphics/skia/FontCustomPlatformData.cpp b/Source/WebCore/platform/graphics/skia/FontCustomPlatformData.cpp index 1ce1efc08..e7e8fc909 100644 --- a/Source/WebCore/platform/graphics/skia/FontCustomPlatformData.cpp +++ b/Source/WebCore/platform/graphics/skia/FontCustomPlatformData.cpp @@ -34,7 +34,6 @@ #include "FontCustomPlatformData.h" #if OS(WINDOWS) -#include "Base64.h" #include "OpenTypeUtilities.h" #include "PlatformSupport.h" #elif OS(UNIX) @@ -48,6 +47,7 @@ #if OS(WINDOWS) #include <objbase.h> +#include <wtf/text/Base64.h> #elif OS(UNIX) #include <cstring> #endif diff --git a/Source/WebCore/platform/graphics/skia/ImageBufferSkia.cpp b/Source/WebCore/platform/graphics/skia/ImageBufferSkia.cpp index ac3d929bc..b5490c656 100644 --- a/Source/WebCore/platform/graphics/skia/ImageBufferSkia.cpp +++ b/Source/WebCore/platform/graphics/skia/ImageBufferSkia.cpp @@ -33,7 +33,6 @@ #include "config.h" #include "ImageBuffer.h" -#include "Base64.h" #include "BitmapImage.h" #include "BitmapImageSingleFrameSkia.h" #include "Extensions3D.h" @@ -56,6 +55,7 @@ #include "Canvas2DLayerBridge.h" #endif +#include <wtf/text/Base64.h> #include <wtf/text/WTFString.h> using namespace std; diff --git a/Source/WebCore/platform/graphics/skia/SimpleFontDataSkia.cpp b/Source/WebCore/platform/graphics/skia/SimpleFontDataSkia.cpp index b4d20b03a..54486c3aa 100644 --- a/Source/WebCore/platform/graphics/skia/SimpleFontDataSkia.cpp +++ b/Source/WebCore/platform/graphics/skia/SimpleFontDataSkia.cpp @@ -86,7 +86,7 @@ void SimpleFontData::platformInit() float descent; // Beware those who step here: This code is designed to match Win32 font - // metrics *exactly*. + // metrics *exactly* (except the adjustment of ascent/descent on Linux/Android). if (isVDMXValid) { ascent = vdmxAscent; descent = -vdmxDescent; @@ -94,6 +94,16 @@ void SimpleFontData::platformInit() SkScalar height = -metrics.fAscent + metrics.fDescent + metrics.fLeading; ascent = SkScalarRound(-metrics.fAscent); descent = SkScalarRound(height) - ascent; +#if OS(LINUX) || OS(ANDROID) + // When subpixel positioning is enabled, if the descent is rounded down, the descent part + // of the glyph may be truncated when displayed in a 'overflow: hidden' container. + // To avoid that, borrow 1 unit from the ascent when possible. + // FIXME: This can be removed if sub-pixel ascent/descent is supported. + if (platformData().fontRenderStyle().useSubpixelPositioning && descent < SkScalarToFloat(metrics.fDescent) && ascent >= 1) { + ++descent; + --ascent; + } +#endif } m_fontMetrics.setAscent(ascent); diff --git a/Source/WebCore/platform/graphics/surfaces/GraphicsSurface.cpp b/Source/WebCore/platform/graphics/surfaces/GraphicsSurface.cpp index 018a89c9b..2b8cd6591 100644 --- a/Source/WebCore/platform/graphics/surfaces/GraphicsSurface.cpp +++ b/Source/WebCore/platform/graphics/surfaces/GraphicsSurface.cpp @@ -27,18 +27,12 @@ namespace WebCore { PassRefPtr<GraphicsSurface> GraphicsSurface::create(const IntSize& size, Flags flags, uint32_t token) { - RefPtr<GraphicsSurface> surface = adoptRef(new GraphicsSurface(size, flags)); - if (!surface->platformImport(token)) - return PassRefPtr<GraphicsSurface>(); - return surface; + return platformImport(size, flags, token); } PassRefPtr<GraphicsSurface> GraphicsSurface::create(const IntSize& size, GraphicsSurface::Flags flags) { - RefPtr<GraphicsSurface> surface = adoptRef(new GraphicsSurface(size, flags)); - if (!surface->platformCreate(size, flags)) - return PassRefPtr<GraphicsSurface>(); - return surface; + return platformCreate(size, flags); } uint32_t GraphicsSurface::exportToken() @@ -70,13 +64,19 @@ void GraphicsSurface::copyFromFramebuffer(uint32_t fbo, const IntRect& sourceRec } GraphicsSurface::GraphicsSurface(const IntSize& size, Flags flags) - : m_size(size) - , m_flags(flags) + : m_flags(flags) + , m_size(size) , m_platformSurface(0) , m_texture(0) , m_fbo(0) + , m_private(0) { } +GraphicsSurface::~GraphicsSurface() +{ + platformDestroy(); +} + } #endif diff --git a/Source/WebCore/platform/graphics/surfaces/GraphicsSurface.h b/Source/WebCore/platform/graphics/surfaces/GraphicsSurface.h index ff71fcd8c..7aeed792c 100644 --- a/Source/WebCore/platform/graphics/surfaces/GraphicsSurface.h +++ b/Source/WebCore/platform/graphics/surfaces/GraphicsSurface.h @@ -32,10 +32,14 @@ #if OS(DARWIN) typedef struct __IOSurface* IOSurfaceRef; typedef IOSurfaceRef PlatformGraphicsSurface; +#else +typedef uint32_t PlatformGraphicsSurface; #endif namespace WebCore { +struct GraphicsSurfacePrivate; + class GraphicsSurface : public RefCounted<GraphicsSurface> { public: enum Flag { @@ -69,10 +73,11 @@ public: uint32_t getTextureID(); PassOwnPtr<GraphicsContext> beginPaint(const IntRect&, LockOptions); PassRefPtr<Image> createReadOnlyImage(const IntRect&); + ~GraphicsSurface(); protected: - bool platformCreate(const IntSize&, Flags); - bool platformImport(uint32_t); + static PassRefPtr<GraphicsSurface> platformCreate(const IntSize&, Flags); + static PassRefPtr<GraphicsSurface> platformImport(const IntSize&, Flags, uint32_t); uint32_t platformExport(); void platformDestroy(); @@ -100,6 +105,7 @@ private: PlatformGraphicsSurface m_platformSurface; uint32_t m_texture; uint32_t m_fbo; + GraphicsSurfacePrivate* m_private; }; } diff --git a/Source/WebCore/platform/graphics/surfaces/mac/GraphicsSurfaceMac.cpp b/Source/WebCore/platform/graphics/surfaces/mac/GraphicsSurfaceMac.cpp index 84312def2..7131b8276 100644 --- a/Source/WebCore/platform/graphics/surfaces/mac/GraphicsSurfaceMac.cpp +++ b/Source/WebCore/platform/graphics/surfaces/mac/GraphicsSurfaceMac.cpp @@ -30,6 +30,8 @@ namespace WebCore { +struct GraphicsSurfacePrivate { }; + uint32_t GraphicsSurface::platformExport() { return IOSurfaceGetID(m_platformSurface); @@ -118,7 +120,7 @@ void GraphicsSurface::platformCopyFromFramebuffer(uint32_t originFbo, const IntR glFlush(); } -bool GraphicsSurface::platformCreate(const IntSize& size, Flags flags) +PassRefPtr<GraphicsSurface> GraphicsSurface::platformCreate(const IntSize& size, Flags flags) { unsigned pixelFormat = 'BGRA'; unsigned bytesPerElement = 4; @@ -154,14 +156,20 @@ bool GraphicsSurface::platformCreate(const IntSize& size, Flags flags) for (unsigned i = 0; i < 7; i++) CFRelease(values[i]); - m_platformSurface = IOSurfaceCreate(dict); - return !!m_platformSurface; + RefPtr<GraphicsSurface> surface = adoptRef(new GraphicsSurface(size, flags)); + surface->m_platformSurface = IOSurfaceCreate(dict); + if (!surface->m_platformSurface) + return PassRefPtr<GraphicsSurface>(); + return surface; } -bool GraphicsSurface::platformImport(uint32_t token) +PassRefPtr<GraphicsSurface> GraphicsSurface::platformImport(const IntSize& size, Flags flags, uint32_t token) { - m_platformSurface = IOSurfaceLookup(token); - return !!m_platformSurface; + RefPtr<GraphicsSurface> surface = adoptRef(new GraphicsSurface(size, flags)); + surface->m_platformSurface = IOSurfaceLookup(token); + if (!surface->m_platformSurface) + return PassRefPtr<GraphicsSurface>(); + return surface; } static int ioSurfaceLockOptions(int lockOptions) diff --git a/Source/WebCore/platform/graphics/surfaces/qt/GraphicsSurfaceGLX.cpp b/Source/WebCore/platform/graphics/surfaces/qt/GraphicsSurfaceGLX.cpp new file mode 100644 index 000000000..afc3a84f2 --- /dev/null +++ b/Source/WebCore/platform/graphics/surfaces/qt/GraphicsSurfaceGLX.cpp @@ -0,0 +1,330 @@ +/* + Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies) + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. + */ + +#include "config.h" +#include "GraphicsSurface.h" + +#if USE(GRAPHICS_SURFACE) + +// Qt headers must be included before glx headers. +#include <QCoreApplication> +#include <QOpenGLContext> +#include <QVector> +#include <QWindow> +#include <qpa/qplatformwindow.h> +#include <GL/glext.h> +#include <GL/glx.h> +#include <X11/extensions/Xcomposite.h> +#include <X11/extensions/Xrender.h> + +namespace WebCore { + +static long X11OverrideRedirect = 1L << 9; + +static PFNGLXBINDTEXIMAGEEXTPROC pGlXBindTexImageEXT = 0; +static PFNGLXRELEASETEXIMAGEEXTPROC pGlXReleaseTexImageEXT = 0; +static PFNGLBINDFRAMEBUFFERPROC pGlBindFramebuffer = 0; +static PFNGLBLITFRAMEBUFFERPROC pGlBlitFramebuffer = 0; + +class OffScreenRootWindow { +public: + OffScreenRootWindow() + { + ++refCount; + } + + QWindow* get(Display* dpy) + { + if (!window) { + window = new QWindow; + window->setGeometry(QRect(-1, -1, 1, 1)); + window->create(); + XSetWindowAttributes attributes; + attributes.override_redirect = true; + XChangeWindowAttributes(dpy, window->handle()->winId(), X11OverrideRedirect, &attributes); + window->show(); + } + return window; + } + + ~OffScreenRootWindow() + { + if (!--refCount) { + delete window; + window = 0; + } + } + +private: + static int refCount; + static QWindow* window; +}; + +int OffScreenRootWindow::refCount = 0; +QWindow* OffScreenRootWindow::window = 0; + +static const int glxSpec[] = { + // The specification is a set key value pairs stored in a simple array. + GLX_LEVEL, 0, + GLX_DRAWABLE_TYPE, GLX_PIXMAP_BIT | GLX_WINDOW_BIT, + GLX_BIND_TO_TEXTURE_TARGETS_EXT, GLX_TEXTURE_2D_BIT_EXT, + GLX_BIND_TO_TEXTURE_RGB_EXT, TRUE, + 0 +}; + +static const int glxAttributes[] = { + GLX_TEXTURE_FORMAT_EXT, + GLX_TEXTURE_FORMAT_RGB_EXT, + GLX_TEXTURE_TARGET_EXT, + GLX_TEXTURE_2D_EXT, + 0 +}; + +struct GraphicsSurfacePrivate { + GraphicsSurfacePrivate() + : m_display(0) + , m_xPixmap(0) + , m_glxPixmap(0) + , m_glContext(adoptPtr(new QOpenGLContext)) + , m_textureIsYInverted(false) + , m_hasAlpha(false) + { + m_display = XOpenDisplay(0); + m_glContext->create(); + } + + ~GraphicsSurfacePrivate() + { + if (m_glxPixmap) + glXDestroyPixmap(m_display, m_glxPixmap); + m_glxPixmap = 0; + + if (m_xPixmap) + XFreePixmap(m_display, m_xPixmap); + m_xPixmap = 0; + + if (m_display) + XCloseDisplay(m_display); + m_display = 0; + } + + uint32_t createSurface(const IntSize& size) + { + m_surface = adoptPtr(new QWindow(m_offScreenWindow.get(m_display))); + m_surface->setSurfaceType(QSurface::OpenGLSurface); + m_surface->setGeometry(0, 0, size.width(), size.height()); + m_surface->create(); + XCompositeRedirectWindow(m_display, m_surface->handle()->winId(), CompositeRedirectManual); + + // Make sure the XRender Extension is available. + int eventBasep, errorBasep; + if (!XRenderQueryExtension(m_display, &eventBasep, &errorBasep)) + return 0; + + m_surface->show(); + + return m_surface->handle()->winId(); + } + + void createPixmap(uint32_t winId) + { + XWindowAttributes attr; + XGetWindowAttributes(m_display, winId, &attr); + + XRenderPictFormat* format = XRenderFindVisualFormat(m_display, attr.visual); + m_hasAlpha = (format->type == PictTypeDirect && format->direct.alphaMask); + m_size = IntSize(attr.width, attr.height); + + int numberOfConfigs; + GLXFBConfig* configs = glXChooseFBConfig(m_display, XDefaultScreen(m_display), glxSpec, &numberOfConfigs); + + m_xPixmap = XCompositeNameWindowPixmap(m_display, winId); + m_glxPixmap = glXCreatePixmap(m_display, *configs, m_xPixmap, glxAttributes); + + uint inverted = 0; + glXQueryDrawable(m_display, m_glxPixmap, GLX_Y_INVERTED_EXT, &inverted); + m_textureIsYInverted = !!inverted; + + XFree(configs); + } + + void makeCurrent() + { + QOpenGLContext* glContext = QOpenGLContext::currentContext(); + if (m_surface && glContext) + glContext->makeCurrent(m_surface.get()); + } + + void swapBuffers() + { + if (!m_surface->isVisible()) + return; + + // Creating and exposing the surface is asynchronous. Therefore we have to wait here + // before swapping the buffers. This should only be the case for the very first frame. + while (!m_surface->isExposed()) + QCoreApplication::processEvents(); + + QOpenGLContext* glContext = QOpenGLContext::currentContext(); + if (m_surface && glContext) + glContext->swapBuffers(m_surface.get()); + } + + + Display* display() const { return m_display; } + + GLXPixmap glxPixmap() const { return m_glxPixmap; } + + IntSize size() const { return m_size; } + + QOpenGLContext* glContext() { return m_glContext.get(); } + +private: + OffScreenRootWindow m_offScreenWindow; + IntSize m_size; + Display* m_display; + Pixmap m_xPixmap; + GLXPixmap m_glxPixmap; + OwnPtr<QWindow> m_surface; + OwnPtr<QOpenGLContext> m_glContext; + bool m_textureIsYInverted; + bool m_hasAlpha; +}; + +static bool resolveGLMethods(GraphicsSurfacePrivate* p) +{ + static bool resolved = false; + if (resolved) + return true; + + QOpenGLContext* glContext = p->glContext(); + pGlXBindTexImageEXT = reinterpret_cast<PFNGLXBINDTEXIMAGEEXTPROC>(glContext->getProcAddress("glXBindTexImageEXT")); + pGlXReleaseTexImageEXT = reinterpret_cast<PFNGLXRELEASETEXIMAGEEXTPROC>(glContext->getProcAddress("glXReleaseTexImageEXT")); + pGlBindFramebuffer = reinterpret_cast<PFNGLBINDFRAMEBUFFERPROC>(glContext->getProcAddress("glBindFramebuffer")); + pGlBlitFramebuffer = reinterpret_cast<PFNGLBLITFRAMEBUFFERPROC>(glContext->getProcAddress("glBlitFramebuffer")); + + resolved = pGlBlitFramebuffer && pGlBindFramebuffer && pGlXBindTexImageEXT && pGlXReleaseTexImageEXT; + + return resolved; +} + +uint32_t GraphicsSurface::platformExport() +{ + return m_platformSurface; +} + +uint32_t GraphicsSurface::platformGetTextureID() +{ + if (!m_texture) + glGenTextures(1, &m_texture); + + glBindTexture(GL_TEXTURE_2D, m_texture); + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); + pGlXBindTexImageEXT(m_private->display(), m_private->glxPixmap(), GLX_FRONT_EXT, 0); + + return m_texture; +} + +void GraphicsSurface::platformCopyToGLTexture(uint32_t target, uint32_t id, const IntRect& targetRect, const IntPoint& offset) +{ + // This is not supported by GLX/Xcomposite. +} + +void GraphicsSurface::platformCopyFromFramebuffer(uint32_t originFbo, const IntRect& sourceRect) +{ + m_private->makeCurrent(); + int width = m_size.width(); + int height = m_size.height(); + + glPushAttrib(GL_ALL_ATTRIB_BITS); + GLint oldFBO; + glGetIntegerv(GL_FRAMEBUFFER_BINDING, &oldFBO); + pGlBindFramebuffer(GL_READ_FRAMEBUFFER, originFbo); + pGlBindFramebuffer(GL_DRAW_FRAMEBUFFER, m_private->glContext()->defaultFramebufferObject()); + pGlBlitFramebuffer(0, 0, width, height, 0, 0, width, height, GL_COLOR_BUFFER_BIT, GL_LINEAR); + pGlBindFramebuffer(GL_FRAMEBUFFER, oldFBO); + glPopAttrib(); + + m_private->swapBuffers(); +} + +PassRefPtr<GraphicsSurface> GraphicsSurface::platformCreate(const IntSize& size, Flags flags) +{ + // X11 does not support CopyToTexture, so we do not create a GraphicsSurface if this is requested. + if (flags & SupportsCopyToTexture) + return PassRefPtr<GraphicsSurface>(); + + RefPtr<GraphicsSurface> surface = adoptRef(new GraphicsSurface(size, flags)); + + surface->m_private = new GraphicsSurfacePrivate(); + if (!resolveGLMethods(surface->m_private)) + return PassRefPtr<GraphicsSurface>(); + + surface->m_platformSurface = surface->m_private->createSurface(size); + + return surface; +} + +PassRefPtr<GraphicsSurface> GraphicsSurface::platformImport(const IntSize& size, Flags flags, uint32_t token) +{ + // X11 does not support CopyToTexture, so we do not create a GraphicsSurface if this is requested. + if (flags & SupportsCopyToTexture) + return PassRefPtr<GraphicsSurface>(); + + RefPtr<GraphicsSurface> surface = adoptRef(new GraphicsSurface(size, flags)); + + surface->m_private = new GraphicsSurfacePrivate(); + if (!resolveGLMethods(surface->m_private)) + return PassRefPtr<GraphicsSurface>(); + + surface->m_platformSurface = token; + + surface->m_private->createPixmap(surface->m_platformSurface); + surface->m_size = surface->m_private->size(); + + return surface; +} + +char* GraphicsSurface::platformLock(const IntRect& rect, int* outputStride, LockOptions lockOptions) +{ + // GraphicsSurface is currently only being used for WebGL, which does not require this locking mechanism. + return 0; +} + +void GraphicsSurface::platformUnlock() +{ + // GraphicsSurface is currently only being used for WebGL, which does not require this locking mechanism. +} + +void GraphicsSurface::platformDestroy() +{ + if (m_texture) { + pGlXReleaseTexImageEXT(m_private->display(), m_private->glxPixmap(), GLX_FRONT_EXT); + glDeleteTextures(1, &m_texture); + } + + delete m_private; + m_private = 0; +} + +} +#endif diff --git a/Source/WebCore/platform/graphics/texmap/GraphicsLayerTextureMapper.cpp b/Source/WebCore/platform/graphics/texmap/GraphicsLayerTextureMapper.cpp index 4ca56c6c1..2802933a9 100644 --- a/Source/WebCore/platform/graphics/texmap/GraphicsLayerTextureMapper.cpp +++ b/Source/WebCore/platform/graphics/texmap/GraphicsLayerTextureMapper.cpp @@ -368,7 +368,7 @@ bool GraphicsLayerTextureMapper::addAnimation(const KeyframeValueList& valueList if (valueList.property() == AnimatedPropertyWebkitTransform) listsMatch = validateTransformOperations(valueList, hasBigRotation) >= 0; - m_animations.add(keyframesName, TextureMapperAnimation(valueList, boxSize, anim, timeOffset, listsMatch)); + m_animations.add(keyframesName, GraphicsLayerAnimation(valueList, boxSize, anim, timeOffset, listsMatch)); notifyChange(TextureMapperLayer::AnimationChange); m_animationStartedTimer.startOneShot(0); return true; diff --git a/Source/WebCore/platform/graphics/texmap/GraphicsLayerTextureMapper.h b/Source/WebCore/platform/graphics/texmap/GraphicsLayerTextureMapper.h index 403e5492b..c5cbbac04 100644 --- a/Source/WebCore/platform/graphics/texmap/GraphicsLayerTextureMapper.h +++ b/Source/WebCore/platform/graphics/texmap/GraphicsLayerTextureMapper.h @@ -106,7 +106,7 @@ private: bool m_fixedToViewport; TextureMapperPlatformLayer* m_contentsLayer; FloatRect m_needsDisplayRect; - TextureMapperAnimations m_animations; + GraphicsLayerAnimations m_animations; void animationStartedTimerFired(Timer<GraphicsLayerTextureMapper>*); Timer<GraphicsLayerTextureMapper> m_animationStartedTimer; }; diff --git a/Source/WebCore/platform/graphics/texmap/TextureMapperLayer.h b/Source/WebCore/platform/graphics/texmap/TextureMapperLayer.h index de2d67f73..45042ca8d 100644 --- a/Source/WebCore/platform/graphics/texmap/TextureMapperLayer.h +++ b/Source/WebCore/platform/graphics/texmap/TextureMapperLayer.h @@ -24,11 +24,11 @@ #include "FloatRect.h" #include "GraphicsContext.h" #include "GraphicsLayer.h" +#include "GraphicsLayerAnimation.h" +#include "GraphicsLayerTransform.h" #include "Image.h" #include "IntPointHash.h" -#include "LayerTransform.h" #include "TextureMapper.h" -#include "TextureMapperAnimation.h" #include "TextureMapperBackingStore.h" #include "Timer.h" #include "TransformOperations.h" @@ -56,7 +56,7 @@ public: { } }; -class TextureMapperLayer : public TextureMapperAnimationClient { +class TextureMapperLayer : public GraphicsLayerAnimation::Client { public: // This set of flags help us defer which properties of the layer have been @@ -157,6 +157,10 @@ private: void drawRepaintCounter(GraphicsContext*, GraphicsLayer*); + // GraphicsLayerAnimation::Client + void setAnimatedTransform(const TransformationMatrix& matrix) { setTransform(matrix); } + void setAnimatedOpacity(float opacity) { setOpacity(opacity); } + void syncAnimations(); bool isVisible() const; enum ContentsLayerCount { @@ -168,7 +172,7 @@ private: ContentsLayerCount countPotentialLayersWithContents() const; bool shouldPaintToIntermediateSurface() const; - LayerTransform m_transform; + GraphicsLayerTransform m_transform; inline FloatRect layerRect() const { @@ -230,7 +234,7 @@ private: State m_state; TextureMapper* m_textureMapper; - TextureMapperAnimations m_animations; + GraphicsLayerAnimations m_animations; IntPoint m_scrollPositionDelta; bool m_fixedToViewport; Color m_debugBorderColor; diff --git a/Source/WebCore/platform/graphics/win/FontCustomPlatformData.cpp b/Source/WebCore/platform/graphics/win/FontCustomPlatformData.cpp index 8348acb39..b9d90fef9 100644 --- a/Source/WebCore/platform/graphics/win/FontCustomPlatformData.cpp +++ b/Source/WebCore/platform/graphics/win/FontCustomPlatformData.cpp @@ -21,7 +21,6 @@ #include "config.h" #include "FontCustomPlatformData.h" -#include "Base64.h" #include "FontPlatformData.h" #include "OpenTypeUtilities.h" #include "SharedBuffer.h" @@ -30,6 +29,7 @@ #include <ApplicationServices/ApplicationServices.h> #include <WebKitSystemInterface/WebKitSystemInterface.h> #include <wtf/RetainPtr.h> +#include <wtf/text/Base64.h> // From t2embapi.h, which is missing from the Microsoft Platform SDK. typedef unsigned long(WINAPIV *READEMBEDPROC) (void*, void*, unsigned long); diff --git a/Source/WebCore/platform/graphics/wince/FontCustomPlatformData.cpp b/Source/WebCore/platform/graphics/wince/FontCustomPlatformData.cpp index 07a875624..844f8ec04 100644 --- a/Source/WebCore/platform/graphics/wince/FontCustomPlatformData.cpp +++ b/Source/WebCore/platform/graphics/wince/FontCustomPlatformData.cpp @@ -22,11 +22,11 @@ #include "config.h" #include "FontCustomPlatformData.h" -#include "Base64.h" #include "CachedFont.h" #include "FontPlatformData.h" #include "SharedBuffer.h" #include <wtf/RandomNumber.h> +#include <wtf/text/Base64.h> namespace WebCore { diff --git a/Source/WebCore/platform/graphics/wince/ImageBufferWinCE.cpp b/Source/WebCore/platform/graphics/wince/ImageBufferWinCE.cpp index 9c4225a3e..572070553 100644 --- a/Source/WebCore/platform/graphics/wince/ImageBufferWinCE.cpp +++ b/Source/WebCore/platform/graphics/wince/ImageBufferWinCE.cpp @@ -21,7 +21,6 @@ #include "config.h" #include "ImageBuffer.h" -#include "Base64.h" #include "GraphicsContext.h" #include "Image.h" #include "ImageData.h" diff --git a/Source/WebCore/platform/graphics/wx/ImageBufferWx.cpp b/Source/WebCore/platform/graphics/wx/ImageBufferWx.cpp index 0cdbc7b3b..57874832e 100644 --- a/Source/WebCore/platform/graphics/wx/ImageBufferWx.cpp +++ b/Source/WebCore/platform/graphics/wx/ImageBufferWx.cpp @@ -27,7 +27,6 @@ #include "config.h" #include "ImageBuffer.h" -#include "Base64.h" #include "BitmapImage.h" #include "GraphicsContext.h" #include "Image.h" |