Permalink
Show file tree
Hide file tree
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
[chromium] Add WebSolidColorLayer interface to draw non-textured colo…
…r layers from Aura. https://bugs.webkit.org/show_bug.cgi?id=75732 Reviewed by James Robinson. Source/WebCore: Add WebSolidColorLayer to paint solid-color layers without a backing texture. Test: unit test for CCSolidColorLayerImpl. * WebCore.gypi: * platform/graphics/chromium/SolidColorLayerChromium.cpp: Added. (WebCore::SolidColorLayerChromium::createCCLayerImpl): (WebCore::SolidColorLayerChromium::create): (WebCore::SolidColorLayerChromium::SolidColorLayerChromium): (WebCore::SolidColorLayerChromium::~SolidColorLayerChromium): * platform/graphics/chromium/SolidColorLayerChromium.h: Added. * platform/graphics/chromium/cc/CCSolidColorLayerImpl.cpp: Added. (WebCore::CCSolidColorLayerImpl::CCSolidColorLayerImpl): (WebCore::CCSolidColorLayerImpl::~CCSolidColorLayerImpl): (WebCore::CCSolidColorLayerImpl::quadTransform): (WebCore::CCSolidColorLayerImpl::appendQuads): * platform/graphics/chromium/cc/CCSolidColorLayerImpl.h: Added. (WebCore::CCSolidColorLayerImpl::create): (WebCore::CCSolidColorLayerImpl::layerTypeAsString): Source/WebKit/chromium: * WebKit.gyp: * WebKit.gypi: * public/platform/WebSolidColorLayer.h: Added. * src/WebSolidColorLayer.cpp: Added. (WebKit::WebSolidColorLayer::create): (WebKit::WebSolidColorLayer::WebSolidColorLayer): (WebKit::WebSolidColorLayer::setBackgroundColor): * src/WebSolidColorLayerImpl.cpp: Added. (WebKit::WebSolidColorLayerImpl::create): (WebKit::WebSolidColorLayerImpl::WebSolidColorLayerImpl): (WebKit::WebSolidColorLayerImpl::~WebSolidColorLayerImpl): * src/WebSolidColorLayerImpl.h: Added. * tests/CCLayerTestCommon.cpp: Added. (CCLayerTestCommon::completelyContains): (CCLayerTestCommon::verifyQuadsExactlyCoverRect): * tests/CCLayerTestCommon.h: Added. * tests/CCSolidColorLayerImplTest.cpp: Added. (CCLayerTestCommon::TEST): * tests/CCTiledLayerImplTest.cpp: Canonical link: https://commits.webkit.org/93668@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@105634 268f45cc-cd09-0410-ab3c-d52691b4dbfc
- Loading branch information
W. James MacLean
committed
Jan 23, 2012
1 parent
c74c039
commit 61af71e6aa23222da85669171285b398f941f763
Showing
17 changed files
with
685 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@@ -0,0 +1,57 @@ | ||
/* | ||
* 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" | ||
|
||
#if USE(ACCELERATED_COMPOSITING) | ||
|
||
#include "SolidColorLayerChromium.h" | ||
|
||
#include "cc/CCSolidColorLayerImpl.h" | ||
|
||
namespace WebCore { | ||
|
||
PassRefPtr<CCLayerImpl> SolidColorLayerChromium::createCCLayerImpl() | ||
{ | ||
return CCSolidColorLayerImpl::create(id()); | ||
} | ||
|
||
PassRefPtr<SolidColorLayerChromium> SolidColorLayerChromium::create() | ||
{ | ||
return adoptRef(new SolidColorLayerChromium()); | ||
} | ||
|
||
SolidColorLayerChromium::SolidColorLayerChromium() | ||
: LayerChromium() | ||
{ | ||
} | ||
|
||
SolidColorLayerChromium::~SolidColorLayerChromium() | ||
{ | ||
} | ||
|
||
} // namespace WebCore | ||
|
||
#endif // USE(ACCELERATED_COMPOSITING) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@@ -0,0 +1,54 @@ | ||
/* | ||
* 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 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 SolidColorLayerChromium_h | ||
#define SolidColorLayerChromium_h | ||
|
||
#if USE(ACCELERATED_COMPOSITING) | ||
|
||
#include "LayerChromium.h" | ||
|
||
namespace WebCore { | ||
|
||
class LayerTilerChromium; | ||
|
||
// A Layer that renders a solid color. The color is specified by using | ||
// setBackgroundColor() on the base class. | ||
class SolidColorLayerChromium : public LayerChromium { | ||
public: | ||
virtual PassRefPtr<CCLayerImpl> createCCLayerImpl(); | ||
static PassRefPtr<SolidColorLayerChromium> create(); | ||
|
||
virtual ~SolidColorLayerChromium(); | ||
|
||
protected: | ||
SolidColorLayerChromium(); | ||
}; | ||
|
||
} | ||
#endif // USE(ACCELERATED_COMPOSITING) | ||
|
||
#endif | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@@ -0,0 +1,74 @@ | ||
/* | ||
* 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" | ||
|
||
#if USE(ACCELERATED_COMPOSITING) | ||
|
||
#include "cc/CCSolidColorLayerImpl.h" | ||
|
||
#include "LayerRendererChromium.h" | ||
#include "cc/CCSolidColorDrawQuad.h" | ||
#include <wtf/MathExtras.h> | ||
#include <wtf/text/WTFString.h> | ||
|
||
using namespace std; | ||
|
||
namespace WebCore { | ||
|
||
CCSolidColorLayerImpl::CCSolidColorLayerImpl(int id) | ||
: CCLayerImpl(id) | ||
, m_tileSize(256) | ||
{ | ||
} | ||
|
||
CCSolidColorLayerImpl::~CCSolidColorLayerImpl() | ||
{ | ||
} | ||
|
||
TransformationMatrix CCSolidColorLayerImpl::quadTransform() const | ||
{ | ||
TransformationMatrix solidColorTransform = drawTransform(); | ||
solidColorTransform.translate(-bounds().width() / 2.0, -bounds().height() / 2.0); | ||
|
||
return solidColorTransform; | ||
} | ||
|
||
void CCSolidColorLayerImpl::appendQuads(CCQuadList& quadList, const CCSharedQuadState* sharedQuadState) | ||
{ | ||
// We create a series of smaller quads instead of just one large one so that the | ||
// culler can reduce the total pixels drawn. | ||
int width = bounds().width(); | ||
int height = bounds().height(); | ||
for (int x = 0; x < width; x += m_tileSize) { | ||
for (int y = 0; y < height; y += m_tileSize) { | ||
IntRect solidTileRect(x, y, min(width - x, m_tileSize), min(height - y, m_tileSize)); | ||
quadList.append(CCSolidColorDrawQuad::create(sharedQuadState, solidTileRect, backgroundColor())); | ||
} | ||
} | ||
} | ||
|
||
} // namespace WebCore | ||
#endif // USE(ACCELERATED_COMPOSITING) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@@ -0,0 +1,58 @@ | ||
/* | ||
* 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. | ||
*/ | ||
|
||
#ifndef CCSolidColorLayerImpl_h | ||
#define CCSolidColorLayerImpl_h | ||
|
||
#include "TransformationMatrix.h" | ||
#include "cc/CCLayerImpl.h" | ||
|
||
namespace WebCore { | ||
|
||
class LayerRendererChromium; | ||
|
||
class CCSolidColorLayerImpl : public CCLayerImpl { | ||
public: | ||
static PassRefPtr<CCSolidColorLayerImpl> create(int id) | ||
{ | ||
return adoptRef(new CCSolidColorLayerImpl(id)); | ||
} | ||
virtual ~CCSolidColorLayerImpl(); | ||
|
||
virtual TransformationMatrix quadTransform() const; | ||
virtual void appendQuads(CCQuadList&, const CCSharedQuadState*); | ||
|
||
protected: | ||
explicit CCSolidColorLayerImpl(int id); | ||
|
||
private: | ||
virtual const char* layerTypeAsString() const { return "SolidColorLayer"; } | ||
|
||
const int m_tileSize; | ||
}; | ||
|
||
} | ||
|
||
#endif // CCSolidColorLayerImpl_h |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.