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_
->cullRect().roundOut().width();
29 jint
AwPicture::GetHeight(JNIEnv
* env
, jobject obj
) {
30 return picture_
->cullRect().roundOut().height();
33 void AwPicture::Draw(JNIEnv
* env
, jobject obj
, jobject canvas
) {
34 const SkIRect bounds
= picture_
->cullRect().roundOut();
35 scoped_ptr
<SoftwareCanvasHolder
> canvas_holder
= SoftwareCanvasHolder::Create(
36 canvas
, gfx::Vector2d(), gfx::Size(bounds
.width(), bounds
.height()),
38 if (!canvas_holder
|| !canvas_holder
->GetCanvas()) {
39 LOG(ERROR
) << "Couldn't draw picture";
42 picture_
->playback(canvas_holder
->GetCanvas());
45 bool RegisterAwPicture(JNIEnv
* env
) {
46 return RegisterNativesImpl(env
);
49 } // namespace android_webview