Chromium Code Reviews| 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(); | |
|
alokp
2012/09/17 16:29:30
can we use SkAutoRef to do this automatically?
reveman
2012/09/17 21:22:16
Yea, I don't see why not.
| |
| 18 record_ = NULL; | |
| 19 } | |
| 20 } | |
| 21 | |
| 22 SkCanvas* PlatformPictureSkia::beginRecording(int width, int height) { | |
|
nduca
2012/09/18 09:58:23
alokp/reveman, does the microbenchmark api needs t
reveman
2012/09/18 19:45:16
Yes, we should switch to using PlatformPictureSkia
| |
| 23 if (record_) { | |
|
alokp
2012/09/17 16:29:30
I would defer to Mike's expertise here.
| |
| 24 record_->unref(); | |
| 25 record_ = NULL; | |
| 26 } | |
| 27 record_ = new SkProxyCanvas; | |
| 28 record_->setProxy(picture_.beginRecording(width, height)); | |
| 29 | |
| 30 // Set device to handle platform paint. | |
| 31 SkDevice* device = CreateRecordingPlatformDeviceSkia( | |
| 32 &picture_, width, height); | |
| 33 record_->setDevice(device); | |
| 34 device->unref(); // Created with refcount 1, and setDevice refs. | |
| 35 | |
| 36 return record_; | |
| 37 } | |
| 38 | |
| 39 void PlatformPictureSkia::endRecording() { | |
| 40 picture_.endRecording(); | |
| 41 | |
| 42 if (record_) { | |
| 43 record_->unref(); | |
| 44 record_ = NULL; | |
| 45 } | |
| 46 } | |
| 47 | |
| 48 void PlatformPictureSkia::drawPicture(SkCanvas* canvas) { | |
| 49 canvas->drawPicture(picture_); | |
| 50 } | |
| 51 | |
| 52 } // namespace skia | |
| OLD | NEW |