summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNicolas Roard <nicolas@android.com>2011-05-03 17:44:11 -0700
committerNicolas Roard <nicolas@android.com>2011-05-03 17:44:11 -0700
commitf8d1bcaf8c8b020e80856c8df5417a37db4f8919 (patch)
treeaa8e0d7d815492aee9047333e40d47168c20a2be
parent3c2218dce93737af90cf230db56fed0e0d1a93fc (diff)
downloadexternal_webkit-f8d1bcaf8c8b020e80856c8df5417a37db4f8919.zip
external_webkit-f8d1bcaf8c8b020e80856c8df5417a37db4f8919.tar.gz
external_webkit-f8d1bcaf8c8b020e80856c8df5417a37db4f8919.tar.bz2
Implement hiding backfaces
bug:3456544 Change-Id: I0e6b10e435432ddbf40085c4b3a7a7e22baed28a
-rw-r--r--WebCore/platform/graphics/android/GraphicsLayerAndroid.cpp7
-rw-r--r--WebCore/platform/graphics/android/GraphicsLayerAndroid.h1
-rw-r--r--WebCore/platform/graphics/android/LayerAndroid.cpp14
-rw-r--r--WebCore/platform/graphics/android/LayerAndroid.h4
4 files changed, 26 insertions, 0 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 6e4b10a..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;
@@ -619,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;
@@ -933,6 +945,8 @@ static inline bool compareLayerZ(const LayerAndroid* a, const LayerAndroid* b)
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 592e427..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; }
@@ -289,6 +291,8 @@ private:
TransformationMatrix m_transform;
float m_zValue;
+ bool m_backfaceVisibility;
+ bool m_visible;
SkColor m_backgroundColor;