summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorLiang Qi <liang.qi@theqtcompany.com>2015-05-26 10:19:01 +0200
committerLiang Qi <liang.qi@theqtcompany.com>2015-05-26 10:19:01 +0200
commit64a79a104ded96a5ecc092a38ca4a6a58ee85be5 (patch)
treeac551b772b407b422d063c7178397b8466094463 /Source
parent90d5224e69b7841e6f82c9fac316fa5fae5a357a (diff)
parentef31021c3ec96a70777217f1f613f7d27d6f5a15 (diff)
Merge remote-tracking branch 'origin/5.4' into 5.5
Diffstat (limited to 'Source')
-rw-r--r--Source/WebCore/html/ImageDocument.cpp6
-rw-r--r--Source/WebCore/platform/Length.h5
-rw-r--r--Source/WebCore/platform/graphics/texmap/GraphicsLayerTextureMapper.cpp40
-rw-r--r--Source/WebCore/platform/graphics/texmap/GraphicsLayerTextureMapper.h1
4 files changed, 48 insertions, 4 deletions
diff --git a/Source/WebCore/html/ImageDocument.cpp b/Source/WebCore/html/ImageDocument.cpp
index 7d9bcc589..594ccad90 100644
--- a/Source/WebCore/html/ImageDocument.cpp
+++ b/Source/WebCore/html/ImageDocument.cpp
@@ -135,6 +135,8 @@ void ImageDocumentParser::appendBytes(DocumentWriter*, const char*, size_t)
return;
CachedImage* cachedImage = document()->cachedImage();
+ if (!cachedImage)
+ return;
RefPtr<ResourceBuffer> resourceData = frame->loader()->documentLoader()->mainResourceData();
cachedImage->addDataBuffer(resourceData.get());
@@ -143,8 +145,8 @@ void ImageDocumentParser::appendBytes(DocumentWriter*, const char*, size_t)
void ImageDocumentParser::finish()
{
- if (!isStopped() && document()->imageElement()) {
- CachedImage* cachedImage = document()->cachedImage();
+ CachedImage* cachedImage = 0;
+ if (!isStopped() && document()->imageElement() && (cachedImage = document()->cachedImage())) {
RefPtr<ResourceBuffer> data = document()->frame()->loader()->documentLoader()->mainResourceData();
// If this is a multipart image, make a copy of the current part, since the resource data
diff --git a/Source/WebCore/platform/Length.h b/Source/WebCore/platform/Length.h
index 2f91550da..72263b045 100644
--- a/Source/WebCore/platform/Length.h
+++ b/Source/WebCore/platform/Length.h
@@ -233,6 +233,11 @@ public:
Length blend(const Length& from, double progress) const
{
// Blend two lengths to produce a new length that is in between them. Used for animation.
+ if (from.isUndefined())
+ return *this;
+ if (isUndefined())
+ return from;
+
if (from.type() == Calculated || type() == Calculated)
return blendMixedTypes(from, progress);
diff --git a/Source/WebCore/platform/graphics/texmap/GraphicsLayerTextureMapper.cpp b/Source/WebCore/platform/graphics/texmap/GraphicsLayerTextureMapper.cpp
index e390792a3..73a6afc02 100644
--- a/Source/WebCore/platform/graphics/texmap/GraphicsLayerTextureMapper.cpp
+++ b/Source/WebCore/platform/graphics/texmap/GraphicsLayerTextureMapper.cpp
@@ -48,6 +48,31 @@ PassOwnPtr<GraphicsLayer> GraphicsLayer::create(GraphicsLayerClient* client)
return adoptPtr(new GraphicsLayerTextureMapper(client));
}
+// A fallback layer to handle painting when we decide dynamically to avoid compositing due to layer size.
+class DirectPaintLayer : public TextureMapperPlatformLayer {
+public:
+ DirectPaintLayer(GraphicsLayer* sourceLayer) : m_sourceLayer(sourceLayer)
+ { }
+ void paintToTextureMapper(TextureMapper*, const FloatRect&, const TransformationMatrix& modelViewMatrix, float opacity) OVERRIDE;
+
+private:
+ GraphicsLayer* m_sourceLayer;
+};
+
+void DirectPaintLayer::paintToTextureMapper(TextureMapper* textureMapper, const FloatRect& targetRect, const TransformationMatrix& matrix, float opacity)
+{
+ GraphicsContext* context = textureMapper->graphicsContext();
+ context->save();
+ context->setAlpha(opacity);
+#if ENABLE(3D_RENDERING)
+ context->concat3DTransform(matrix);
+#else
+ context->concatCTM(matrix.toAffineTransform());
+#endif
+ m_sourceLayer->paintGraphicsLayerContents(*context, enclosingIntRect(targetRect));
+ context->restore();
+}
+
GraphicsLayerTextureMapper::GraphicsLayerTextureMapper(GraphicsLayerClient* client)
: GraphicsLayer(client)
, m_layer(adoptPtr(new TextureMapperLayer()))
@@ -57,6 +82,7 @@ GraphicsLayerTextureMapper::GraphicsLayerTextureMapper(GraphicsLayerClient* clie
, m_fixedToViewport(false)
, m_debugBorderWidth(0)
, m_contentsLayer(0)
+ , m_directLayer(0)
, m_animationStartTime(0)
, m_isScrollable(false)
{
@@ -79,7 +105,8 @@ GraphicsLayerTextureMapper::~GraphicsLayerTextureMapper()
{
if (m_contentsLayer)
m_contentsLayer->setClient(0);
-
+ delete m_directLayer;
+ m_directLayer = 0;
willBeDestroyed();
}
@@ -233,6 +260,15 @@ void GraphicsLayerTextureMapper::setSize(const FloatSize& value)
if (maskLayer())
maskLayer()->setSize(value);
notifyChange(SizeChange);
+
+ if (m_size.width() * m_size.height() <= 8192*8192) {
+ if (m_contentsLayer == m_directLayer)
+ setContentsToMedia(0);
+ } else if (!m_contentsLayer) {
+ if (!m_directLayer)
+ m_directLayer = new DirectPaintLayer(this);
+ setContentsToMedia(m_directLayer);
+ }
}
/* \reimp (GraphicsLayer.h)
@@ -627,7 +663,7 @@ void GraphicsLayerTextureMapper::updateBackingStoreIfNeeded()
bool GraphicsLayerTextureMapper::shouldHaveBackingStore() const
{
- return drawsContent() && contentsAreVisible() && !m_size.isEmpty() && (m_size.width() * m_size.height() <= 8192*8192);
+ return drawsContent() && contentsAreVisible() && !m_size.isEmpty() && !m_contentsLayer;
}
bool GraphicsLayerTextureMapper::addAnimation(const KeyframeValueList& valueList, const IntSize& boxSize, const Animation* anim, const String& keyframesName, double timeOffset)
diff --git a/Source/WebCore/platform/graphics/texmap/GraphicsLayerTextureMapper.h b/Source/WebCore/platform/graphics/texmap/GraphicsLayerTextureMapper.h
index 16e4ebad0..548a95c29 100644
--- a/Source/WebCore/platform/graphics/texmap/GraphicsLayerTextureMapper.h
+++ b/Source/WebCore/platform/graphics/texmap/GraphicsLayerTextureMapper.h
@@ -176,6 +176,7 @@ private:
float m_debugBorderWidth;
TextureMapperPlatformLayer* m_contentsLayer;
+ TextureMapperPlatformLayer* m_directLayer;
FloatRect m_needsDisplayRect;
GraphicsLayerAnimations m_animations;
double m_animationStartTime;