OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 package org.chromium.android_webview; | 5 package org.chromium.android_webview; |
6 | 6 |
7 import android.content.res.Configuration; | 7 import android.content.res.Configuration; |
8 import android.graphics.Bitmap; | 8 import android.graphics.Bitmap; |
9 import android.graphics.Canvas; | 9 import android.graphics.Canvas; |
10 import android.graphics.Color; | 10 import android.graphics.Color; |
(...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
310 public static void setAwDrawSWFunctionTable(int functionTablePointer) { | 310 public static void setAwDrawSWFunctionTable(int functionTablePointer) { |
311 nativeSetAwDrawSWFunctionTable(functionTablePointer); | 311 nativeSetAwDrawSWFunctionTable(functionTablePointer); |
312 } | 312 } |
313 | 313 |
314 public static int getAwDrawGLFunction() { | 314 public static int getAwDrawGLFunction() { |
315 return nativeGetAwDrawGLFunction(); | 315 return nativeGetAwDrawGLFunction(); |
316 } | 316 } |
317 | 317 |
318 public int getAwDrawGLViewContext() { | 318 public int getAwDrawGLViewContext() { |
319 // Using the native pointer as the returned viewContext. This is matched
by the | 319 // Using the native pointer as the returned viewContext. This is matched
by the |
320 // reinterpret_cast back to AwContents pointer in the native DrawGLFunct
ion. | 320 // reinterpret_cast back to BrowserViewRenderer pointer in the native Dr
awGLFunction. |
321 return mNativeAwContents; | 321 return nativeGetAwDrawGLViewContext(mNativeAwContents); |
322 } | 322 } |
323 | 323 |
324 public boolean onPrepareDrawGL(Canvas canvas) { | 324 public boolean onPrepareDrawGL(Canvas canvas) { |
325 if (mNativeAwContents == 0) return false; | 325 if (mNativeAwContents == 0) return false; |
326 nativeSetScrollForHWFrame(mNativeAwContents, | 326 nativeSetScrollForHWFrame(mNativeAwContents, |
327 mContainerView.getScrollX(), mContainerView.getScrollY()); | 327 mContainerView.getScrollX(), mContainerView.getScrollY()); |
328 | 328 |
329 // returning false will cause a fallback to SW path. | 329 // returning false will cause a fallback to SW path. |
330 return true; | 330 return true; |
331 } | 331 } |
(...skipping 635 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
967 | 967 |
968 for (int i = 1; i < 100; i++) { | 968 for (int i = 1; i < 100; i++) { |
969 testName = baseName + name + "-" + i + WEB_ARCHIVE_EXTENSION; | 969 testName = baseName + name + "-" + i + WEB_ARCHIVE_EXTENSION; |
970 if (!new File(testName).exists()) return testName; | 970 if (!new File(testName).exists()) return testName; |
971 } | 971 } |
972 | 972 |
973 Log.e(TAG, "Unable to auto generate archive name for path: " + baseName)
; | 973 Log.e(TAG, "Unable to auto generate archive name for path: " + baseName)
; |
974 return null; | 974 return null; |
975 } | 975 } |
976 | 976 |
977 /** | |
978 * Provides a Bitmap object with a given width and height used for auxiliary
rasterization. | |
979 */ | |
980 @CalledByNative | |
981 private static Bitmap createBitmap(int width, int height) { | |
982 return Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888); | |
983 } | |
984 | |
985 /** | |
986 * Draws a provided bitmap into a canvas. | |
987 * Used for convenience from the native side and other static helper methods
. | |
988 */ | |
989 @CalledByNative | |
990 private static void drawBitmapIntoCanvas(Bitmap bitmap, Canvas canvas) { | |
991 canvas.drawBitmap(bitmap, 0, 0, null); | |
992 } | |
993 | |
994 /** | |
995 * Creates a new Picture that records drawing a provided bitmap. | |
996 * Will return an empty Picture if the Bitmap is null. | |
997 */ | |
998 @CalledByNative | |
999 private static Picture recordBitmapIntoPicture(Bitmap bitmap) { | |
1000 Picture picture = new Picture(); | |
1001 if (bitmap != null) { | |
1002 Canvas recordingCanvas = picture.beginRecording(bitmap.getWidth(), b
itmap.getHeight()); | |
1003 drawBitmapIntoCanvas(bitmap, recordingCanvas); | |
1004 picture.endRecording(); | |
1005 } | |
1006 return picture; | |
1007 } | |
1008 | |
1009 @CalledByNative | 977 @CalledByNative |
1010 private void handleJsAlert(String url, String message, JsResultReceiver rece
iver) { | 978 private void handleJsAlert(String url, String message, JsResultReceiver rece
iver) { |
1011 mContentsClient.handleJsAlert(url, message, receiver); | 979 mContentsClient.handleJsAlert(url, message, receiver); |
1012 } | 980 } |
1013 | 981 |
1014 @CalledByNative | 982 @CalledByNative |
1015 private void handleJsBeforeUnload(String url, String message, JsResultReceiv
er receiver) { | 983 private void handleJsBeforeUnload(String url, String message, JsResultReceiv
er receiver) { |
1016 mContentsClient.handleJsBeforeUnload(url, message, receiver); | 984 mContentsClient.handleJsBeforeUnload(url, message, receiver); |
1017 } | 985 } |
1018 | 986 |
(...skipping 25 matching lines...) Expand all Loading... |
1044 private native void nativeGenerateMHTML( | 1012 private native void nativeGenerateMHTML( |
1045 int nativeAwContents, String path, ValueCallback<String> callback); | 1013 int nativeAwContents, String path, ValueCallback<String> callback); |
1046 | 1014 |
1047 private native void nativeSetIoThreadClient(int nativeAwContents, | 1015 private native void nativeSetIoThreadClient(int nativeAwContents, |
1048 AwContentsIoThreadClient ioThreadClient); | 1016 AwContentsIoThreadClient ioThreadClient); |
1049 private native void nativeSetInterceptNavigationDelegate(int nativeAwContent
s, | 1017 private native void nativeSetInterceptNavigationDelegate(int nativeAwContent
s, |
1050 InterceptNavigationDelegate navigationInterceptionDelegate); | 1018 InterceptNavigationDelegate navigationInterceptionDelegate); |
1051 | 1019 |
1052 private native void nativeAddVisitedLinks(int nativeAwContents, String[] vis
itedLinks); | 1020 private native void nativeAddVisitedLinks(int nativeAwContents, String[] vis
itedLinks); |
1053 | 1021 |
1054 private native boolean nativeDrawSW(int nativeAwContents, Canvas canvas, int
clipX, int clipY, | |
1055 int clipW, int clipH); | |
1056 private native void nativeSetScrollForHWFrame(int nativeAwContents, int scro
llX, int scrollY); | 1022 private native void nativeSetScrollForHWFrame(int nativeAwContents, int scro
llX, int scrollY); |
1057 private native int nativeFindAllSync(int nativeAwContents, String searchStri
ng); | 1023 private native int nativeFindAllSync(int nativeAwContents, String searchStri
ng); |
1058 private native void nativeFindAllAsync(int nativeAwContents, String searchSt
ring); | 1024 private native void nativeFindAllAsync(int nativeAwContents, String searchSt
ring); |
1059 private native void nativeFindNext(int nativeAwContents, boolean forward); | 1025 private native void nativeFindNext(int nativeAwContents, boolean forward); |
1060 private native void nativeClearMatches(int nativeAwContents); | 1026 private native void nativeClearMatches(int nativeAwContents); |
1061 private native void nativeClearCache(int nativeAwContents, boolean includeDi
skFiles); | 1027 private native void nativeClearCache(int nativeAwContents, boolean includeDi
skFiles); |
1062 private native byte[] nativeGetCertificate(int nativeAwContents); | 1028 private native byte[] nativeGetCertificate(int nativeAwContents); |
1063 | 1029 |
1064 // Coordinates in desity independent pixels. | 1030 // Coordinates in desity independent pixels. |
1065 private native void nativeRequestNewHitTestDataAt(int nativeAwContents, int
x, int y); | 1031 private native void nativeRequestNewHitTestDataAt(int nativeAwContents, int
x, int y); |
1066 private native void nativeUpdateLastHitTestData(int nativeAwContents); | 1032 private native void nativeUpdateLastHitTestData(int nativeAwContents); |
1067 | 1033 |
1068 private native void nativeOnSizeChanged(int nativeAwContents, int w, int h,
int ow, int oh); | 1034 private native void nativeOnSizeChanged(int nativeAwContents, int w, int h,
int ow, int oh); |
1069 private native void nativeSetWindowViewVisibility(int nativeAwContents, bool
ean windowVisible, | 1035 private native void nativeSetWindowViewVisibility(int nativeAwContents, bool
ean windowVisible, |
1070 boolean viewVisible); | 1036 boolean viewVisible); |
1071 private native void nativeOnAttachedToWindow(int nativeAwContents, int w, in
t h); | 1037 private native void nativeOnAttachedToWindow(int nativeAwContents, int w, in
t h); |
1072 private native void nativeOnDetachedFromWindow(int nativeAwContents); | 1038 private native void nativeOnDetachedFromWindow(int nativeAwContents); |
1073 | 1039 |
1074 // Returns null if save state fails. | 1040 // Returns null if save state fails. |
1075 private native byte[] nativeGetOpaqueState(int nativeAwContents); | 1041 private native byte[] nativeGetOpaqueState(int nativeAwContents); |
1076 | 1042 |
1077 // Returns false if restore state fails. | 1043 // Returns false if restore state fails. |
1078 private native boolean nativeRestoreFromOpaqueState(int nativeAwContents, by
te[] state); | 1044 private native boolean nativeRestoreFromOpaqueState(int nativeAwContents, by
te[] state); |
1079 | 1045 |
1080 private native int nativeReleasePopupWebContents(int nativeAwContents); | 1046 private native int nativeReleasePopupWebContents(int nativeAwContents); |
1081 private native void nativeSetWebContents(int nativeAwContents, int nativeNew
WebContents); | 1047 private native void nativeSetWebContents(int nativeAwContents, int nativeNew
WebContents); |
1082 private native void nativeFocusFirstNode(int nativeAwContents); | 1048 private native void nativeFocusFirstNode(int nativeAwContents); |
1083 | 1049 |
| 1050 private native boolean nativeDrawSW(int nativeAwContents, Canvas canvas, int
clipX, int clipY, |
| 1051 int clipW, int clipH); |
| 1052 private native int nativeGetAwDrawGLViewContext(int nativeAwContents); |
1084 private native Picture nativeCapturePicture(int nativeAwContents); | 1053 private native Picture nativeCapturePicture(int nativeAwContents); |
1085 private native void nativeEnableOnNewPicture(int nativeAwContents, boolean e
nabled, | 1054 private native void nativeEnableOnNewPicture(int nativeAwContents, boolean e
nabled, |
1086 boolean invalidationOnly); | 1055 boolean invalidationOnly); |
1087 } | 1056 } |
OLD | NEW |