Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4475)

Unified Diff: cc/CCDecorationLayerImpl.cpp

Issue 10963056: [cc] Add window decoration layers (NinePatch) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: hacky rebase for Jerome to use Created 8 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « cc/CCDecorationLayerImpl.h ('k') | cc/CCDecorationLayerImplTest.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/CCDecorationLayerImpl.cpp
diff --git a/cc/CCDecorationLayerImpl.cpp b/cc/CCDecorationLayerImpl.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..42b8c5a4670648854f9eb4dc39e49a37996a9077
--- /dev/null
+++ b/cc/CCDecorationLayerImpl.cpp
@@ -0,0 +1,109 @@
+// Copyright 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "config.h"
+
+#include "CCDecorationLayerImpl.h"
+
+#include "CCQuadSink.h"
+#include "CCTextureDrawQuad.h"
+
+namespace cc {
+
+CCDecorationLayerImpl::CCDecorationLayerImpl(int id)
+ : CCLayerImpl(id)
+ , m_resourceId(0)
+{
+}
+
+CCDecorationLayerImpl::~CCDecorationLayerImpl()
+{
+}
+
+CCResourceProvider::ResourceId CCDecorationLayerImpl::contentsResourceId() const
+{
+ return 0;
+}
+
+void CCDecorationLayerImpl::dumpLayerProperties(std::string* str, int indent) const
+{
+ CCLayerImpl::dumpLayerProperties(str, indent);
+}
+
+
+void CCDecorationLayerImpl::willDraw(CCResourceProvider* resourceProvider)
+{
+}
+
+static FloatRect normalizedRect(float x, float y, float width, float height, float totalWidth, float totalHeight)
+{
+ return FloatRect(x / totalWidth, y / totalHeight, width / totalWidth, height / totalHeight);
+}
+
+void CCDecorationLayerImpl::setDecorationLayout(const IntSize& imageBounds, const IntRect& aperture)
+{
+ m_imageBounds = imageBounds;
+ m_imageAperture = aperture;
+}
+
+void CCDecorationLayerImpl::appendQuads(CCQuadSink& quadSink, CCAppendQuadsData& appendQuadsData)
+{
+ if (!m_resourceId)
+ return;
+
+ CCSharedQuadState* sharedQuadState = quadSink.useSharedQuadState(createSharedQuadState());
+ appendDebugBorderQuad(quadSink, sharedQuadState, appendQuadsData);
+
+ static const bool flipped = false;
+ static const bool premultipliedAlpha = true;
+
+ ASSERT(!bounds().isEmpty());
+
+ // decoration border widths in image space
+ int leftWidth = m_imageAperture.x();
+ int topHeight = m_imageAperture.y();
+ int rightWidth = m_imageBounds.width() - m_imageAperture.maxX();
+ int bottomHeight = m_imageBounds.height() - m_imageAperture.maxY();
+
+ IntRect topLeft(0, 0, leftWidth, topHeight);
+ IntRect topRight(bounds().width() - rightWidth, 0, rightWidth, topHeight);
+ IntRect bottomLeft(0, bounds().height() - bottomHeight, leftWidth, bottomHeight);
+ IntRect bottomRight(topRight.x(), bottomLeft.y(), rightWidth, bottomHeight);
+ IntRect top(topLeft.maxX(), 0, bounds().width() - leftWidth - rightWidth, topHeight);
+ IntRect left(0, topLeft.maxY(), leftWidth, bounds().height() - topHeight - bottomHeight);
+ IntRect right(topRight.x(), topRight.maxY(), rightWidth, left.height());
+ IntRect bottom(top.x(), bottomLeft.y(), top.width(), bottomHeight);
+
+ float imgWidth = m_imageBounds.width();
+ float imgHeight = m_imageBounds.height();
+
+ FloatRect uvTopLeft = normalizedRect(0, 0, leftWidth, topHeight, imgWidth, imgHeight);
+ FloatRect uvTopRight = normalizedRect(imgWidth - rightWidth, 0, rightWidth, topHeight, imgWidth, imgHeight);
+ FloatRect uvBottomLeft = normalizedRect(0, imgHeight - bottomHeight, leftWidth, bottomHeight, imgWidth, imgHeight);
+ FloatRect uvBottomRight = normalizedRect(imgWidth - rightWidth, imgHeight - bottomHeight, rightWidth, bottomHeight, imgWidth, imgHeight);
+ FloatRect uvTop(uvTopLeft.maxX(), 0, (imgWidth - leftWidth - rightWidth) / imgWidth, (topHeight) / imgHeight);
+ FloatRect uvLeft(0, uvTopLeft.maxY(), leftWidth / imgWidth, (imgHeight - topHeight - bottomHeight) / imgHeight);
+ FloatRect uvRight(uvTopRight.x(), uvTopRight.maxY(), rightWidth / imgWidth, uvLeft.height());
+ FloatRect uvBottom(uvTop.x(), uvBottomLeft.y(), uvTop.width(), bottomHeight / imgHeight);
+
+ quadSink.append(CCTextureDrawQuad::create(sharedQuadState, topLeft, m_resourceId, premultipliedAlpha, uvTopLeft, flipped).PassAs<CCDrawQuad>(), appendQuadsData);
+ quadSink.append(CCTextureDrawQuad::create(sharedQuadState, topRight, m_resourceId, premultipliedAlpha, uvTopRight, flipped).PassAs<CCDrawQuad>(), appendQuadsData);
+ quadSink.append(CCTextureDrawQuad::create(sharedQuadState, bottomLeft, m_resourceId, premultipliedAlpha, uvBottomLeft, flipped).PassAs<CCDrawQuad>(), appendQuadsData);
+ quadSink.append(CCTextureDrawQuad::create(sharedQuadState, bottomRight, m_resourceId, premultipliedAlpha, uvBottomRight, flipped).PassAs<CCDrawQuad>(), appendQuadsData);
+ quadSink.append(CCTextureDrawQuad::create(sharedQuadState, top, m_resourceId, premultipliedAlpha, uvTop, flipped).PassAs<CCDrawQuad>(), appendQuadsData);
+ quadSink.append(CCTextureDrawQuad::create(sharedQuadState, left, m_resourceId, premultipliedAlpha, uvLeft, flipped).PassAs<CCDrawQuad>(), appendQuadsData);
+ quadSink.append(CCTextureDrawQuad::create(sharedQuadState, right, m_resourceId, premultipliedAlpha, uvRight, flipped).PassAs<CCDrawQuad>(), appendQuadsData);
+ quadSink.append(CCTextureDrawQuad::create(sharedQuadState, bottom, m_resourceId, premultipliedAlpha, uvBottom, flipped).PassAs<CCDrawQuad>(), appendQuadsData);
+}
+
+void CCDecorationLayerImpl::didDraw(CCResourceProvider* resourceProvider)
+{
+}
+
+void CCDecorationLayerImpl::didLoseContext()
+{
+ m_resourceId = 0;
+}
+
+} // namespace WebCore
« no previous file with comments | « cc/CCDecorationLayerImpl.h ('k') | cc/CCDecorationLayerImplTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698