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

Side by Side Diff: cc/resources/picture.cc

Issue 111143005: cc: Gather and lock/unlock SkDiscardablePixelRefs instead of skia::LazyPixelRefs. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: s/lazy/discardable/ to fix cc_unittests Created 6 years, 11 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « cc/resources/picture.h ('k') | cc/resources/picture_pile_impl.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 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 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.h" 5 #include "cc/resources/picture.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <limits> 8 #include <limits>
9 #include <set> 9 #include <set>
10 10
11 #include "base/base64.h" 11 #include "base/base64.h"
12 #include "base/debug/trace_event.h" 12 #include "base/debug/trace_event.h"
13 #include "base/values.h" 13 #include "base/values.h"
14 #include "cc/base/math_util.h" 14 #include "cc/base/math_util.h"
15 #include "cc/base/util.h" 15 #include "cc/base/util.h"
16 #include "cc/debug/traced_picture.h" 16 #include "cc/debug/traced_picture.h"
17 #include "cc/debug/traced_value.h" 17 #include "cc/debug/traced_value.h"
18 #include "cc/layers/content_layer_client.h" 18 #include "cc/layers/content_layer_client.h"
19 #include "skia/ext/lazy_pixel_ref_utils.h" 19 #include "skia/ext/pixel_ref_utils.h"
20 #include "third_party/skia/include/core/SkCanvas.h" 20 #include "third_party/skia/include/core/SkCanvas.h"
21 #include "third_party/skia/include/core/SkData.h" 21 #include "third_party/skia/include/core/SkData.h"
22 #include "third_party/skia/include/core/SkDrawFilter.h" 22 #include "third_party/skia/include/core/SkDrawFilter.h"
23 #include "third_party/skia/include/core/SkPaint.h" 23 #include "third_party/skia/include/core/SkPaint.h"
24 #include "third_party/skia/include/core/SkStream.h" 24 #include "third_party/skia/include/core/SkStream.h"
25 #include "third_party/skia/include/utils/SkPictureUtils.h" 25 #include "third_party/skia/include/utils/SkPictureUtils.h"
26 #include "ui/gfx/codec/jpeg_codec.h" 26 #include "ui/gfx/codec/jpeg_codec.h"
27 #include "ui/gfx/codec/png_codec.h" 27 #include "ui/gfx/codec/png_codec.h"
28 #include "ui/gfx/rect_conversions.h" 28 #include "ui/gfx/rect_conversions.h"
29 #include "ui/gfx/skia_util.h" 29 #include "ui/gfx/skia_util.h"
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after
256 tile_grid_info.fTileInterval.height() + 256 tile_grid_info.fTileInterval.height() +
257 2 * tile_grid_info.fMargin.height()); 257 2 * tile_grid_info.fMargin.height());
258 DCHECK_GT(cell_size_.width(), 0); 258 DCHECK_GT(cell_size_.width(), 0);
259 DCHECK_GT(cell_size_.height(), 0); 259 DCHECK_GT(cell_size_.height(), 0);
260 260
261 int min_x = std::numeric_limits<int>::max(); 261 int min_x = std::numeric_limits<int>::max();
262 int min_y = std::numeric_limits<int>::max(); 262 int min_y = std::numeric_limits<int>::max();
263 int max_x = 0; 263 int max_x = 0;
264 int max_y = 0; 264 int max_y = 0;
265 265
266 skia::LazyPixelRefList pixel_refs; 266 skia::DiscardablePixelRefList pixel_refs;
267 skia::LazyPixelRefUtils::GatherPixelRefs(picture_.get(), &pixel_refs); 267 skia::PixelRefUtils::GatherDiscardablePixelRefs(picture_.get(), &pixel_refs);
268 for (skia::LazyPixelRefList::const_iterator it = pixel_refs.begin(); 268 for (skia::DiscardablePixelRefList::const_iterator it = pixel_refs.begin();
269 it != pixel_refs.end(); 269 it != pixel_refs.end();
270 ++it) { 270 ++it) {
271 gfx::Point min( 271 gfx::Point min(
272 RoundDown(static_cast<int>(it->pixel_ref_rect.x()), 272 RoundDown(static_cast<int>(it->pixel_ref_rect.x()),
273 cell_size_.width()), 273 cell_size_.width()),
274 RoundDown(static_cast<int>(it->pixel_ref_rect.y()), 274 RoundDown(static_cast<int>(it->pixel_ref_rect.y()),
275 cell_size_.height())); 275 cell_size_.height()));
276 gfx::Point max( 276 gfx::Point max(
277 RoundDown(static_cast<int>(std::ceil(it->pixel_ref_rect.right())), 277 RoundDown(static_cast<int>(std::ceil(it->pixel_ref_rect.right())),
278 cell_size_.width()), 278 cell_size_.width()),
279 RoundDown(static_cast<int>(std::ceil(it->pixel_ref_rect.bottom())), 279 RoundDown(static_cast<int>(std::ceil(it->pixel_ref_rect.bottom())),
280 cell_size_.height())); 280 cell_size_.height()));
281 281
282 for (int y = min.y(); y <= max.y(); y += cell_size_.height()) { 282 for (int y = min.y(); y <= max.y(); y += cell_size_.height()) {
283 for (int x = min.x(); x <= max.x(); x += cell_size_.width()) { 283 for (int x = min.x(); x <= max.x(); x += cell_size_.width()) {
284 PixelRefMapKey key(x, y); 284 PixelRefMapKey key(x, y);
285 pixel_refs_[key].push_back(it->lazy_pixel_ref); 285 pixel_refs_[key].push_back(it->pixel_ref);
286 } 286 }
287 } 287 }
288 288
289 min_x = std::min(min_x, min.x()); 289 min_x = std::min(min_x, min.x());
290 min_y = std::min(min_y, min.y()); 290 min_y = std::min(min_y, min.y());
291 max_x = std::max(max_x, max.x()); 291 max_x = std::max(max_x, max.x());
292 max_y = std::max(max_y, max.y()); 292 max_y = std::max(max_y, max.y());
293 } 293 }
294 294
295 min_pixel_cell_ = gfx::Point(min_x, min_y); 295 min_pixel_cell_ = gfx::Point(min_x, min_y);
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
481 scoped_refptr<base::debug::ConvertableToTraceFormat> 481 scoped_refptr<base::debug::ConvertableToTraceFormat>
482 Picture::AsTraceableRecordData() const { 482 Picture::AsTraceableRecordData() const {
483 scoped_ptr<base::DictionaryValue> record_data(new base::DictionaryValue()); 483 scoped_ptr<base::DictionaryValue> record_data(new base::DictionaryValue());
484 record_data->Set("picture_id", TracedValue::CreateIDRef(this).release()); 484 record_data->Set("picture_id", TracedValue::CreateIDRef(this).release());
485 record_data->SetInteger("width", layer_rect_.width()); 485 record_data->SetInteger("width", layer_rect_.width());
486 record_data->SetInteger("height", layer_rect_.height()); 486 record_data->SetInteger("height", layer_rect_.height());
487 return TracedValue::FromValue(record_data.release()); 487 return TracedValue::FromValue(record_data.release());
488 } 488 }
489 489
490 } // namespace cc 490 } // namespace cc
OLDNEW
« no previous file with comments | « cc/resources/picture.h ('k') | cc/resources/picture_pile_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698