Chromium Code Reviews| Index: skia/ext/platform_picture_skia.cc |
| diff --git a/skia/ext/platform_picture_skia.cc b/skia/ext/platform_picture_skia.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..6303a4cf950f82782851fad829b8626b5efe08da |
| --- /dev/null |
| +++ b/skia/ext/platform_picture_skia.cc |
| @@ -0,0 +1,52 @@ |
| +// Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "skia/ext/platform_picture_skia.h" |
| + |
| +#include "skia/ext/recording_platform_device_skia.h" |
| +#include "third_party/skia/include/utils/SkProxyCanvas.h" |
| + |
| +namespace skia { |
| + |
| +PlatformPictureSkia::PlatformPictureSkia() : record_(NULL) { |
| +} |
| + |
| +PlatformPictureSkia::~PlatformPictureSkia() { |
| + if (record_) { |
| + 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.
|
| + record_ = NULL; |
| + } |
| +} |
| + |
| +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
|
| + if (record_) { |
|
alokp
2012/09/17 16:29:30
I would defer to Mike's expertise here.
|
| + record_->unref(); |
| + record_ = NULL; |
| + } |
| + record_ = new SkProxyCanvas; |
| + record_->setProxy(picture_.beginRecording(width, height)); |
| + |
| + // Set device to handle platform paint. |
| + SkDevice* device = CreateRecordingPlatformDeviceSkia( |
| + &picture_, width, height); |
| + record_->setDevice(device); |
| + device->unref(); // Created with refcount 1, and setDevice refs. |
| + |
| + return record_; |
| +} |
| + |
| +void PlatformPictureSkia::endRecording() { |
| + picture_.endRecording(); |
| + |
| + if (record_) { |
| + record_->unref(); |
| + record_ = NULL; |
| + } |
| +} |
| + |
| +void PlatformPictureSkia::drawPicture(SkCanvas* canvas) { |
| + canvas->drawPicture(picture_); |
| +} |
| + |
| +} // namespace skia |