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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright 2013 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 "android_webview/native/aw_picture.h"
6
7 #include "android_webview/browser/in_process_view_renderer.h"
8 #include "android_webview/native/java_browser_view_renderer_helper.h"
9 #include "jni/AwPicture_jni.h"
10 #include "third_party/skia/include/core/SkPicture.h"
11
12 namespace android_webview {
13
14 AwPicture::AwPicture(skia::RefPtr<SkPicture> picture)
15 : picture_(picture) {
16 DCHECK(picture_);
17 }
18
19 AwPicture::~AwPicture() {}
20
21 void AwPicture::Destroy(JNIEnv* env, jobject obj) {
22 delete this;
23 }
24
25 jint AwPicture::GetWidth(JNIEnv* env, jobject obj) {
26 return picture_->width();
27 }
28
29 jint AwPicture::GetHeight(JNIEnv* env, jobject obj) {
30 return picture_->height();
31 }
32
33 namespace {
34 bool RenderPictureToCanvas(SkPicture* picture, SkCanvas* canvas) {
35 picture->draw(canvas);
36 return true;
37 }
38 }
39
40 void AwPicture::Draw(JNIEnv* env, jobject obj, jobject canvas,
41 jint left, jint top, jint right, jint bottom) {
42 bool ok = InProcessViewRenderer::RenderViaAuxilaryBitmapIfNeeded(
43 canvas,
44 JavaBrowserViewRendererHelper::GetInstance(),
45 gfx::Vector2d(),
46 gfx::Rect(left, top, right - left, bottom - top),
47 base::Bind(&RenderPictureToCanvas, base::Unretained(picture_.get())),
48 this);
49 LOG_IF(ERROR, !ok) << "Couldn't draw picture";
50 }
51
52 bool RegisterAwPicture(JNIEnv* env) {
53 return RegisterNativesImpl(env) >= 0;
54 }
55
56 } // namespace android_webview
OLDNEW
« 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