OLD | NEW |
---|---|
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "cc/resources/picture_pile_base.h" | 5 #include "cc/resources/picture_pile_base.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
11 #include "base/values.h" | |
12 #include "cc/base/math_util.h" | |
13 #include "cc/debug/traced_value.h" | |
11 #include "third_party/skia/include/core/SkColor.h" | 14 #include "third_party/skia/include/core/SkColor.h" |
12 #include "ui/gfx/rect_conversions.h" | 15 #include "ui/gfx/rect_conversions.h" |
13 | 16 |
14 namespace { | 17 namespace { |
15 // Dimensions of the tiles in this picture pile as well as the dimensions of | 18 // Dimensions of the tiles in this picture pile as well as the dimensions of |
16 // the base picture in each tile. | 19 // the base picture in each tile. |
17 const int kBasePictureSize = 3000; | 20 const int kBasePictureSize = 3000; |
18 const int kTileGridBorderPixels = 1; | 21 const int kTileGridBorderPixels = 1; |
19 } | 22 } |
20 | 23 |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
166 | 169 |
167 bool PicturePileBase::CanRaster(float contents_scale, gfx::Rect content_rect) { | 170 bool PicturePileBase::CanRaster(float contents_scale, gfx::Rect content_rect) { |
168 if (tiling_.total_size().IsEmpty()) | 171 if (tiling_.total_size().IsEmpty()) |
169 return false; | 172 return false; |
170 gfx::Rect layer_rect = gfx::ToEnclosingRect( | 173 gfx::Rect layer_rect = gfx::ToEnclosingRect( |
171 gfx::ScaleRect(content_rect, 1.f / contents_scale)); | 174 gfx::ScaleRect(content_rect, 1.f / contents_scale)); |
172 layer_rect.Intersect(gfx::Rect(tiling_.total_size())); | 175 layer_rect.Intersect(gfx::Rect(tiling_.total_size())); |
173 return recorded_region_.Contains(layer_rect); | 176 return recorded_region_.Contains(layer_rect); |
174 } | 177 } |
175 | 178 |
179 scoped_ptr<base::Value> PicturePileBase::AsValue() const { | |
180 scoped_ptr<base::ListValue> rects(new base::ListValue()); | |
enne (OOO)
2013/05/14 15:55:18
rects => pictures?
| |
181 gfx::Rect layer_rect(tiling_.total_size()); /* enne, insane or not? */ | |
enne (OOO)
2013/05/14 15:55:18
This is right. You could also simplify this a lit
| |
182 for (TilingData::Iterator tile_iter(&tiling_, layer_rect); | |
183 tile_iter; ++tile_iter) { | |
184 PictureListMap::const_iterator map_iter = | |
185 picture_list_map_.find(tile_iter.index()); | |
186 if (map_iter == picture_list_map_.end()) | |
187 continue; | |
188 const PictureList& pic_list= map_iter->second; | |
189 if (pic_list.empty()) | |
190 continue; | |
191 for (PictureList::const_reverse_iterator i = pic_list.rbegin(); | |
192 i != pic_list.rend(); ++i) { | |
193 Picture* picture = (*i).get(); | |
194 rects->Append(TracedValue::CreateIDRef(picture).release()); | |
195 } | |
196 } | |
197 return rects.PassAs<base::Value>(); | |
198 } | |
199 | |
176 } // namespace cc | 200 } // namespace cc |
OLD | NEW |