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

Unified Diff: android_webview/native/aw_picture.cc

Issue 22035002: Android WebView: Make a custom Picture subclass (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: endRecording is OK Created 7 years, 4 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
« no previous file with comments | « android_webview/native/aw_picture.h ('k') | android_webview/native/java_browser_view_renderer_helper.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: android_webview/native/aw_picture.cc
diff --git a/android_webview/native/aw_picture.cc b/android_webview/native/aw_picture.cc
new file mode 100644
index 0000000000000000000000000000000000000000..bc02b5b84b9b396e2aea1c59c266eecd7959d7dd
--- /dev/null
+++ b/android_webview/native/aw_picture.cc
@@ -0,0 +1,56 @@
+// Copyright 2013 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 "android_webview/native/aw_picture.h"
+
+#include "android_webview/browser/in_process_view_renderer.h"
+#include "android_webview/native/java_browser_view_renderer_helper.h"
+#include "jni/AwPicture_jni.h"
+#include "third_party/skia/include/core/SkPicture.h"
+
+namespace android_webview {
+
+AwPicture::AwPicture(skia::RefPtr<SkPicture> picture)
+ : picture_(picture) {
+ DCHECK(picture_);
+}
+
+AwPicture::~AwPicture() {}
+
+void AwPicture::Destroy(JNIEnv* env, jobject obj) {
+ delete this;
+}
+
+jint AwPicture::GetWidth(JNIEnv* env, jobject obj) {
+ return picture_->width();
+}
+
+jint AwPicture::GetHeight(JNIEnv* env, jobject obj) {
+ return picture_->height();
+}
+
+namespace {
+bool RenderPictureToCanvas(SkPicture* picture, SkCanvas* canvas) {
+ picture->draw(canvas);
+ return true;
+}
+}
+
+void AwPicture::Draw(JNIEnv* env, jobject obj, jobject canvas,
+ jint left, jint top, jint right, jint bottom) {
+ bool ok = InProcessViewRenderer::RenderViaAuxilaryBitmapIfNeeded(
+ canvas,
+ JavaBrowserViewRendererHelper::GetInstance(),
+ gfx::Vector2d(),
+ gfx::Rect(left, top, right - left, bottom - top),
+ base::Bind(&RenderPictureToCanvas, base::Unretained(picture_.get())),
+ this);
+ LOG_IF(ERROR, !ok) << "Couldn't draw picture";
+}
+
+bool RegisterAwPicture(JNIEnv* env) {
+ return RegisterNativesImpl(env) >= 0;
+}
+
+} // namespace android_webview
« no previous file with comments | « android_webview/native/aw_picture.h ('k') | android_webview/native/java_browser_view_renderer_helper.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698