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.
5 #include "android_webview/native/aw_picture.h"
7 #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"
12 namespace android_webview
{
14 AwPicture::AwPicture(skia::RefPtr
<SkPicture
> picture
)
19 AwPicture::~AwPicture() {}
21 void AwPicture::Destroy(JNIEnv
* env
, jobject obj
) {
25 jint
AwPicture::GetWidth(JNIEnv
* env
, jobject obj
) {
26 return picture_
->width();
29 jint
AwPicture::GetHeight(JNIEnv
* env
, jobject obj
) {
30 return picture_
->height();
34 bool RenderPictureToCanvas(SkPicture
* picture
, SkCanvas
* canvas
) {
35 picture
->draw(canvas
);
40 void AwPicture::Draw(JNIEnv
* env
, jobject obj
, jobject canvas
) {
41 bool ok
= JavaBrowserViewRendererHelper::GetInstance()
42 ->RenderViaAuxilaryBitmapIfNeeded(
45 gfx::Size(picture_
->width(), picture_
->height()),
46 base::Bind(&RenderPictureToCanvas
,
47 base::Unretained(picture_
.get())));
48 LOG_IF(ERROR
, !ok
) << "Couldn't draw picture";
51 bool RegisterAwPicture(JNIEnv
* env
) {
52 return RegisterNativesImpl(env
);
55 } // namespace android_webview