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 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
260 | 260 |
261 DCHECK(!picture_); | 261 DCHECK(!picture_); |
262 DCHECK(!tile_grid_info.fTileInterval.isEmpty()); | 262 DCHECK(!tile_grid_info.fTileInterval.isEmpty()); |
263 | 263 |
264 SkTileGridFactory factory(tile_grid_info); | 264 SkTileGridFactory factory(tile_grid_info); |
265 SkPictureRecorder recorder; | 265 SkPictureRecorder recorder; |
266 | 266 |
267 scoped_ptr<EXPERIMENTAL::SkRecording> recording; | 267 scoped_ptr<EXPERIMENTAL::SkRecording> recording; |
268 | 268 |
269 skia::RefPtr<SkCanvas> canvas; | 269 skia::RefPtr<SkCanvas> canvas; |
270 canvas = skia::SharePtr( | 270 canvas = skia::SharePtr(recorder.beginRecording( |
271 recorder.beginRecording(layer_rect_.width(), | 271 layer_rect_.width(), layer_rect_.height(), &factory)); |
272 layer_rect_.height(), | |
273 &factory, | |
274 SkPicture::kUsePathBoundsForClip_RecordingFlag)); | |
275 | 272 |
276 ContentLayerClient::GraphicsContextStatus graphics_context_status = | 273 ContentLayerClient::GraphicsContextStatus graphics_context_status = |
277 ContentLayerClient::GRAPHICS_CONTEXT_ENABLED; | 274 ContentLayerClient::GRAPHICS_CONTEXT_ENABLED; |
278 | 275 |
279 switch (recording_mode) { | 276 switch (recording_mode) { |
280 case RECORD_NORMALLY: | 277 case RECORD_NORMALLY: |
281 // Already setup for normal recording. | 278 // Already setup for normal recording. |
282 break; | 279 break; |
283 case RECORD_WITH_SK_NULL_CANVAS: | 280 case RECORD_WITH_SK_NULL_CANVAS: |
284 canvas = skia::AdoptRef(SkCreateNullCanvas()); | 281 canvas = skia::AdoptRef(SkCreateNullCanvas()); |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
441 | 438 |
442 scoped_ptr<base::Value> Picture::AsValue() const { | 439 scoped_ptr<base::Value> Picture::AsValue() const { |
443 SkDynamicMemoryWStream stream; | 440 SkDynamicMemoryWStream stream; |
444 | 441 |
445 if (playback_) { | 442 if (playback_) { |
446 // SkPlayback can't serialize itself, so re-record into an SkPicture. | 443 // SkPlayback can't serialize itself, so re-record into an SkPicture. |
447 SkPictureRecorder recorder; | 444 SkPictureRecorder recorder; |
448 skia::RefPtr<SkCanvas> canvas(skia::SharePtr(recorder.beginRecording( | 445 skia::RefPtr<SkCanvas> canvas(skia::SharePtr(recorder.beginRecording( |
449 layer_rect_.width(), | 446 layer_rect_.width(), |
450 layer_rect_.height(), | 447 layer_rect_.height(), |
451 NULL, // Default (no) bounding-box hierarchy is fastest. | 448 NULL))); // Default (no) bounding-box hierarchy is fastest. |
452 SkPicture::kUsePathBoundsForClip_RecordingFlag))); | |
453 playback_->draw(canvas.get()); | 449 playback_->draw(canvas.get()); |
454 skia::RefPtr<SkPicture> picture(skia::AdoptRef(recorder.endRecording())); | 450 skia::RefPtr<SkPicture> picture(skia::AdoptRef(recorder.endRecording())); |
455 picture->serialize(&stream, &EncodeBitmap); | 451 picture->serialize(&stream, &EncodeBitmap); |
456 } else { | 452 } else { |
457 // Serialize the picture. | 453 // Serialize the picture. |
458 picture_->serialize(&stream, &EncodeBitmap); | 454 picture_->serialize(&stream, &EncodeBitmap); |
459 } | 455 } |
460 | 456 |
461 // Encode the picture as base64. | 457 // Encode the picture as base64. |
462 scoped_ptr<base::DictionaryValue> res(new base::DictionaryValue()); | 458 scoped_ptr<base::DictionaryValue> res(new base::DictionaryValue()); |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
596 | 592 |
597 scoped_refptr<base::debug::ConvertableToTraceFormat> | 593 scoped_refptr<base::debug::ConvertableToTraceFormat> |
598 Picture::AsTraceableRecordData() const { | 594 Picture::AsTraceableRecordData() const { |
599 scoped_ptr<base::DictionaryValue> record_data(new base::DictionaryValue()); | 595 scoped_ptr<base::DictionaryValue> record_data(new base::DictionaryValue()); |
600 record_data->Set("picture_id", TracedValue::CreateIDRef(this).release()); | 596 record_data->Set("picture_id", TracedValue::CreateIDRef(this).release()); |
601 record_data->Set("layer_rect", MathUtil::AsValue(layer_rect_).release()); | 597 record_data->Set("layer_rect", MathUtil::AsValue(layer_rect_).release()); |
602 return TracedValue::FromValue(record_data.release()); | 598 return TracedValue::FromValue(record_data.release()); |
603 } | 599 } |
604 | 600 |
605 } // namespace cc | 601 } // namespace cc |
OLD | NEW |