Commit 5eb17ee2 authored by abarth@chromium.org's avatar abarth@chromium.org

Remove unused cruft from GraphicsLayer

This CL deletes a bunch of state and code from GraphicsLayer that's not used.

R=jamesr@chromium.org

Review URL: https://codereview.chromium.org/335453002

git-svn-id: svn://svn.chromium.org/blink/trunk@176005 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent c1993ac4
...@@ -82,7 +82,6 @@ GraphicsLayer::GraphicsLayer(GraphicsLayerClient* client) ...@@ -82,7 +82,6 @@ GraphicsLayer::GraphicsLayer(GraphicsLayerClient* client)
: m_client(client) : m_client(client)
, m_backgroundColor(Color::transparent) , m_backgroundColor(Color::transparent)
, m_opacity(1) , m_opacity(1)
, m_zPosition(0)
, m_blendMode(blink::WebBlendModeNormal) , m_blendMode(blink::WebBlendModeNormal)
, m_hasTransformOrigin(false) , m_hasTransformOrigin(false)
, m_contentsOpaque(false) , m_contentsOpaque(false)
...@@ -95,7 +94,6 @@ GraphicsLayer::GraphicsLayer(GraphicsLayerClient* client) ...@@ -95,7 +94,6 @@ GraphicsLayer::GraphicsLayer(GraphicsLayerClient* client)
, m_hasScrollParent(false) , m_hasScrollParent(false)
, m_hasClipParent(false) , m_hasClipParent(false)
, m_paintingPhase(GraphicsLayerPaintAllWithOverflowClip) , m_paintingPhase(GraphicsLayerPaintAllWithOverflowClip)
, m_contentsOrientation(CompositingCoordinatesTopDown)
, m_parent(0) , m_parent(0)
, m_maskLayer(0) , m_maskLayer(0)
, m_contentsClippingMaskLayer(0) , m_contentsClippingMaskLayer(0)
...@@ -149,6 +147,8 @@ void GraphicsLayer::setParent(GraphicsLayer* layer) ...@@ -149,6 +147,8 @@ void GraphicsLayer::setParent(GraphicsLayer* layer)
m_parent = layer; m_parent = layer;
} }
#if ASSERT_ENABLED
bool GraphicsLayer::hasAncestor(GraphicsLayer* ancestor) const bool GraphicsLayer::hasAncestor(GraphicsLayer* ancestor) const
{ {
for (GraphicsLayer* curr = parent(); curr; curr = curr->parent()) { for (GraphicsLayer* curr = parent(); curr; curr = curr->parent()) {
...@@ -159,6 +159,8 @@ bool GraphicsLayer::hasAncestor(GraphicsLayer* ancestor) const ...@@ -159,6 +159,8 @@ bool GraphicsLayer::hasAncestor(GraphicsLayer* ancestor) const
return false; return false;
} }
#endif
bool GraphicsLayer::setChildren(const GraphicsLayerVector& newChildren) bool GraphicsLayer::setChildren(const GraphicsLayerVector& newChildren)
{ {
// If the contents of the arrays are the same, nothing to do. // If the contents of the arrays are the same, nothing to do.
...@@ -335,11 +337,6 @@ void GraphicsLayer::paintGraphicsLayerContents(GraphicsContext& context, const I ...@@ -335,11 +337,6 @@ void GraphicsLayer::paintGraphicsLayerContents(GraphicsContext& context, const I
m_client->paintContents(this, context, m_paintingPhase, clip); m_client->paintContents(this, context, m_paintingPhase, clip);
} }
void GraphicsLayer::setZPosition(float position)
{
m_zPosition = position;
}
void GraphicsLayer::updateChildList() void GraphicsLayer::updateChildList()
{ {
WebLayer* childHost = m_layer->layer(); WebLayer* childHost = m_layer->layer();
...@@ -687,30 +684,30 @@ void GraphicsLayer::dumpProperties(TextStream& ts, int indent, LayerTreeFlags fl ...@@ -687,30 +684,30 @@ void GraphicsLayer::dumpProperties(TextStream& ts, int indent, LayerTreeFlags fl
ts << ")\n"; ts << ")\n";
} }
if ((flags & LayerTreeIncludesPaintingPhases) && paintingPhase()) { if ((flags & LayerTreeIncludesPaintingPhases) && m_paintingPhase) {
writeIndent(ts, indent + 1); writeIndent(ts, indent + 1);
ts << "(paintingPhases\n"; ts << "(paintingPhases\n";
if (paintingPhase() & GraphicsLayerPaintBackground) { if (m_paintingPhase & GraphicsLayerPaintBackground) {
writeIndent(ts, indent + 2); writeIndent(ts, indent + 2);
ts << "GraphicsLayerPaintBackground\n"; ts << "GraphicsLayerPaintBackground\n";
} }
if (paintingPhase() & GraphicsLayerPaintForeground) { if (m_paintingPhase & GraphicsLayerPaintForeground) {
writeIndent(ts, indent + 2); writeIndent(ts, indent + 2);
ts << "GraphicsLayerPaintForeground\n"; ts << "GraphicsLayerPaintForeground\n";
} }
if (paintingPhase() & GraphicsLayerPaintMask) { if (m_paintingPhase & GraphicsLayerPaintMask) {
writeIndent(ts, indent + 2); writeIndent(ts, indent + 2);
ts << "GraphicsLayerPaintMask\n"; ts << "GraphicsLayerPaintMask\n";
} }
if (paintingPhase() & GraphicsLayerPaintChildClippingMask) { if (m_paintingPhase & GraphicsLayerPaintChildClippingMask) {
writeIndent(ts, indent + 2); writeIndent(ts, indent + 2);
ts << "GraphicsLayerPaintChildClippingMask\n"; ts << "GraphicsLayerPaintChildClippingMask\n";
} }
if (paintingPhase() & GraphicsLayerPaintOverflowContents) { if (m_paintingPhase & GraphicsLayerPaintOverflowContents) {
writeIndent(ts, indent + 2); writeIndent(ts, indent + 2);
ts << "GraphicsLayerPaintOverflowContents\n"; ts << "GraphicsLayerPaintOverflowContents\n";
} }
if (paintingPhase() & GraphicsLayerPaintCompositedScroll) { if (m_paintingPhase & GraphicsLayerPaintCompositedScroll) {
writeIndent(ts, indent + 2); writeIndent(ts, indent + 2);
ts << "GraphicsLayerPaintCompositedScroll\n"; ts << "GraphicsLayerPaintCompositedScroll\n";
} }
...@@ -971,7 +968,7 @@ void GraphicsLayer::setContentsNeedsDisplay() ...@@ -971,7 +968,7 @@ void GraphicsLayer::setContentsNeedsDisplay()
{ {
if (WebLayer* contentsLayer = contentsLayerIfRegistered()) { if (WebLayer* contentsLayer = contentsLayerIfRegistered()) {
contentsLayer->invalidate(); contentsLayer->invalidate();
addRepaintRect(contentsRect()); addRepaintRect(m_contentsRect);
} }
} }
......
...@@ -102,9 +102,6 @@ public: ...@@ -102,9 +102,6 @@ public:
GraphicsLayer* parent() const { return m_parent; }; GraphicsLayer* parent() const { return m_parent; };
void setParent(GraphicsLayer*); // Internal use only. void setParent(GraphicsLayer*); // Internal use only.
// Returns true if the layer has the given layer as an ancestor (excluding self).
bool hasAncestor(GraphicsLayer*) const;
const Vector<GraphicsLayer*>& children() const { return m_children; } const Vector<GraphicsLayer*>& children() const { return m_children; }
// Returns true if the child list changed. // Returns true if the child list changed.
bool setChildren(const GraphicsLayerVector&); bool setChildren(const GraphicsLayerVector&);
...@@ -127,8 +124,6 @@ public: ...@@ -127,8 +124,6 @@ public:
// The given layer will replicate this layer and its children; the replica renders behind this layer. // The given layer will replicate this layer and its children; the replica renders behind this layer.
void setReplicatedByLayer(GraphicsLayer*); void setReplicatedByLayer(GraphicsLayer*);
// Whether this layer is being replicated by another layer.
bool isReplicated() const { return m_replicaLayer; }
// The layer that replicates this layer (if any). // The layer that replicates this layer (if any).
GraphicsLayer* replicaLayer() const { return m_replicaLayer; } GraphicsLayer* replicaLayer() const { return m_replicaLayer; }
// The layer being replicated. // The layer being replicated.
...@@ -160,14 +155,8 @@ public: ...@@ -160,14 +155,8 @@ public:
const TransformationMatrix& transform() const { return m_transform; } const TransformationMatrix& transform() const { return m_transform; }
void setTransform(const TransformationMatrix&); void setTransform(const TransformationMatrix&);
bool shouldFlattenTransform() const { return m_shouldFlattenTransform; }
void setShouldFlattenTransform(bool); void setShouldFlattenTransform(bool);
int renderingContext() const { return m_3dRenderingContext; }
void setRenderingContext(int id); void setRenderingContext(int id);
bool masksToBounds() const { return m_masksToBounds; }
void setMasksToBounds(bool); void setMasksToBounds(bool);
bool drawsContent() const { return m_drawsContent; } bool drawsContent() const { return m_drawsContent; }
...@@ -182,7 +171,6 @@ public: ...@@ -182,7 +171,6 @@ public:
// For special cases, e.g. drawing missing tiles on Android. // For special cases, e.g. drawing missing tiles on Android.
// The compositor should never paint this color in normal cases because the RenderLayer // The compositor should never paint this color in normal cases because the RenderLayer
// will paint background by itself. // will paint background by itself.
const Color& backgroundColor() const { return m_backgroundColor; }
void setBackgroundColor(const Color&); void setBackgroundColor(const Color&);
// opaque means that we know the layer contents have no alpha // opaque means that we know the layer contents have no alpha
...@@ -195,20 +183,14 @@ public: ...@@ -195,20 +183,14 @@ public:
float opacity() const { return m_opacity; } float opacity() const { return m_opacity; }
void setOpacity(float); void setOpacity(float);
blink::WebBlendMode blendMode() const { return m_blendMode; }
void setBlendMode(blink::WebBlendMode); void setBlendMode(blink::WebBlendMode);
bool isRootForIsolatedGroup() const { return m_isRootForIsolatedGroup; }
void setIsRootForIsolatedGroup(bool); void setIsRootForIsolatedGroup(bool);
const FilterOperations& filters() const { return m_filters; }
// Returns true if filter can be rendered by the compositor // Returns true if filter can be rendered by the compositor
bool setFilters(const FilterOperations&); bool setFilters(const FilterOperations&);
void setBackgroundFilters(const FilterOperations&); void setBackgroundFilters(const FilterOperations&);
// Some GraphicsLayers paint only the foreground or the background content // Some GraphicsLayers paint only the foreground or the background content
GraphicsLayerPaintingPhase paintingPhase() const { return m_paintingPhase; }
void setPaintingPhase(GraphicsLayerPaintingPhase); void setPaintingPhase(GraphicsLayerPaintingPhase);
void setNeedsDisplay(); void setNeedsDisplay();
...@@ -218,7 +200,6 @@ public: ...@@ -218,7 +200,6 @@ public:
void setContentsNeedsDisplay(); void setContentsNeedsDisplay();
// Set that the position/size of the contents (image or video). // Set that the position/size of the contents (image or video).
IntRect contentsRect() const { return m_contentsRect; }
void setContentsRect(const IntRect&); void setContentsRect(const IntRect&);
// Return true if the animation is handled by the compositing system. If this returns // Return true if the animation is handled by the compositing system. If this returns
...@@ -240,25 +221,11 @@ public: ...@@ -240,25 +221,11 @@ public:
// For hosting this GraphicsLayer in a native layer hierarchy. // For hosting this GraphicsLayer in a native layer hierarchy.
blink::WebLayer* platformLayer() const; blink::WebLayer* platformLayer() const;
enum CompositingCoordinatesOrientation { CompositingCoordinatesTopDown, CompositingCoordinatesBottomUp };
// Flippedness of the contents of this layer. Does not affect sublayer geometry.
void setContentsOrientation(CompositingCoordinatesOrientation orientation) { m_contentsOrientation = orientation; }
CompositingCoordinatesOrientation contentsOrientation() const { return m_contentsOrientation; }
typedef HashMap<int, int> RenderingContextMap; typedef HashMap<int, int> RenderingContextMap;
void dumpLayer(TextStream&, int indent, LayerTreeFlags, RenderingContextMap&) const; void dumpLayer(TextStream&, int indent, LayerTreeFlags, RenderingContextMap&) const;
int paintCount() const { return m_paintCount; } int paintCount() const { return m_paintCount; }
// z-position is the z-equivalent of position(). It's only used for debugging purposes.
float zPosition() const { return m_zPosition; }
void setZPosition(float);
// If the exposed rect of this layer changes, returns true if this or descendant layers need a flush,
// for example to allocate new tiles.
bool visibleRectChangeRequiresFlush(const FloatRect& /* clipRect */) const { return false; }
// Return a string with a human readable form of the layer tree, If debug is true // Return a string with a human readable form of the layer tree, If debug is true
// pointers for the layers and timing data will be included in the returned string. // pointers for the layers and timing data will be included in the returned string.
String layerTreeAsText(LayerTreeFlags = LayerTreeNormal) const; String layerTreeAsText(LayerTreeFlags = LayerTreeNormal) const;
...@@ -306,6 +273,10 @@ private: ...@@ -306,6 +273,10 @@ private:
// can be batched before updating. // can be batched before updating.
void addChildInternal(GraphicsLayer*); void addChildInternal(GraphicsLayer*);
#if ASSERT_ENABLED
bool hasAncestor(GraphicsLayer*) const;
#endif
// This method is used by platform GraphicsLayer classes to clear the filters // This method is used by platform GraphicsLayer classes to clear the filters
// when compositing is not done in hardware. It is not virtual, so the caller // when compositing is not done in hardware. It is not virtual, so the caller
// needs to notifiy the change to the platform layer as needed. // needs to notifiy the change to the platform layer as needed.
...@@ -342,7 +313,6 @@ private: ...@@ -342,7 +313,6 @@ private:
Color m_backgroundColor; Color m_backgroundColor;
float m_opacity; float m_opacity;
float m_zPosition;
blink::WebBlendMode m_blendMode; blink::WebBlendMode m_blendMode;
...@@ -361,7 +331,6 @@ private: ...@@ -361,7 +331,6 @@ private:
bool m_hasClipParent : 1; bool m_hasClipParent : 1;
GraphicsLayerPaintingPhase m_paintingPhase; GraphicsLayerPaintingPhase m_paintingPhase;
CompositingCoordinatesOrientation m_contentsOrientation; // affects orientation of layer contents
Vector<GraphicsLayer*> m_children; Vector<GraphicsLayer*> m_children;
GraphicsLayer* m_parent; GraphicsLayer* m_parent;
......
/*
* Copyright (C) 2013 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 "core/rendering/compositing/CompositedLayerMapping.h"
#include "core/dom/Document.h"
#include "core/frame/FrameView.h"
#include "public/platform/Platform.h"
#include "public/platform/WebUnitTestSupport.h"
#include "public/web/WebDocument.h"
#include "public/web/WebElement.h"
#include "public/web/WebFrameClient.h"
#include "public/web/WebSettings.h"
#include "public/web/WebViewClient.h"
#include "web/WebLocalFrameImpl.h"
#include "web/WebViewImpl.h"
#include "web/tests/FrameTestHelpers.h"
#include "web/tests/URLTestHelpers.h"
#include <gtest/gtest.h>
using namespace blink;
namespace WebCore {
namespace {
class MockWebFrameClient : public WebFrameClient {
};
class CompositedLayerMappingTest : public testing::Test {
public:
CompositedLayerMappingTest()
: m_baseURL("http://www.test.com/")
{
// We cannot reuse FrameTestHelpers::createWebViewAndLoad here because the compositing
// settings need to be set before the page is loaded.
m_mainFrame = WebLocalFrame::create(&m_mockWebFrameClient);
m_webViewImpl = toWebViewImpl(WebView::create(&m_mockWebViewClient));
m_webViewImpl->settings()->setAcceleratedCompositingEnabled(true);
m_webViewImpl->settings()->setAcceleratedCompositingForFixedPositionEnabled(true);
m_webViewImpl->settings()->setAcceleratedCompositingForOverflowScrollEnabled(true);
m_webViewImpl->settings()->setCompositedScrollingForFramesEnabled(true);
m_webViewImpl->setMainFrame(m_mainFrame);
m_webViewImpl->resize(IntSize(320, 240));
}
virtual void TearDown()
{
Platform::current()->unitTestSupport()->unregisterAllMockedURLs();
m_webViewImpl->close();
m_mainFrame->close();
}
void navigateTo(const std::string& url)
{
FrameTestHelpers::loadFrame(m_webViewImpl->mainFrame(), url);
}
void registerMockedHttpURLLoad(const std::string& fileName)
{
URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c_str()), WebString::fromUTF8(fileName.c_str()));
}
protected:
std::string m_baseURL;
MockWebFrameClient m_mockWebFrameClient;
FrameTestHelpers::TestWebViewClient m_mockWebViewClient;
WebViewImpl* m_webViewImpl;
WebFrame* m_mainFrame;
};
TEST_F(CompositedLayerMappingTest, DISABLED_GraphicsLayerBackgroundColor)
{
registerMockedHttpURLLoad("layer_background_color.html");
navigateTo(m_baseURL + "layer_background_color.html");
m_webViewImpl->layout();
Document* document = m_webViewImpl->mainFrameImpl()->frame()->document();
Element* layerElement = document->getElementById("layer");
RenderLayerModelObject* renderer = toRenderLayerModelObject(layerElement->renderer());
EXPECT_EQ(renderer->style()->visitedDependentColor(CSSPropertyBackgroundColor),
renderer->layer()->compositedLayerMapping()->mainGraphicsLayer()->backgroundColor());
layerElement = document->getElementById("layer-solid-color");
renderer = toRenderLayerModelObject(layerElement->renderer());
// CompositedLayerMapping::graphicsLayer's background color is unset if SolidColorLayer is created.
EXPECT_EQ(Color(), renderer->layer()->compositedLayerMapping()->mainGraphicsLayer()->backgroundColor());
}
}
} // namespace WebCore
<!DOCTYPE html>
<html>
<head>
<style>
.composited {
position: fixed;
background-color: #223344;
width: 50px;
height: 50px;
}
#layer-solid-color {
top: 100px;
}
</style>
<head>
<!-- Fixed position elements may skip compositing without a scrollable
ancestor. To make sure this test covers the intended scenario, we force the
body element to be tall, so that the FrameView is scrolling. -->
<body style="height: 4000px;">
<div id="layer" class="composited">
inner layer
</div>
<div id="layer-solid-color" class="composited">
</div>
</body>
</html>
...@@ -265,7 +265,6 @@ ...@@ -265,7 +265,6 @@
'web_unittest_files': [ 'web_unittest_files': [
'tests/AssociatedURLLoaderTest.cpp', 'tests/AssociatedURLLoaderTest.cpp',
'tests/ChromeClientImplTest.cpp', 'tests/ChromeClientImplTest.cpp',
'tests/CompositedLayerMappingTest.cpp',
'tests/CustomEventTest.cpp', 'tests/CustomEventTest.cpp',
'tests/FakeWebPlugin.cpp', 'tests/FakeWebPlugin.cpp',
'tests/FakeWebPlugin.h', 'tests/FakeWebPlugin.h',
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment