Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 |
| (...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 218 | 218 |
| 219 clones_.clear(); | 219 clones_.clear(); |
| 220 for (int i = 0; i < num_threads; i++) { | 220 for (int i = 0; i < num_threads; i++) { |
| 221 scoped_refptr<Picture> clone = make_scoped_refptr( | 221 scoped_refptr<Picture> clone = make_scoped_refptr( |
| 222 new Picture(skia::AdoptRef(new SkPicture(clones[i])), | 222 new Picture(skia::AdoptRef(new SkPicture(clones[i])), |
| 223 layer_rect_, | 223 layer_rect_, |
| 224 opaque_rect_, | 224 opaque_rect_, |
| 225 pixel_refs_)); | 225 pixel_refs_)); |
| 226 clones_.push_back(clone); | 226 clones_.push_back(clone); |
| 227 | 227 |
| 228 TRACE_EVENT_OBJECT_SNAPSHOT_WITH_ID(TRACE_DISABLED_BY_DEFAULT("cc.debug"), | 228 clone->EmitTraceSnapshot(); |
| 229 "cc::Picture", clone.get(), TracedPicture::AsTraceablePicture(clone)); | |
| 230 } | 229 } |
| 231 } | 230 } |
| 232 | 231 |
| 233 void Picture::Record(ContentLayerClient* painter, | 232 void Picture::Record(ContentLayerClient* painter, |
| 234 const SkTileGridPicture::TileGridInfo& tile_grid_info, | 233 const SkTileGridPicture::TileGridInfo& tile_grid_info, |
| 235 RenderingStats* stats) { | 234 RenderingStats* stats) { |
| 236 TRACE_EVENT2("cc", "Picture::Record", | 235 TRACE_EVENT2("cc", "Picture::Record", |
| 237 "width", layer_rect_.width(), | 236 "width", layer_rect_.width(), |
| 238 "height", layer_rect_.height()); | 237 "height", layer_rect_.height()); |
| 239 | 238 |
| (...skipping 26 matching lines...) Expand all Loading... | |
| 266 stats->total_record_time += base::TimeTicks::Now() - begin_record_time; | 265 stats->total_record_time += base::TimeTicks::Now() - begin_record_time; |
| 267 stats->total_pixels_recorded += | 266 stats->total_pixels_recorded += |
| 268 layer_rect_.width() * layer_rect_.height(); | 267 layer_rect_.width() * layer_rect_.height(); |
| 269 } | 268 } |
| 270 | 269 |
| 271 canvas->restore(); | 270 canvas->restore(); |
| 272 picture_->endRecording(); | 271 picture_->endRecording(); |
| 273 | 272 |
| 274 opaque_rect_ = gfx::ToEnclosedRect(opaque_layer_rect); | 273 opaque_rect_ = gfx::ToEnclosedRect(opaque_layer_rect); |
| 275 | 274 |
| 276 TRACE_EVENT_OBJECT_SNAPSHOT_WITH_ID(TRACE_DISABLED_BY_DEFAULT("cc.debug"), | 275 EmitTraceSnapshot(); |
| 277 "cc::Picture", this, TracedPicture::AsTraceablePicture(this)); | |
| 278 } | 276 } |
| 279 | 277 |
| 280 void Picture::GatherPixelRefs( | 278 void Picture::GatherPixelRefs( |
| 281 const SkTileGridPicture::TileGridInfo& tile_grid_info, | 279 const SkTileGridPicture::TileGridInfo& tile_grid_info, |
| 282 RenderingStats* stats) { | 280 RenderingStats* stats) { |
| 283 TRACE_EVENT2("cc", "Picture::GatherPixelRefs", | 281 TRACE_EVENT2("cc", "Picture::GatherPixelRefs", |
| 284 "width", layer_rect_.width(), | 282 "width", layer_rect_.width(), |
| 285 "height", layer_rect_.height()); | 283 "height", layer_rect_.height()); |
| 286 | 284 |
| 287 DCHECK(picture_); | 285 DCHECK(picture_); |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 381 size_t serialized_size = stream.bytesWritten(); | 379 size_t serialized_size = stream.bytesWritten(); |
| 382 scoped_ptr<char[]> serialized_picture(new char[serialized_size]); | 380 scoped_ptr<char[]> serialized_picture(new char[serialized_size]); |
| 383 stream.copyTo(serialized_picture.get()); | 381 stream.copyTo(serialized_picture.get()); |
| 384 std::string b64_picture; | 382 std::string b64_picture; |
| 385 base::Base64Encode(std::string(serialized_picture.get(), serialized_size), | 383 base::Base64Encode(std::string(serialized_picture.get(), serialized_size), |
| 386 &b64_picture); | 384 &b64_picture); |
| 387 res->SetString("skp64", b64_picture); | 385 res->SetString("skp64", b64_picture); |
| 388 return res.PassAs<base::Value>(); | 386 return res.PassAs<base::Value>(); |
| 389 } | 387 } |
| 390 | 388 |
| 389 void Picture::DidBeginTracing() { | |
|
enne (OOO)
2013/06/01 03:10:45
I'm not sure this function really needs to exist.
| |
| 390 EmitTraceSnapshot(); | |
| 391 } | |
| 392 | |
| 391 base::LazyInstance<Picture::PixelRefs> | 393 base::LazyInstance<Picture::PixelRefs> |
| 392 Picture::PixelRefIterator::empty_pixel_refs_; | 394 Picture::PixelRefIterator::empty_pixel_refs_; |
| 393 | 395 |
| 394 Picture::PixelRefIterator::PixelRefIterator() | 396 Picture::PixelRefIterator::PixelRefIterator() |
| 395 : picture_(NULL), | 397 : picture_(NULL), |
| 396 current_pixel_refs_(empty_pixel_refs_.Pointer()), | 398 current_pixel_refs_(empty_pixel_refs_.Pointer()), |
| 397 current_index_(0), | 399 current_index_(0), |
| 398 min_point_(-1, -1), | 400 min_point_(-1, -1), |
| 399 max_point_(-1, -1), | 401 max_point_(-1, -1), |
| 400 current_x_(0), | 402 current_x_(0), |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 491 scoped_ptr<base::DictionaryValue> raster_data(new base::DictionaryValue()); | 493 scoped_ptr<base::DictionaryValue> raster_data(new base::DictionaryValue()); |
| 492 raster_data->Set("picture_id", TracedValue::CreateIDRef(this).release()); | 494 raster_data->Set("picture_id", TracedValue::CreateIDRef(this).release()); |
| 493 raster_data->SetDouble("scale", scale); | 495 raster_data->SetDouble("scale", scale); |
| 494 raster_data->SetDouble("rect_x", rect.x()); | 496 raster_data->SetDouble("rect_x", rect.x()); |
| 495 raster_data->SetDouble("rect_y", rect.y()); | 497 raster_data->SetDouble("rect_y", rect.y()); |
| 496 raster_data->SetDouble("rect_width", rect.width()); | 498 raster_data->SetDouble("rect_width", rect.width()); |
| 497 raster_data->SetDouble("rect_height", rect.height()); | 499 raster_data->SetDouble("rect_height", rect.height()); |
| 498 return TracedValue::FromValue(raster_data.release()); | 500 return TracedValue::FromValue(raster_data.release()); |
| 499 } | 501 } |
| 500 | 502 |
| 503 void Picture::EmitTraceSnapshot() { | |
| 504 TRACE_EVENT_OBJECT_SNAPSHOT_WITH_ID(TRACE_DISABLED_BY_DEFAULT("cc.debug"), | |
| 505 "cc::Picture", this, TracedPicture::AsTraceablePicture(this)); | |
| 506 } | |
| 507 | |
| 501 } // namespace cc | 508 } // namespace cc |
| OLD | NEW |