| OLD | NEW |
| (Empty) | |
| 1 // Copyright (c) 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. |
| 4 |
| 5 #include "skia/ext/platform_picture_skia.h" |
| 6 |
| 7 #include "skia/ext/recording_platform_device_skia.h" |
| 8 #include "third_party/skia/include/utils/SkProxyCanvas.h" |
| 9 |
| 10 namespace skia { |
| 11 |
| 12 PlatformPictureSkia::PlatformPictureSkia() : record_(NULL) { |
| 13 } |
| 14 |
| 15 PlatformPictureSkia::~PlatformPictureSkia() { |
| 16 if (record_) |
| 17 record_->unref(); |
| 18 } |
| 19 |
| 20 SkCanvas* PlatformPictureSkia::beginRecording(int width, int height) { |
| 21 if (record_) |
| 22 record_->unref(); |
| 23 record_ = new SkProxyCanvas; |
| 24 record_->setProxy(picture_.beginRecording(width, height)); |
| 25 |
| 26 // Set device to handle platform paint. |
| 27 SkDevice* device = RecordingPlatformDeviceSkia::Create( |
| 28 &picture_, width, height); |
| 29 record_->setDevice(device); |
| 30 device->unref(); // Created with refcount 1, and setDevice refs. |
| 31 |
| 32 return record_; |
| 33 } |
| 34 |
| 35 void PlatformPictureSkia::endRecording() { |
| 36 picture_.endRecording(); |
| 37 |
| 38 if (record_) { |
| 39 record_->unref(); |
| 40 record_ = NULL; |
| 41 } |
| 42 } |
| 43 |
| 44 void PlatformPictureSkia::drawInto(SkCanvas* canvas) { |
| 45 canvas->drawPicture(picture_); |
| 46 } |
| 47 |
| 48 } // namespace skia |
| OLD | NEW |