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

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: rebase 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 void AwPicture::Destroy(JNIEnv* env, jobject obj) {
20 delete this;
21 }
22
23 jint AwPicture::GetWidth(JNIEnv* env, jobject obj) {
24 return picture_->width();
25 }
26
27 jint AwPicture::GetHeight(JNIEnv* env, jobject obj) {
28 return picture_->height();
29 }
30
31 namespace {
32 bool RenderPictureToCanvas(SkPicture* picture, SkCanvas* canvas) {
33 picture->draw(canvas);
34 return true;
35 }
36 }
37
38 void AwPicture::Draw(JNIEnv* env, jobject obj, jobject canvas,
39 jint left, jint top, jint right, jint bottom) {
40 bool ok = InProcessViewRenderer::RenderViaAuxilaryBitmapIfNeeded(
41 canvas,
42 JavaBrowserViewRendererHelper::GetInstance(),
43 gfx::Vector2d(),
44 gfx::Rect(left, top, right - left, bottom - top),
45 base::Bind(&RenderPictureToCanvas, base::Unretained(picture_.get())),
46 this);
47 LOG_IF(ERROR, !ok) << "Couldn't draw picture";
48 }
49
50 bool RegisterAwPicture(JNIEnv* env) {
51 return RegisterNativesImpl(env) >= 0;
52 }
53
54 } // namespace android_webview
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698