diff options
Diffstat (limited to 'WebCore/platform')
6 files changed, 43 insertions, 4 deletions
diff --git a/WebCore/platform/graphics/android/GraphicsLayerAndroid.cpp b/WebCore/platform/graphics/android/GraphicsLayerAndroid.cpp index 59f8408..e8120f9 100644 --- a/WebCore/platform/graphics/android/GraphicsLayerAndroid.cpp +++ b/WebCore/platform/graphics/android/GraphicsLayerAndroid.cpp @@ -337,6 +337,13 @@ void GraphicsLayerAndroid::setSize(const FloatSize& size) askForSync(); } +void GraphicsLayerAndroid::setBackfaceVisibility(bool b) +{ + GraphicsLayer::setBackfaceVisibility(b); + m_contentLayer->setBackfaceVisibility(b); + askForSync(); +} + void GraphicsLayerAndroid::setTransform(const TransformationMatrix& t) { if (t == m_transform) diff --git a/WebCore/platform/graphics/android/GraphicsLayerAndroid.h b/WebCore/platform/graphics/android/GraphicsLayerAndroid.h index 94b828b..10db5a1 100644 --- a/WebCore/platform/graphics/android/GraphicsLayerAndroid.h +++ b/WebCore/platform/graphics/android/GraphicsLayerAndroid.h @@ -61,6 +61,7 @@ public: virtual void setAnchorPoint(const FloatPoint3D&); virtual void setSize(const FloatSize&); + virtual void setBackfaceVisibility(bool b); virtual void setTransform(const TransformationMatrix&); virtual void setChildrenTransform(const TransformationMatrix&); diff --git a/WebCore/platform/graphics/android/LayerAndroid.cpp b/WebCore/platform/graphics/android/LayerAndroid.cpp index e616041..7bef420 100644 --- a/WebCore/platform/graphics/android/LayerAndroid.cpp +++ b/WebCore/platform/graphics/android/LayerAndroid.cpp @@ -58,6 +58,8 @@ LayerAndroid::LayerAndroid(RenderLayer* owner) : SkLayer(), m_haveClip(false), m_isFixed(false), m_isIframe(false), + m_backfaceVisibility(true), + m_visible(true), m_preserves3D(false), m_anchorPointZ(0), m_recordingPicture(0), @@ -97,6 +99,8 @@ LayerAndroid::LayerAndroid(const LayerAndroid& layer) : SkLayer(layer), copyBitmap(layer.m_contentsImage); m_renderLayerPos = layer.m_renderLayerPos; m_transform = layer.m_transform; + m_backfaceVisibility = layer.m_backfaceVisibility; + m_visible = layer.m_visible; m_backgroundColor = layer.m_backgroundColor; m_fixedLeft = layer.m_fixedLeft; @@ -604,6 +608,8 @@ void LayerAndroid::updateGLPositions(const TransformationMatrix& parentMatrix, -anchorPointZ()); setDrawTransform(localMatrix); + m_zValue = TilesManager::instance()->shader()->zValue(drawTransform(), getSize().width(), getSize().height()); + opacity *= getOpacity(); setDrawOpacity(opacity); @@ -617,6 +623,14 @@ void LayerAndroid::updateGLPositions(const TransformationMatrix& parentMatrix, setDrawClip(clipping); } + if (!m_backfaceVisibility + && drawTransform().inverse().m33() < 0) { + setVisible(false); + return; + } else { + setVisible(true); + } + int count = this->countChildren(); if (!count) return; @@ -925,15 +939,14 @@ bool LayerAndroid::needsScheduleRepaint(LayerTexture* texture) static inline bool compareLayerZ(const LayerAndroid* a, const LayerAndroid* b) { - const TransformationMatrix& transformA = a->drawTransform(); - const TransformationMatrix& transformB = b->drawTransform(); - - return transformA.m43() < transformB.m43(); + return a->zValue() > b->zValue(); } bool LayerAndroid::drawGL(GLWebViewState* glWebViewState, SkMatrix& matrix) { TilesManager::instance()->shader()->clip(m_clippingRect); + if (!m_visible) + return false; if (m_drawingTexture) { TextureInfo* textureInfo = m_drawingTexture->consumerLock(); diff --git a/WebCore/platform/graphics/android/LayerAndroid.h b/WebCore/platform/graphics/android/LayerAndroid.h index e01a9a7..d4510c5 100644 --- a/WebCore/platform/graphics/android/LayerAndroid.h +++ b/WebCore/platform/graphics/android/LayerAndroid.h @@ -101,6 +101,7 @@ public: LayerTexture* texture() { return m_reservedTexture; } virtual TiledPage* page() { return 0; } + void setBackfaceVisibility(bool value) { m_backfaceVisibility = value; } void setTransform(const TransformationMatrix& matrix) { m_transform = matrix; } FloatPoint translation() const; SkRect bounds() const; @@ -134,6 +135,7 @@ public: void updateGLPositions(const TransformationMatrix& parentMatrix, const FloatRect& clip, float opacity); void setDrawOpacity(float opacity) { m_drawOpacity = opacity; } + void setVisible(bool value) { m_visible = value; } bool preserves3D() { return m_preserves3D; } void setPreserves3D(bool value) { m_preserves3D = value; } @@ -252,6 +254,7 @@ public: RenderLayer* owningLayer() const { return m_owningLayer; } void setIsIframe(bool isIframe) { m_isIframe = isIframe; } + float zValue() const { return m_zValue; } protected: virtual void onDraw(SkCanvas*, SkScalar opacity); @@ -287,6 +290,9 @@ private: IntPoint m_renderLayerPos; TransformationMatrix m_transform; + float m_zValue; + bool m_backfaceVisibility; + bool m_visible; SkColor m_backgroundColor; diff --git a/WebCore/platform/graphics/android/ShaderProgram.cpp b/WebCore/platform/graphics/android/ShaderProgram.cpp index 9e0a4ab..6933890 100644 --- a/WebCore/platform/graphics/android/ShaderProgram.cpp +++ b/WebCore/platform/graphics/android/ShaderProgram.cpp @@ -28,6 +28,7 @@ #if USE(ACCELERATED_COMPOSITING) +#include "FloatPoint3D.h" #include "GLUtils.h" #include <GLES2/gl2.h> @@ -372,6 +373,16 @@ IntRect ShaderProgram::clippedRectWithViewport(const IntRect& rect, int margin) return viewport; } +float ShaderProgram::zValue(const TransformationMatrix& drawMatrix, float w, float h) +{ + TransformationMatrix renderMatrix = drawMatrix; + renderMatrix.scale3d(w, h, 1); + renderMatrix.multiply(m_projectionMatrix); + FloatPoint3D point(0.5, 0.5, 0.0); + FloatPoint3D result = renderMatrix.mapPoint(point); + return result.z(); +} + void ShaderProgram::drawLayerQuad(const TransformationMatrix& drawMatrix, SkRect& geometry, int textureId, float opacity, bool forceBlending) diff --git a/WebCore/platform/graphics/android/ShaderProgram.h b/WebCore/platform/graphics/android/ShaderProgram.h index 256cc2b..55afe4f 100644 --- a/WebCore/platform/graphics/android/ShaderProgram.h +++ b/WebCore/platform/graphics/android/ShaderProgram.h @@ -39,6 +39,7 @@ class ShaderProgram { // Drawing void setViewport(SkRect& viewport); void drawQuad(SkRect& geometry, int textureId, float opacity); + float zValue(const TransformationMatrix& drawMatrix, float w, float h); void drawLayerQuad(const TransformationMatrix& drawMatrix, SkRect& geometry, int textureId, float opacity, bool forceBlending = false); |