In iossim, ignore harmless messages from launchd.
[chromium-blink-merge.git] / cc / picture_layer_tiling.h
blobb6c7b7d7ec85a4e7b1e29a3421cbcef6152e8b38
1 // Copyright 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef CC_PICTURE_LAYER_TILING_H_
6 #define CC_PICTURE_LAYER_TILING_H_
8 #include "base/basictypes.h"
9 #include "base/hash_tables.h"
10 #include "base/memory/scoped_ptr.h"
11 #include "cc/cc_export.h"
12 #include "cc/hash_pair.h"
13 #include "cc/region.h"
14 #include "cc/tile.h"
15 #include "cc/tiling_data.h"
16 #include "ui/gfx/rect.h"
18 namespace cc {
20 class PictureLayerTiling;
22 class PictureLayerTilingClient {
23 public:
24 virtual scoped_refptr<Tile> CreateTile(PictureLayerTiling*, gfx::Rect) = 0;
27 class CC_EXPORT PictureLayerTiling {
28 public:
29 ~PictureLayerTiling();
31 static scoped_ptr<PictureLayerTiling> Create(float contents_scale,
32 gfx::Size tile_size);
33 scoped_ptr<PictureLayerTiling> Clone() const;
35 const PictureLayerTiling& operator=(const PictureLayerTiling&);
37 void SetLayerBounds(gfx::Size layer_bounds);
38 void Invalidate(const Region& layer_invalidation);
40 void SetClient(PictureLayerTilingClient* client);
42 gfx::Rect ContentRect() const;
43 float contents_scale() const { return contents_scale_; }
45 // Iterate over all tiles to fill content_rect. Even if tiles are invalid
46 // (i.e. no valid resource) this tiling should still iterate over them.
47 // The union of all geometry_rect calls for each element iterated over should
48 // exactly equal content_rect and no two geometry_rects should intersect.
49 class CC_EXPORT Iterator {
50 public:
51 Iterator();
52 Iterator(PictureLayerTiling* tiling, float dest_scale, gfx::Rect rect);
53 ~Iterator();
55 // Visible rect (no borders), always in the space of content_rect,
56 // regardless of the contents scale of the tiling.
57 gfx::Rect geometry_rect() const;
58 // Texture rect (in texels) for geometry_rect
59 gfx::RectF texture_rect() const;
60 gfx::Size texture_size() const;
62 Tile* operator->() const { return current_tile_; }
63 Tile* operator*() const { return current_tile_; }
65 Iterator& operator++();
66 operator bool() const { return tile_j_ <= bottom_; }
68 private:
69 PictureLayerTiling* tiling_;
70 gfx::Rect dest_rect_;
71 float dest_to_content_scale_;
73 Tile* current_tile_;
74 gfx::Rect current_geometry_rect_;
75 int tile_i_;
76 int tile_j_;
77 int left_;
78 int top_;
79 int right_;
80 int bottom_;
82 friend class PictureLayerTiling;
85 Region OpaqueRegionInContentRect(const gfx::Rect&) const;
87 void Reset() { return tiles_.clear(); }
89 void UpdateTilePriorities(
90 WhichTree tree,
91 const gfx::Size& device_viewport,
92 float layer_content_scale_x,
93 float layer_content_scale_y,
94 const gfx::Transform& last_screen_transform,
95 const gfx::Transform& current_screen_transform,
96 double time_delta);
98 protected:
99 typedef std::pair<int, int> TileMapKey;
100 typedef base::hash_map<TileMapKey, scoped_refptr<Tile> > TileMap;
102 PictureLayerTiling(float contents_scale, gfx::Size tileSize);
103 Tile* TileAt(int, int) const;
104 void CreateTile(int i, int j);
106 PictureLayerTilingClient* client_;
107 float contents_scale_;
108 gfx::Size layer_bounds_;
109 TileMap tiles_;
110 TilingData tiling_data_;
112 friend class Iterator;
115 } // namespace cc
117 #endif // CC_PICTURE_LAYER_TILING_H_