1 // Copyright (c) 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/java_browser_view_renderer_helper.h"
7 #include "base/debug/trace_event.h"
8 #include "jni/JavaBrowserViewRendererHelper_jni.h"
10 using base::android::JavaRef
;
11 using base::android::ScopedJavaLocalRef
;
13 namespace android_webview
{
15 JavaBrowserViewRendererHelper::JavaBrowserViewRendererHelper() {
18 JavaBrowserViewRendererHelper::~JavaBrowserViewRendererHelper() {
22 JavaBrowserViewRendererHelper
* JavaBrowserViewRendererHelper::GetInstance() {
23 static JavaBrowserViewRendererHelper
* g_instance
=
24 new JavaBrowserViewRendererHelper
;
28 ScopedJavaLocalRef
<jobject
> JavaBrowserViewRendererHelper::CreateBitmap(
32 const base::android::JavaRef
<jobject
>& jcanvas
,
34 TRACE_EVENT0("android_webview", "RendererHelper::CreateBitmap");
35 return width
<= 0 || height
<= 0 ? ScopedJavaLocalRef
<jobject
>() :
36 Java_JavaBrowserViewRendererHelper_createBitmap(
37 env
, width
, height
, jcanvas
.obj(),
38 reinterpret_cast<jint
>(owner_key
));
41 void JavaBrowserViewRendererHelper::DrawBitmapIntoCanvas(
43 const JavaRef
<jobject
>& jbitmap
,
44 const JavaRef
<jobject
>& jcanvas
,
47 TRACE_EVENT0("android_webview", "RendererHelper::DrawBitmapIntoCanvas");
48 Java_JavaBrowserViewRendererHelper_drawBitmapIntoCanvas(
49 env
, jbitmap
.obj(), jcanvas
.obj(), x
, y
);
52 ScopedJavaLocalRef
<jobject
>
53 JavaBrowserViewRendererHelper::RecordBitmapIntoPicture(
55 const JavaRef
<jobject
>& jbitmap
) {
56 TRACE_EVENT0("android_webview", "RendererHelper::RecordBitmapIntoPicture");
57 return Java_JavaBrowserViewRendererHelper_recordBitmapIntoPicture(
61 bool RegisterJavaBrowserViewRendererHelper(JNIEnv
* env
) {
62 return RegisterNativesImpl(env
) >= 0;
65 } // namespace android_webview