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

Unified Diff: ui/cc/cc/CCLayerTilingData.cpp

Issue 10701016: Initial import attempt, just to play with. Many things disabled/removed (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 6 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 | « ui/cc/cc/CCLayerTilingData.h ('k') | ui/cc/cc/CCLayerTreeHost.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/cc/cc/CCLayerTilingData.cpp
diff --git a/ui/cc/cc/CCLayerTilingData.cpp b/ui/cc/cc/CCLayerTilingData.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..823a316a3c4eb5f73459b9468a92082731579efc
--- /dev/null
+++ b/ui/cc/cc/CCLayerTilingData.cpp
@@ -0,0 +1,161 @@
+/*
+ * Copyright (C) 2011 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/CCLayerTilingData.h"
+
+using namespace std;
+
+namespace WebCore {
+
+PassOwnPtr<CCLayerTilingData> CCLayerTilingData::create(const IntSize& tileSize, BorderTexelOption border)
+{
+ return adoptPtr(new CCLayerTilingData(tileSize, border));
+}
+
+CCLayerTilingData::CCLayerTilingData(const IntSize& tileSize, BorderTexelOption border)
+ : m_tilingData(tileSize, IntSize(), border == HasBorderTexels)
+{
+ setTileSize(tileSize);
+}
+
+void CCLayerTilingData::setTileSize(const IntSize& size)
+{
+ if (tileSize() == size)
+ return;
+
+ reset();
+
+ m_tilingData.setMaxTextureSize(size);
+}
+
+const IntSize& CCLayerTilingData::tileSize() const
+{
+ return m_tilingData.maxTextureSize();
+}
+
+void CCLayerTilingData::setBorderTexelOption(BorderTexelOption borderTexelOption)
+{
+ bool borderTexels = borderTexelOption == HasBorderTexels;
+ if (hasBorderTexels() == borderTexels)
+ return;
+
+ reset();
+ m_tilingData.setHasBorderTexels(borderTexels);
+}
+
+const CCLayerTilingData& CCLayerTilingData::operator=(const CCLayerTilingData& tiler)
+{
+ m_tilingData = tiler.m_tilingData;
+
+ return *this;
+}
+
+void CCLayerTilingData::addTile(PassOwnPtr<Tile> tile, int i, int j)
+{
+ ASSERT(!tileAt(i, j));
+ tile->moveTo(i, j);
+ m_tiles.add(make_pair(i, j), tile);
+}
+
+PassOwnPtr<CCLayerTilingData::Tile> CCLayerTilingData::takeTile(int i, int j)
+{
+ return m_tiles.take(make_pair(i, j));
+}
+
+CCLayerTilingData::Tile* CCLayerTilingData::tileAt(int i, int j) const
+{
+ return m_tiles.get(make_pair(i, j));
+}
+
+void CCLayerTilingData::reset()
+{
+ m_tiles.clear();
+}
+
+void CCLayerTilingData::layerRectToTileIndices(const IntRect& layerRect, int& left, int& top, int& right, int& bottom) const
+{
+ left = m_tilingData.tileXIndexFromSrcCoord(layerRect.x());
+ top = m_tilingData.tileYIndexFromSrcCoord(layerRect.y());
+ right = m_tilingData.tileXIndexFromSrcCoord(layerRect.maxX() - 1);
+ bottom = m_tilingData.tileYIndexFromSrcCoord(layerRect.maxY() - 1);
+}
+
+IntRect CCLayerTilingData::tileRect(const Tile* tile) const
+{
+ IntRect tileRect = m_tilingData.tileBoundsWithBorder(tile->i(), tile->j());
+ tileRect.setSize(tileSize());
+ return tileRect;
+}
+
+Region CCLayerTilingData::opaqueRegionInLayerRect(const IntRect& layerRect) const
+{
+ if (layerRect.isEmpty())
+ return Region();
+
+ Region opaqueRegion;
+ int left, top, right, bottom;
+ layerRectToTileIndices(layerRect, left, top, right, bottom);
+ for (int j = top; j <= bottom; ++j) {
+ for (int i = left; i <= right; ++i) {
+ Tile* tile = tileAt(i, j);
+ if (!tile)
+ continue;
+
+ IntRect tileOpaqueRect = intersection(layerRect, tile->opaqueRect());
+ opaqueRegion.unite(tileOpaqueRect);
+ }
+ }
+ return opaqueRegion;
+}
+
+void CCLayerTilingData::setBounds(const IntSize& size)
+{
+ m_tilingData.setTotalSize(size);
+
+ // Any tiles completely outside our new bounds are invalid and should be dropped.
+ int left, top, right, bottom;
+ layerRectToTileIndices(IntRect(IntPoint(), size), left, top, right, bottom);
+ Vector<TileMapKey> invalidTileKeys;
+ for (TileMap::const_iterator it = m_tiles.begin(); it != m_tiles.end(); ++it) {
+ if (it->first.first > right || it->first.second > bottom)
+ invalidTileKeys.append(it->first);
+ }
+ for (size_t i = 0; i < invalidTileKeys.size(); ++i)
+ m_tiles.remove(invalidTileKeys[i]);
+}
+
+IntSize CCLayerTilingData::bounds() const
+{
+ return m_tilingData.totalSize();
+}
+
+} // namespace WebCore
+
+#endif // USE(ACCELERATED_COMPOSITING)
« no previous file with comments | « ui/cc/cc/CCLayerTilingData.h ('k') | ui/cc/cc/CCLayerTreeHost.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698