Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(902)

Unified Diff: skia/ext/platform_picture_skia.cc

Issue 10915065: Add PlatformPictureSkia and RecordingPlatformDeviceSkia. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add IsPlatformPaintSupported(), update comment in WebPluginDelegateProxy::Paint and require direct … Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..7b4002a2dda94ba2bfccc7c64414f7a33188e2a8
--- /dev/null
+++ b/skia/ext/platform_picture_skia.cc
@@ -0,0 +1,48 @@
+// 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();
+}
+
+SkCanvas* PlatformPictureSkia::beginRecording(int width, int height) {
+ if (record_)
+ record_->unref();
+ record_ = new SkProxyCanvas;
+ record_->setProxy(picture_.beginRecording(width, height));
+
+ // Set device to handle platform paint.
+ SkDevice* device = RecordingPlatformDeviceSkia::Create(
+ &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::drawInto(SkCanvas* canvas) {
+ canvas->drawPicture(picture_);
+}
+
+} // namespace skia

Powered by Google App Engine
This is Rietveld 408576698