summaryrefslogtreecommitdiffstats
path: root/cc/picture_layer_tiling.h
diff options
context:
space:
mode:
authorenne@chromium.org <enne@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-11-15 19:57:03 +0000
committerenne@chromium.org <enne@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-11-15 19:57:03 +0000
commit9b18c10a99bf44dcbc1372b78d7e84e1314f6f20 (patch)
tree25d166589054f1ed15d77b0521669e72991bbfc2 /cc/picture_layer_tiling.h
parent2299dcf5bc16896c098162de817d54c68c76a6f6 (diff)
downloadchromium_src-9b18c10a99bf44dcbc1372b78d7e84e1314f6f20.zip
chromium_src-9b18c10a99bf44dcbc1372b78d7e84e1314f6f20.tar.gz
chromium_src-9b18c10a99bf44dcbc1372b78d7e84e1314f6f20.tar.bz2
cc: Add PictureLayerTiling for impl-side painting
This adds an interface for generating/iterating/creating tiles and tilings. PictureLayerImpl now knows a lot less about the internals of the tiling (yay). TBR=nduca@chromium.org BUG=155209 Review URL: https://chromiumcodereview.appspot.com/11377176 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@167997 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'cc/picture_layer_tiling.h')
-rw-r--r--cc/picture_layer_tiling.h98
1 files changed, 98 insertions, 0 deletions
diff --git a/cc/picture_layer_tiling.h b/cc/picture_layer_tiling.h
new file mode 100644
index 0000000..1c08ea1
--- /dev/null
+++ b/cc/picture_layer_tiling.h
@@ -0,0 +1,98 @@
+// 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.
+
+#ifndef CC_PICTURE_LAYER_TILING_H_
+#define CC_PICTURE_LAYER_TILING_H_
+
+#include "base/basictypes.h"
+#include "base/hash_tables.h"
+#include "base/memory/scoped_ptr.h"
+#include "cc/cc_export.h"
+#include "cc/hash_pair.h"
+#include "cc/region.h"
+#include "cc/tile.h"
+#include "cc/tiling_data.h"
+#include "ui/gfx/rect.h"
+
+namespace cc {
+
+class PictureLayerTiling;
+
+class PictureLayerTilingClient {
+ public:
+ virtual scoped_refptr<Tile> CreateTile(PictureLayerTiling*, gfx::Rect) = 0;
+};
+
+class CC_EXPORT PictureLayerTiling {
+ public:
+ ~PictureLayerTiling();
+
+ static scoped_ptr<PictureLayerTiling> Create(gfx::Size tile_size);
+ scoped_ptr<PictureLayerTiling> Clone() const;
+
+ const PictureLayerTiling& operator=(const PictureLayerTiling&);
+
+ void SetBounds(gfx::Size);
+ gfx::Size bounds() const { return tiling_data_.total_size(); }
+
+ void create_tiles(gfx::Rect);
+ void set_client(PictureLayerTilingClient* client);
+
+ class Iterator {
+ public:
+ Iterator(PictureLayerTiling* tiling, gfx::Rect content_rect);
+ ~Iterator();
+
+ // Visible rect (no borders)
+ gfx::Rect geometry_rect() const;
+ // Full tile rect (not clipped, with borders)
+ gfx::Rect full_tile_rect() const;
+ // Texture rect (in texels) for geometry_rect
+ gfx::Rect texture_rect() const;
+ gfx::Rect opaque_rect() const;
+ gfx::Size texture_size() const;
+
+ Tile* operator->() const { return current_tile_; }
+ Tile* operator*() const { return current_tile_; }
+
+ Iterator& operator++();
+ bool operator==(const Iterator& other) const;
+ bool operator!=(const Iterator& other) const;
+ operator bool() const { return current_tile_; }
+
+ private:
+ PictureLayerTiling* tiling_;
+ Tile* current_tile_;
+ gfx::Rect content_rect_;
+ int tile_i_;
+ int tile_j_;
+ int left_;
+ int top_;
+ int right_;
+ int bottom_;
+
+ friend class PictureLayerTiling;
+ };
+
+ Region OpaqueRegionInContentRect(const gfx::Rect&) const;
+
+ void Reset() { return tiles_.clear(); }
+
+ protected:
+ typedef std::pair<int, int> TileMapKey;
+ typedef base::hash_map<TileMapKey, scoped_refptr<Tile> > TileMap;
+
+ PictureLayerTiling(gfx::Size tileSize);
+ Tile* TileAt(int, int) const;
+
+ PictureLayerTilingClient* client_;
+ TileMap tiles_;
+ TilingData tiling_data_;
+
+ friend class Iterator;
+};
+
+} // namespace cc
+
+#endif // CC_PICTURE_LAYER_TILING_H_