From dc71e152efbbecb26950c24f7e5d3387a9986eaa Mon Sep 17 00:00:00 2001 From: Derek Sollenberger Date: Wed, 4 Jan 2017 14:02:52 -0500 Subject: Update Android Apps to work with GN. This also includes the removal of an old example whose instructions are not compatible with GN. BUG=skia:6009 Change-Id: I2807829ca12c19292ae0f5a7ea250ed453f9a182 Reviewed-on: https://skia-review.googlesource.com/5620 Commit-Queue: Derek Sollenberger Reviewed-by: Mike Klein --- platform_tools/android/apps/build.gradle | 114 +++++------- .../android/apps/canvasproof/build.gradle | 23 --- .../apps/canvasproof/src/main/AndroidManifest.xml | 29 --- .../canvasproof/src/main/assets/skps/.gitignore | 1 - .../org/skia/canvasproof/CanvasProofActivity.java | 205 --------------------- .../org/skia/canvasproof/CreateSkiaPicture.java | 58 ------ .../skia/canvasproof/GaneshPictureRenderer.java | 120 ------------ .../java/org/skia/canvasproof/HwuiPictureView.java | 72 -------- .../canvasproof/src/main/jni/JavaInputStream.cpp | 61 ------ .../canvasproof/src/main/jni/JavaInputStream.h | 28 --- .../jni/org_skia_canvasproof_CreateSkiaPicture.cpp | 42 ----- .../jni/org_skia_canvasproof_CreateSkiaPicture.h | 35 ---- .../org_skia_canvasproof_GaneshPictureRenderer.cpp | 145 --------------- .../org_skia_canvasproof_GaneshPictureRenderer.h | 52 ------ .../apps/gradle/wrapper/gradle-wrapper.properties | 4 +- platform_tools/android/apps/settings.gradle | 1 - platform_tools/android/apps/viewer/build.gradle | 4 +- .../java/org/skia/viewer/ViewerApplication.java | 1 - platform_tools/android/bin/android_install_app | 21 +-- platform_tools/android/bin/android_launch_app | 2 +- platform_tools/android/bin/android_make | 22 --- platform_tools/android/bin/android_ninja | 1 - platform_tools/android/bin/utils/android_setup.sh | 81 +------- 23 files changed, 62 insertions(+), 1060 deletions(-) delete mode 100644 platform_tools/android/apps/canvasproof/build.gradle delete mode 100644 platform_tools/android/apps/canvasproof/src/main/AndroidManifest.xml delete mode 100644 platform_tools/android/apps/canvasproof/src/main/assets/skps/.gitignore delete mode 100644 platform_tools/android/apps/canvasproof/src/main/java/org/skia/canvasproof/CanvasProofActivity.java delete mode 100644 platform_tools/android/apps/canvasproof/src/main/java/org/skia/canvasproof/CreateSkiaPicture.java delete mode 100644 platform_tools/android/apps/canvasproof/src/main/java/org/skia/canvasproof/GaneshPictureRenderer.java delete mode 100644 platform_tools/android/apps/canvasproof/src/main/java/org/skia/canvasproof/HwuiPictureView.java delete mode 100644 platform_tools/android/apps/canvasproof/src/main/jni/JavaInputStream.cpp delete mode 100644 platform_tools/android/apps/canvasproof/src/main/jni/JavaInputStream.h delete mode 100644 platform_tools/android/apps/canvasproof/src/main/jni/org_skia_canvasproof_CreateSkiaPicture.cpp delete mode 100644 platform_tools/android/apps/canvasproof/src/main/jni/org_skia_canvasproof_CreateSkiaPicture.h delete mode 100644 platform_tools/android/apps/canvasproof/src/main/jni/org_skia_canvasproof_GaneshPictureRenderer.cpp delete mode 100644 platform_tools/android/apps/canvasproof/src/main/jni/org_skia_canvasproof_GaneshPictureRenderer.h delete mode 100755 platform_tools/android/bin/android_make delete mode 120000 platform_tools/android/bin/android_ninja (limited to 'platform_tools') diff --git a/platform_tools/android/apps/build.gradle b/platform_tools/android/apps/build.gradle index c16bfe433a..5c49269356 100644 --- a/platform_tools/android/apps/build.gradle +++ b/platform_tools/android/apps/build.gradle @@ -6,7 +6,7 @@ buildscript { jcenter() } dependencies { - classpath 'com.android.tools.build:gradle:2.1.0' + classpath 'com.android.tools.build:gradle:2.2.3' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files @@ -19,21 +19,27 @@ allprojects { } } -def setupSkiaLibraryBuild(project, appVariants, buildCmd, requireCMake = false) { +def setupSkiaLibraryBuild(project, appVariants, appName) { appVariants.all{ variant -> - def buildNativeLib = project.task("${variant.name}_SkiaNativeLib", type:Exec) { + def buildNativeLib = project.task("${variant.name}_BuildSkiaLib", type:Exec) { workingDir '../../../..' // top-level skia directory - commandLine constructBuildCommand(variant, buildCmd).split() - environment PATH: getPathWithDeps(requireCMake) - environment ANDROID_SDK_ROOT: getSDKPath() + commandLine constructBuildCommand(variant, appName).split() } buildNativeLib.onlyIf { !project.hasProperty("suppressNativeBuild") } + + def copyNativeLib = project.task("${variant.name}_CopySkiaLib", type:Copy) { + from getVariantOutDir(variant).skiaOut + into getVariantOutDir(variant).androidOut + include "${appName}.so" + } + TaskCollection compileTask = project.tasks.matching { // println(it.name) it.name.toLowerCase().contains("compile" + variant.name.toLowerCase()) && it.name.toLowerCase().endsWith("ndk") } - compileTask.getAt(0).dependsOn buildNativeLib + compileTask.getAt(0).dependsOn copyNativeLib + copyNativeLib.dependsOn buildNativeLib } } @@ -50,70 +56,50 @@ def getLocalProperties() { return properties } -def getSDKPath() { - String path = System.getenv("ANDROID_SDK_ROOT") - if (path == null) { - path = getLocalProperties().getProperty('sdk.dir', null) - } - - if (path == null) { - throw new GradleScriptException("Android SDK not found! Please set ANDROID_SDK_ROOT to" + - " your path or define sdk.dir in gradle.properties") - } - return path -} - -def getPathWithDeps(requireCMake = false) { - String path = System.getenv("PATH") - if (!path.contains("depot_tools")) { - path += ":" + getLocalProperties().getProperty('depot_tools.dir', null) - } - - if (!path.contains("depot_tools")) { - throw GradleScriptException("Depot Tools not found! Please update your path to include" + - " depot_tools or define depot_tools.dir in gradle.properties") - } - - if (requireCMake) { - String cmakePath = getSDKPath() + "/cmake/bin" - if (!file(cmakePath).exists()) { - logger.warn("cmake not found! Please install the android SDK version of cmake."); - } - if (!path.contains(cmakePath)) { - path = cmakePath + ":" + path - } - } - - return path -} - -def constructBuildCommand(variant, buildTarget) { - String cmdLine = "./platform_tools/android/bin/android_ninja $buildTarget" - String deviceType = null +def getVariantOutDir(variant) { + String variantPrefix = null + String androidLibDir = null if (variant.name.startsWith("arm64")) { - deviceType = "arm64" + variantPrefix = "arm64" + androidLibDir = "arm64-v8a" } else if (variant.name.startsWith("arm")) { - deviceType = "arm_v7_neon" + variantPrefix = "arm" + androidLibDir = "armeabi-v7a" } else if (variant.name.startsWith("x86_64")) { - deviceType = "x86_64" + variantPrefix = "x64" + androidLibDir = "x86_64" } else if (variant.name.startsWith("x86")) { - deviceType = "x86" - } else if (variant.name.startsWith("mips")) { - deviceType = "mips" - } else if (variant.name.startsWith("mips64")) { - deviceType = "mips64" + variantPrefix = "x86" + androidLibDir = "x86" + } else if (variant.name.startsWith("mipsel")) { + variantPrefix = "mipsel" + androidLibDir = "mips" + } else if (variant.name.startsWith("mips64el")) { + variantPrefix = "mips64el" + androidLibDir = "mips64" } - if (deviceType != null) { - cmdLine += " -d " + deviceType - } + return [skiaOut: getLocalProperties().getProperty("${variantPrefix}.out.dir", "missing_variant_out"), + androidOut: "src/main/libs/${androidLibDir}"] +} - if (variant.name.endsWith("Release")) { - cmdLine += " --release" +def constructBuildCommand(variant, appName) { + String depotToolsDir = null + for (String entry : System.getenv("PATH").split(":")) { + if (entry.contains("depot_tools")) { + depotToolsDir = entry; + break; + } + } + if (depotToolsDir == null) { + depotToolsDir = getLocalProperties().getProperty('depot_tools.dir', null) } - if (variant.name.indexOf("vulkan") != -1) { - cmdLine += " --vulkan" + if (depotToolsDir == null) { + throw GradleScriptException("Depot Tools not found! Please update your path to include" + + " depot_tools or define depot_tools.dir in local.properties") } - return cmdLine -} \ No newline at end of file + + String out_dir = getVariantOutDir(variant).skiaOut + return "${depotToolsDir}/ninja -C $out_dir $appName" +} diff --git a/platform_tools/android/apps/canvasproof/build.gradle b/platform_tools/android/apps/canvasproof/build.gradle deleted file mode 100644 index 5493699b73..0000000000 --- a/platform_tools/android/apps/canvasproof/build.gradle +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Copyright 2015 Google Inc. - * - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ -apply plugin: 'com.android.application' -android { - compileSdkVersion 19 - buildToolsVersion "22.0.1" - defaultConfig { - applicationId "org.skia.canvasproof" - minSdkVersion 9 - targetSdkVersion 19 - versionCode 1 - versionName "1.0" - signingConfig signingConfigs.debug - } - sourceSets.main.jni.srcDirs = [] //disable automatic ndk-build call - sourceSets.main.jniLibs.srcDir "src/main/libs" - productFlavors { arm {}; arm64 {}; x86 {}; x86_64 {}; mips {}; mips64 {}; } - setupSkiaLibraryBuild(project, applicationVariants, "CopyCanvasProofDeps") -} diff --git a/platform_tools/android/apps/canvasproof/src/main/AndroidManifest.xml b/platform_tools/android/apps/canvasproof/src/main/AndroidManifest.xml deleted file mode 100644 index be774c880c..0000000000 --- a/platform_tools/android/apps/canvasproof/src/main/AndroidManifest.xml +++ /dev/null @@ -1,29 +0,0 @@ - - - - - - - - - - - - - - - - - diff --git a/platform_tools/android/apps/canvasproof/src/main/assets/skps/.gitignore b/platform_tools/android/apps/canvasproof/src/main/assets/skps/.gitignore deleted file mode 100644 index 4a708012f6..0000000000 --- a/platform_tools/android/apps/canvasproof/src/main/assets/skps/.gitignore +++ /dev/null @@ -1 +0,0 @@ -*.skp diff --git a/platform_tools/android/apps/canvasproof/src/main/java/org/skia/canvasproof/CanvasProofActivity.java b/platform_tools/android/apps/canvasproof/src/main/java/org/skia/canvasproof/CanvasProofActivity.java deleted file mode 100644 index 9363585bbf..0000000000 --- a/platform_tools/android/apps/canvasproof/src/main/java/org/skia/canvasproof/CanvasProofActivity.java +++ /dev/null @@ -1,205 +0,0 @@ -/* - * Copyright 2015 Google Inc. - * - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -package org.skia.canvasproof; - -import android.app.Activity; -import android.content.res.AssetManager; -import android.graphics.Picture; -import android.opengl.GLSurfaceView; -import android.os.Bundle; -import android.util.Log; -import android.view.Gravity; -import android.view.MotionEvent; -import android.view.View; -import android.widget.LinearLayout.LayoutParams; -import android.widget.LinearLayout; -import java.io.File; -import java.io.IOException; -import java.io.InputStream; - -public class CanvasProofActivity extends Activity { - private static final String TAG = "CanvasProofActivity"; - private GaneshPictureRenderer ganeshPictureRenderer; - private HwuiPictureView hwuiPictureView; - private GLSurfaceView ganeshPictureView; - private LinearLayout splitPaneView; - private View currentView; - private float x, y; - private int resourcesIndex; - private class PictureAsset { - public String path; - public long ptr; - public Picture picture; - }; - private PictureAsset[] assets; - - @SuppressWarnings("deprecation") // purposely using this - private static Picture ReadPicture(InputStream inputStream) - throws IOException { - Picture p = null; - try { - p = Picture.createFromStream(inputStream); - } catch (java.lang.Exception e) { - Log.e(TAG, "Exception in Picture.createFromStream", e); - } - inputStream.close(); - return p; - } - - private void getAssetPaths() { - String directory = "skps"; - AssetManager mgr = this.getAssets(); - assert (mgr != null); - String[] resources; - try { - resources = mgr.list(directory); - } catch (IOException e) { - Log.e(TAG, "IOException in getAssetPaths", e); - return; - } - if (resources == null || resources.length == 0) { - Log.e(TAG, "SKP assets should be packaged in " + - ".../apps/canvasproof/src/main/assets/skps/" + - ", but none were found."); - return; - } - CreateSkiaPicture.init(); - this.assets = new PictureAsset[resources.length]; - for (int i = 0; i < resources.length; ++i) { - String path = directory + File.separator + resources[i]; - this.assets[i] = new PictureAsset(); - this.assets[i].path = path; - try { - this.assets[i].ptr = CreateSkiaPicture.create(mgr.open(path)); - if (0 == this.assets[i].ptr) { - Log.e(TAG, "CreateSkiaPicture.create returned 0 " + path); - } - Picture p = CanvasProofActivity.ReadPicture(mgr.open(path)); - if (null == p) { - Log.e(TAG, "CanvasProofActivity.ReadPicture.create " + - "returned null " + path); - } else if (0 == p.getHeight() || 0 == p.getWidth()) { - Log.e(TAG, "CanvasProofActivity.ReadPicture.create " + - "empty picture" + path); - p = null; - } - this.assets[i].picture = p; - } catch (IOException e) { - Log.e(TAG, "IOException in getAssetPaths " + path + e); - return; - } - } - } - - private void nextView() { - if (this.currentView == this.hwuiPictureView) { - this.currentView = this.ganeshPictureView; - this.ganeshPictureView.setRenderMode( - GLSurfaceView.RENDERMODE_CONTINUOUSLY); - } else if (this.currentView == null || - this.currentView == this.ganeshPictureView) { - this.setContentView(new View(this)); - LayoutParams layoutParams = - new LayoutParams( - LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT, 0.5f); - this.ganeshPictureView.setLayoutParams(layoutParams); - this.ganeshPictureView.setRenderMode( - GLSurfaceView.RENDERMODE_WHEN_DIRTY); - this.splitPaneView.addView(this.ganeshPictureView); - this.hwuiPictureView.setLayoutParams(layoutParams); - this.splitPaneView.addView(this.hwuiPictureView); - this.currentView = this.splitPaneView; - this.hwuiPictureView.fullTime = false; - } else if (this.currentView == this.splitPaneView) { - this.splitPaneView.removeAllViews(); - this.currentView = this.hwuiPictureView; - this.hwuiPictureView.fullTime = true; - } else { - Log.e(TAG, "unexpected value"); - this.setContentView(null); - return; - } - this.setContentView(this.currentView); - this.currentView.invalidate(); - } - - private void nextPicture(int d) { - if (this.assets == null) { - Log.w(TAG, "this.assets == null"); - return; - } - assert (this.assets.length > 0); - resourcesIndex = (resourcesIndex + d) % this.assets.length; - while (resourcesIndex < 0) { - resourcesIndex += this.assets.length; - } - while (resourcesIndex >= this.assets.length) { - resourcesIndex -= this.assets.length; - } - this.ganeshPictureRenderer.setPicture(assets[resourcesIndex].ptr); - this.hwuiPictureView.setPicture(assets[resourcesIndex].picture); - this.currentView.invalidate(); - } - - @Override - protected void onStop() { - this.ganeshPictureRenderer.releaseResources(); - super.onStop(); - } - - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - - this.getAssetPaths(); - this.ganeshPictureRenderer = new GaneshPictureRenderer(); - this.hwuiPictureView = new HwuiPictureView(this); - - this.ganeshPictureRenderer.setScale(2.0f); - this.hwuiPictureView.setScale(2.0f); - this.ganeshPictureView = ganeshPictureRenderer.makeView(this); - this.splitPaneView = new LinearLayout(this); - this.splitPaneView.setOrientation(LinearLayout.VERTICAL); - this.splitPaneView.setGravity(Gravity.FILL); - - LayoutParams layoutParams = - new LayoutParams( - LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT, 0.5f); - this.ganeshPictureView.setLayoutParams(layoutParams); - this.hwuiPictureView.setLayoutParams(layoutParams); - - this.nextView(); - this.nextPicture(0); - } - - // TODO: replace this funtion with onTouchEvent(). - // @Override public boolean onTouchEvent(MotionEvent event)... - @Override - public boolean dispatchTouchEvent (MotionEvent event) { - switch(event.getAction()) { - case MotionEvent.ACTION_DOWN: - this.x = event.getX(); - this.y = event.getY(); - break; - case MotionEvent.ACTION_UP: - float dx = event.getX() - this.x; - float dy = event.getY() - this.y; - float dx2 = dx * dx; - float dy2 = dy * dy; - if (dx2 + dy2 > 22500.0) { - if (dy2 < dx2) { - this.nextPicture(dx > 0 ? 1 : -1); - } else if (dy > 0) { - this.nextView(); - } - } - break; - } - return super.onTouchEvent(event); - } -} diff --git a/platform_tools/android/apps/canvasproof/src/main/java/org/skia/canvasproof/CreateSkiaPicture.java b/platform_tools/android/apps/canvasproof/src/main/java/org/skia/canvasproof/CreateSkiaPicture.java deleted file mode 100644 index 61aa14a7b7..0000000000 --- a/platform_tools/android/apps/canvasproof/src/main/java/org/skia/canvasproof/CreateSkiaPicture.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright 2015 Google Inc. - * - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ -/* -AJAR=$ANDROID_SDK_ROOT/platforms/android-19/android.jar -CLASS=CreateSkiaPicture -SRC=platform_tools/android/apps/canvasproof/src/main -javac -classpath $AJAR $SRC/java/org/skia/canvasproof/$CLASS.java -javah -classpath $AJAR:$SRC/java -d $SRC/jni org.skia.canvasproof.$CLASS -*/ - -package org.skia.canvasproof; - -import android.util.Log; -import java.io.IOException; -import java.io.InputStream; -import java.lang.UnsatisfiedLinkError; - -public class CreateSkiaPicture { - private static final String TAG = "CreateSkiaPicture"; - - public static void init() { - try { - System.loadLibrary("skia_android"); - System.loadLibrary("canvasproof"); - } catch (java.lang.Error e) { - Log.v(TAG, "System.loadLibrary error", e); - } - } - - public static long create(InputStream inputStream) throws IOException { - byte[] buffer = new byte[16 * (1 << 10)]; // 16 KByte - long p = 0; - try { - p = CreateSkiaPicture.createImpl(inputStream, buffer); - } catch (UnsatisfiedLinkError e) { - Log.e(TAG, "UnsatisfiedLinkError createImpl"); - } - inputStream.close(); - return p; - } - - public static void delete(long ptr) { - try { - if (ptr != 0) { - CreateSkiaPicture.deleteImpl(ptr); - } - } catch (UnsatisfiedLinkError e) { - Log.e(TAG, "UnsatisfiedLinkError deleteImpl"); - } - - } - private static native void deleteImpl(long ptr); - private static native long createImpl(InputStream s, byte[] b); -} diff --git a/platform_tools/android/apps/canvasproof/src/main/java/org/skia/canvasproof/GaneshPictureRenderer.java b/platform_tools/android/apps/canvasproof/src/main/java/org/skia/canvasproof/GaneshPictureRenderer.java deleted file mode 100644 index 01c6dc3f25..0000000000 --- a/platform_tools/android/apps/canvasproof/src/main/java/org/skia/canvasproof/GaneshPictureRenderer.java +++ /dev/null @@ -1,120 +0,0 @@ -/* - * Copyright 2015 Google Inc. - * - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -// AJAR=$ANDROID_SDK_ROOT/platforms/android-19/android.jar -// SRC=platform_tools/android/apps/canvasproof/src/main -// javac -classpath $AJAR $SRC/java/org/skia/canvasproof/GaneshPictureRenderer.java -// javah -classpath $AJAR:$SRC/java -d $SRC/jni org.skia.canvasproof.GaneshPictureRenderer - -package org.skia.canvasproof; - -import android.app.Activity; -import android.graphics.Rect; -import android.opengl.GLSurfaceView; -import android.util.Log; -import javax.microedition.khronos.egl.EGLConfig; -import javax.microedition.khronos.opengles.GL10; - -public class GaneshPictureRenderer implements GLSurfaceView.Renderer { - private static final String TAG = "GaneshPictureRenderer"; - private long picturePtr; - private long contextPtr; - private float scale; - private int width; - private int height; - private GLSurfaceView view; - - GaneshPictureRenderer() { - try { - System.loadLibrary("skia_android"); - System.loadLibrary("canvasproof"); - } catch (java.lang.Error e) { - Log.e(TAG, "System.loadLibrary error", e); - return; - } - this.scale = 1; - } - public GLSurfaceView makeView(Activity activity) { - this.view = new GLSurfaceView(activity); - this.view.setEGLConfigChooser(8, 8, 8, 8, 0, 8); - this.view.setEGLContextClientVersion(2); - this.view.setRenderer(this); - this.view.setRenderMode(GLSurfaceView.RENDERMODE_WHEN_DIRTY); - return this.view; - } - static public Rect cullRect(long picturePtr) { - Rect rect = new Rect(); - try { - GaneshPictureRenderer.GetCullRect(rect, picturePtr); - } catch (UnsatisfiedLinkError e) { - Log.e(TAG, "GetCullRect failed", e); - } - return rect; - } - public void setPicture(long picturePtr) { - this.picturePtr = picturePtr; - this.view.requestRender(); - } - public void setScale(float s) { this.scale = s; } - - public void releaseResources() { - if (this.contextPtr != 0) { - try { - GaneshPictureRenderer.CleanUp(this.contextPtr); - } catch (UnsatisfiedLinkError e) { - Log.e(TAG, "CleanUp failed", e); - } - } - this.contextPtr = 0; - } - - private void createContext() { - try { - this.contextPtr = GaneshPictureRenderer.Ctor(); - } catch (UnsatisfiedLinkError e) { - Log.e(TAG, "Ctor failed", e); - } - } - - @Override - public void onSurfaceCreated(GL10 gl, EGLConfig c) { - this.releaseResources(); - this.createContext(); - } - @Override - public void onDrawFrame(GL10 gl) { - if (this.contextPtr == 0) { - this.createContext(); - } - if (this.width > 0 && this.height > 0 && - this.contextPtr != 0 && this.picturePtr != 0) { - try { - GaneshPictureRenderer.DrawThisFrame( - this.width, this.height, this.scale, - this.contextPtr, this.picturePtr); - } catch (UnsatisfiedLinkError e) { - Log.e(TAG, "DrawThisFrame failed", e); - } - } - } - @Override - public void onSurfaceChanged(GL10 gl, int w, int h) { - this.width = w; - this.height = h; - } - @Override - public void finalize() throws Throwable { - super.finalize(); - this.releaseResources(); - } - - // Make the native functions static to simplify JNI interaction. - private static native void DrawThisFrame(int w, int h, float s, long pr, long pc); - private static native long Ctor(); - private static native void CleanUp(long p); - private static native void GetCullRect(Rect r, long picture); -} diff --git a/platform_tools/android/apps/canvasproof/src/main/java/org/skia/canvasproof/HwuiPictureView.java b/platform_tools/android/apps/canvasproof/src/main/java/org/skia/canvasproof/HwuiPictureView.java deleted file mode 100644 index 872089c9d3..0000000000 --- a/platform_tools/android/apps/canvasproof/src/main/java/org/skia/canvasproof/HwuiPictureView.java +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Copyright 2015 Google Inc. - * - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -package org.skia.canvasproof; - -import android.content.Context; -import android.graphics.Bitmap; -import android.graphics.Canvas; -import android.graphics.Color; -import android.graphics.Paint; -import android.graphics.Picture; -import android.util.Log; -import android.view.View; -import java.io.IOException; -import java.io.InputStream; - -public class HwuiPictureView extends View { - private static final String TAG = "HwuiPictureView"; - private Picture picture; - private float scale; - private Picture defaultPicture; - - public boolean fullTime; - - HwuiPictureView(Context context) { - super(context); - this.scale = 1.0f; - } - public void setScale(float s) { - this.scale = s; - } - public void setPicture(Picture p) { - this.picture = p; - this.invalidate(); - } - - @Override - protected void onDraw(Canvas canvas) { - if (this.picture != null) { - canvas.save(); - canvas.scale(scale, scale); - HwuiPictureView.draw(canvas, this.picture); - canvas.restore(); - if (fullTime) { - this.invalidate(); - } - } - } - - static private void draw(Canvas canvas, Picture p) { - if (android.os.Build.VERSION.SDK_INT > 22) { - try { - canvas.drawPicture(p); - return; - } catch (java.lang.Exception e) { - Log.e(TAG, "Exception while drawing picture in Hwui"); - } - } - if (p.getWidth() > 0 && p.getHeight() > 0) { - // Fallback to software rendering. - Bitmap bm = Bitmap.createBitmap(p.getWidth(), p.getHeight(), - Bitmap.Config.ARGB_8888); - (new Canvas(bm)).drawPicture(p); - canvas.drawBitmap(bm, 0.0f, 0.0f, null); - bm.recycle(); - } - } -} diff --git a/platform_tools/android/apps/canvasproof/src/main/jni/JavaInputStream.cpp b/platform_tools/android/apps/canvasproof/src/main/jni/JavaInputStream.cpp deleted file mode 100644 index 823b72f7ef..0000000000 --- a/platform_tools/android/apps/canvasproof/src/main/jni/JavaInputStream.cpp +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright 2015 Google Inc. - * - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include "JavaInputStream.h" - -JavaInputStream::JavaInputStream( - JNIEnv* env, jbyteArray javaBuffer, jobject inputStream) - : fEnv(env) - , fStartIndex(0) - , fEndIndex(0) { - SkASSERT(inputStream); - SkASSERT(javaBuffer); - fInputStream = inputStream; - fJavaBuffer = javaBuffer; - fInputStreamClass = env->FindClass("java/io/InputStream"); - SkASSERT(fInputStreamClass); - fReadMethodID = env->GetMethodID(fInputStreamClass, "read", "([B)I"); - SkASSERT(fReadMethodID); -} - -bool JavaInputStream::isAtEnd() const { return fStartIndex == fEndIndex; } - -size_t JavaInputStream::read(void* voidBuffer, size_t size) { - size_t totalRead = 0; - char* buffer = static_cast(voidBuffer); // may be NULL; - while (size) { - // make sure the cache has at least one byte or is done. - if (fStartIndex == fEndIndex) { - jint count = - fEnv->CallIntMethod(fInputStream, fReadMethodID, fJavaBuffer); - if (fEnv->ExceptionCheck()) { - fEnv->ExceptionDescribe(); - fEnv->ExceptionClear(); - SkDebugf("---- java.io.InputStream::read() threw an exception\n"); - return 0; - } - fStartIndex = 0; - fEndIndex = count; - if (this->isAtEnd()) { - return totalRead; // No more to read. - } - } - SkASSERT(fEndIndex > fStartIndex); - size_t length = SkTMin(SkToSizeT(fEndIndex - fStartIndex), size); - if (buffer && length) { - jbyte* bufferElements - = fEnv->GetByteArrayElements(fJavaBuffer, NULL); - memcpy(buffer, &bufferElements[fStartIndex], length); - buffer += length; - fEnv->ReleaseByteArrayElements(fJavaBuffer, bufferElements, 0); - } - totalRead += length; - size -= length; - fStartIndex += length; - } - return totalRead; -} diff --git a/platform_tools/android/apps/canvasproof/src/main/jni/JavaInputStream.h b/platform_tools/android/apps/canvasproof/src/main/jni/JavaInputStream.h deleted file mode 100644 index e14e026552..0000000000 --- a/platform_tools/android/apps/canvasproof/src/main/jni/JavaInputStream.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright 2015 Google Inc. - * - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ -#ifndef JavaInputStream_DEFINED -#define JavaInputStream_DEFINED - -#include -#include "SkStream.h" - -class JavaInputStream : public SkStream { -public: - JavaInputStream(JNIEnv*, jbyteArray javaBuffer, jobject javaIoInputStream); - bool isAtEnd() const override; - size_t read(void*, size_t) override; -private: - JNIEnv* fEnv; - jobject fInputStream; - jbyteArray fJavaBuffer; - jclass fInputStreamClass; - jmethodID fReadMethodID; - jint fStartIndex; - jint fEndIndex; -}; - -#endif // JavaInputStream_DEFINED diff --git a/platform_tools/android/apps/canvasproof/src/main/jni/org_skia_canvasproof_CreateSkiaPicture.cpp b/platform_tools/android/apps/canvasproof/src/main/jni/org_skia_canvasproof_CreateSkiaPicture.cpp deleted file mode 100644 index 086cd5d42e..0000000000 --- a/platform_tools/android/apps/canvasproof/src/main/jni/org_skia_canvasproof_CreateSkiaPicture.cpp +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright 2015 Google Inc. - * - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include "org_skia_canvasproof_CreateSkiaPicture.h" -#include "JavaInputStream.h" -#include "SkPicture.h" -#include "SkPictureRecorder.h" - -/* - * Class: org_skia_canvasproof_CreateSkiaPicture - * Method: delete - * Signature: (J)V - */ -JNIEXPORT void JNICALL Java_org_skia_canvasproof_CreateSkiaPicture_deleteImpl( - JNIEnv* env, jclass clazz, jlong ptr) { - SkSafeUnref(reinterpret_cast(ptr)); -} - -/* - * Class: org_skia_canvasproof_CreateSkiaPicture - * Method: createImpl - * Signature: (Ljava/io/InputStream;[B)J - */ -JNIEXPORT jlong JNICALL Java_org_skia_canvasproof_CreateSkiaPicture_createImpl - (JNIEnv* env, jclass clazz, jobject inputStream, jbyteArray buffer) { - JavaInputStream stream(env, buffer, inputStream); - #if 0 - sk_sp p(SkPicture::CreateFromStream(&stream)); - if (!p) { return 0; } - SkPictureRecorder recorder; - SkRect bounds = p->cullRect(); - SkRTreeFactory bbh; - recorder.beginRecording(bounds, &bbh)->drawPicture(p); - return reinterpret_cast(recorder.endRecordingAsPicture()); - #else - return reinterpret_cast(SkPicture::CreateFromStream(&stream)); - #endif -} diff --git a/platform_tools/android/apps/canvasproof/src/main/jni/org_skia_canvasproof_CreateSkiaPicture.h b/platform_tools/android/apps/canvasproof/src/main/jni/org_skia_canvasproof_CreateSkiaPicture.h deleted file mode 100644 index 2937d549ef..0000000000 --- a/platform_tools/android/apps/canvasproof/src/main/jni/org_skia_canvasproof_CreateSkiaPicture.h +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright 2015 Google Inc. - * - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ -/* DO NOT EDIT THIS FILE - it is machine generated */ -#include -/* Header for class org_skia_canvasproof_CreateSkiaPicture */ - -#ifndef _Included_org_skia_canvasproof_CreateSkiaPicture -#define _Included_org_skia_canvasproof_CreateSkiaPicture -#ifdef __cplusplus -extern "C" { -#endif -/* - * Class: org_skia_canvasproof_CreateSkiaPicture - * Method: deleteImpl - * Signature: (J)V - */ -JNIEXPORT void JNICALL Java_org_skia_canvasproof_CreateSkiaPicture_deleteImpl - (JNIEnv *, jclass, jlong); - -/* - * Class: org_skia_canvasproof_CreateSkiaPicture - * Method: createImpl - * Signature: (Ljava/io/InputStream;[B)J - */ -JNIEXPORT jlong JNICALL Java_org_skia_canvasproof_CreateSkiaPicture_createImpl - (JNIEnv *, jclass, jobject, jbyteArray); - -#ifdef __cplusplus -} -#endif -#endif diff --git a/platform_tools/android/apps/canvasproof/src/main/jni/org_skia_canvasproof_GaneshPictureRenderer.cpp b/platform_tools/android/apps/canvasproof/src/main/jni/org_skia_canvasproof_GaneshPictureRenderer.cpp deleted file mode 100644 index 1bdc655ef2..0000000000 --- a/platform_tools/android/apps/canvasproof/src/main/jni/org_skia_canvasproof_GaneshPictureRenderer.cpp +++ /dev/null @@ -1,145 +0,0 @@ -/* - * Copyright 2015 Google Inc. - * - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include "org_skia_canvasproof_GaneshPictureRenderer.h" - -#include "GrContext.h" -#include "JavaInputStream.h" -#include "SkCanvas.h" -#include "SkMatrix.h" -#include "SkPicture.h" -#include "SkRect.h" -#include "SkStream.h" -#include "SkSurface.h" - -#define TAG "GaneshPictureRenderer.cpp: " - -static void render_picture(GrContext* grContext, - int width, - int height, - const SkPicture* picture, - const SkMatrix& matrix) { - SkASSERT(grContext); - if (!picture) { - SkDebugf(TAG "!picture\n"); - return; - } - // Render to the default framebuffer render target. - GrBackendRenderTargetDesc desc; - desc.fWidth = width; - desc.fHeight = height; - desc.fConfig = kSkia8888_GrPixelConfig; - desc.fOrigin = kBottomLeft_GrSurfaceOrigin; - SkSurfaceProps surfaceProps(SkSurfaceProps::kUseDeviceIndependentFonts_Flag, - kUnknown_SkPixelGeometry); - // TODO: Check to see if we can keep the surface between draw calls. - sk_sp surface( - SkSurface::MakeFromBackendRenderTarget(grContext, desc, nullptr, &surfaceProps)); - if (surface) { - SkCanvas* canvas = surface->getCanvas(); - SkASSERT(canvas); - canvas->clear(SK_ColorGRAY); - canvas->concat(matrix); - SkRect cullRect = picture->cullRect(); - canvas->clipRect(cullRect); - picture->playback(canvas); - canvas->flush(); - } -} - -namespace { -struct GaneshPictureRendererImpl { - sk_sp fGrContext; - void render(int w, int h, const SkPicture* p, const SkMatrix& m) { - if (!fGrContext) { - // Cache the rendering context between frames. - fGrContext.reset(GrContext::Create(kOpenGL_GrBackend, 0)); - if (!fGrContext) { - SkDebugf(TAG "GrContext::Create - failed\n"); - return; - } - } - render_picture(fGrContext, w, h, p, m); - } -}; -} // namespace - -/* - * Class: org_skia_canvasproof_GaneshPictureRenderer - * Method: DrawThisFrame - * Signature: (IIFJ)V - */ -JNIEXPORT void JNICALL Java_org_skia_canvasproof_GaneshPictureRenderer_DrawThisFrame( - JNIEnv*, jclass, jint width, jint height, jfloat scale, jlong ptr, jlong pic) { - if (!ptr) { return; } - SkMatrix matrix = SkMatrix::MakeScale((SkScalar)scale); - GaneshPictureRendererImpl* impl = - reinterpret_cast(ptr); - SkPicture* picture = reinterpret_cast(pic); - impl->render((int)width, (int)height, picture, matrix); -} - -/* - * Class: org_skia_canvasproof_GaneshPictureRenderer - * Method: Ctor - * Signature: ()J - */ -JNIEXPORT jlong JNICALL Java_org_skia_canvasproof_GaneshPictureRenderer_Ctor - (JNIEnv *, jclass) { - return reinterpret_cast(new GaneshPictureRendererImpl); -} - -/* - * Class: org_skia_canvasproof_GaneshPictureRenderer - * Method: CleanUp - * Signature: (J)V - */ -JNIEXPORT void JNICALL Java_org_skia_canvasproof_GaneshPictureRenderer_CleanUp - (JNIEnv *, jclass, jlong ptr) { - delete reinterpret_cast(ptr); -} - -namespace { -struct AndroidRectHelper { - jfieldID fLeft, fTop, fRight, fBottom; - AndroidRectHelper() - : fLeft(nullptr), fTop(nullptr), fRight(nullptr), fBottom(nullptr) {} - void config(JNIEnv *env) { - if (!fLeft) { - jclass rectClass = env->FindClass("android/graphics/Rect"); - SkASSERT(rectClass); - fLeft = env->GetFieldID(rectClass, "left", "I"); - fTop = env->GetFieldID(rectClass, "top", "I"); - fRight = env->GetFieldID(rectClass, "right", "I"); - fBottom = env->GetFieldID(rectClass, "bottom", "I"); - } - } -}; -} // namespace - -/* - * Class: org_skia_canvasproof_GaneshPictureRenderer - * Method: GetCullRect - * Signature: (Landroid/graphics/Rect;J)V - */ -JNIEXPORT void JNICALL Java_org_skia_canvasproof_GaneshPictureRenderer_GetCullRect - (JNIEnv *env, jclass, jobject androidGraphicsRect, jlong picturePtr) { - SkASSERT(androidGraphicsRect); - const SkPicture* picture = reinterpret_cast(picturePtr); - SkRect rect = SkRect::MakeEmpty(); - if (picture) { - rect = picture->cullRect(); - } - SkIRect iRect; - rect.roundOut(&iRect); - static AndroidRectHelper help; - help.config(env); - env->SetIntField(androidGraphicsRect, help.fLeft, (jint)(iRect.left())); - env->SetIntField(androidGraphicsRect, help.fTop, (jint)(iRect.top())); - env->SetIntField(androidGraphicsRect, help.fRight, (jint)(iRect.right())); - env->SetIntField(androidGraphicsRect, help.fBottom, (jint)(iRect.bottom())); -} diff --git a/platform_tools/android/apps/canvasproof/src/main/jni/org_skia_canvasproof_GaneshPictureRenderer.h b/platform_tools/android/apps/canvasproof/src/main/jni/org_skia_canvasproof_GaneshPictureRenderer.h deleted file mode 100644 index 401fa87872..0000000000 --- a/platform_tools/android/apps/canvasproof/src/main/jni/org_skia_canvasproof_GaneshPictureRenderer.h +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright 2015 Google Inc. - * - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/* DO NOT EDIT THIS FILE - it is machine generated */ -#include -/* Header for class org_skia_canvasproof_GaneshPictureRenderer */ - -#ifndef _Included_org_skia_canvasproof_GaneshPictureRenderer -#define _Included_org_skia_canvasproof_GaneshPictureRenderer -#ifdef __cplusplus -extern "C" { -#endif -/* - * Class: org_skia_canvasproof_GaneshPictureRenderer - * Method: DrawThisFrame - * Signature: (IIFJJ)V - */ -JNIEXPORT void JNICALL Java_org_skia_canvasproof_GaneshPictureRenderer_DrawThisFrame - (JNIEnv *, jclass, jint, jint, jfloat, jlong, jlong); - -/* - * Class: org_skia_canvasproof_GaneshPictureRenderer - * Method: Ctor - * Signature: ()J - */ -JNIEXPORT jlong JNICALL Java_org_skia_canvasproof_GaneshPictureRenderer_Ctor - (JNIEnv *, jclass); - -/* - * Class: org_skia_canvasproof_GaneshPictureRenderer - * Method: CleanUp - * Signature: (J)V - */ -JNIEXPORT void JNICALL Java_org_skia_canvasproof_GaneshPictureRenderer_CleanUp - (JNIEnv *, jclass, jlong); - -/* - * Class: org_skia_canvasproof_GaneshPictureRenderer - * Method: GetCullRect - * Signature: (Landroid/graphics/Rect;J)V - */ -JNIEXPORT void JNICALL Java_org_skia_canvasproof_GaneshPictureRenderer_GetCullRect - (JNIEnv *, jclass, jobject, jlong); - -#ifdef __cplusplus -} -#endif -#endif diff --git a/platform_tools/android/apps/gradle/wrapper/gradle-wrapper.properties b/platform_tools/android/apps/gradle/wrapper/gradle-wrapper.properties index be9e31c6af..9326d8c394 100644 --- a/platform_tools/android/apps/gradle/wrapper/gradle-wrapper.properties +++ b/platform_tools/android/apps/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ -#Tue Jul 07 11:56:32 EDT 2015 +#Fri Dec 02 09:57:59 EST 2016 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-2.10-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip diff --git a/platform_tools/android/apps/settings.gradle b/platform_tools/android/apps/settings.gradle index faa393409c..75ce0a6db1 100644 --- a/platform_tools/android/apps/settings.gradle +++ b/platform_tools/android/apps/settings.gradle @@ -1,2 +1 @@ -include ':canvasproof' include ':viewer' diff --git a/platform_tools/android/apps/viewer/build.gradle b/platform_tools/android/apps/viewer/build.gradle index 6da64be3b5..e231a6f3d0 100644 --- a/platform_tools/android/apps/viewer/build.gradle +++ b/platform_tools/android/apps/viewer/build.gradle @@ -24,7 +24,7 @@ android { } sourceSets.main.jni.srcDirs = [] //disable automatic ndk-build call sourceSets.main.jniLibs.srcDir "src/main/libs" - productFlavors { arm {}; arm64 {}; x86 {}; x86_64 {}; mips {}; mips64 {}; arm64vulkan{}; } + productFlavors { arm {}; arm64 {}; x86 {}; x64 {}; mipsel {}; mips64el {}; arm64vulkan{}; } - setupSkiaLibraryBuild(project, applicationVariants, "CopyViewerDeps", true) + setupSkiaLibraryBuild(project, applicationVariants, "libviewer") } diff --git a/platform_tools/android/apps/viewer/src/main/java/org/skia/viewer/ViewerApplication.java b/platform_tools/android/apps/viewer/src/main/java/org/skia/viewer/ViewerApplication.java index 5849724741..2dcce90e63 100644 --- a/platform_tools/android/apps/viewer/src/main/java/org/skia/viewer/ViewerApplication.java +++ b/platform_tools/android/apps/viewer/src/main/java/org/skia/viewer/ViewerApplication.java @@ -15,7 +15,6 @@ public class ViewerApplication extends Application { private String mStateJsonStr, mTitle; static { - System.loadLibrary("skia_android"); System.loadLibrary("viewer"); } diff --git a/platform_tools/android/bin/android_install_app b/platform_tools/android/bin/android_install_app index fe16cd5285..0c9cd54506 100755 --- a/platform_tools/android/bin/android_install_app +++ b/platform_tools/android/bin/android_install_app @@ -7,13 +7,12 @@ function print_usage { echo " Options: -f Forces the package to be installed by removing any" echo " previously installed packages" echo " -h Prints this help message" - echo " --release Install the release build of Skia" echo " -s [device_s/n] Serial number of the device to be used" } SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" -source $SCRIPT_DIR/android_setup.sh +source $SCRIPT_DIR/utils/android_setup.sh source $SCRIPT_DIR/utils/setup_adb.sh forceRemoval="false" @@ -24,8 +23,6 @@ for arg in ${APP_ARGS[@]}; do elif [[ "${arg}" == "-h" ]]; then print_usage exit - elif [[ "${arg}" == "-r" ]]; then - echo "DEPRECATED: -r is now a no-op" elif [[ ${arg} == '-'* ]]; then echo "ERROR: unrecognized option ${arg}" print_usage @@ -33,22 +30,14 @@ for arg in ${APP_ARGS[@]}; do fi done +APP_LC=$(echo Viewer | tr "[:upper:]" "[:lower:]") if [[ "$forceRemoval" == "true" ]]; then echo "Forcing removal of previously installed packages" - $ADB ${DEVICE_SERIAL} uninstall com.skia > /dev/null -fi - -if [[ "$BUILDTYPE" == "Release" ]]; -then - apk_suffix="release.apk" -else - apk_suffix="debug.apk" + $ADB ${DEVICE_SERIAL} uninstall org.skia.${APP_LC} > /dev/null fi -APP_LC=$(echo Viewer | tr "[:upper:]" "[:lower:]") - -echo "Installing ${APP_LC} from ${APP_LC}/build/outputs/apk/${APP_LC}-${ANDROID_ARCH}-${apk_suffix}" -$ADB ${DEVICE_SERIAL} install -r ${SCRIPT_DIR}/../apps/${APP_LC}/build/outputs/apk/${APP_LC}-${ANDROID_ARCH}-${apk_suffix} +echo "Installing ${APP_LC} from ${SKIA_OUT}/${APP_LC}.apk" +$ADB ${DEVICE_SERIAL} install -r ${SKIA_OUT}/${APP_LC}.apk diff --git a/platform_tools/android/bin/android_launch_app b/platform_tools/android/bin/android_launch_app index 0e65ba143d..46cd4b11c3 100755 --- a/platform_tools/android/bin/android_launch_app +++ b/platform_tools/android/bin/android_launch_app @@ -3,7 +3,7 @@ # android_launch_app: Launches the skia Viewer app on the device. SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" -source $SCRIPT_DIR/android_setup.sh +source $SCRIPT_DIR/utils/android_setup.sh source $SCRIPT_DIR/utils/setup_adb.sh # TODO: check to ensure that the app exists on the device and prompt to install diff --git a/platform_tools/android/bin/android_make b/platform_tools/android/bin/android_make deleted file mode 100755 index cac0cc93c6..0000000000 --- a/platform_tools/android/bin/android_make +++ /dev/null @@ -1,22 +0,0 @@ -#!/bin/bash - -# Fail-fast if anything in the script fails. -set -e - -# Remove any existing .android_config file before running android_setup. If we -# did not remove this now then we would build for whatever device type was -# listed in the .android_config instead of the default device type. -rm -f .android_config - -SCRIPT_DIR=$(dirname "${BASH_SOURCE[0]}") -source $SCRIPT_DIR/utils/android_setup.sh - -SKIA_SRC_DIR=$(cd "${SCRIPT_DIR}/../../.."; pwd) -echo $GN_ARGS -gn gen $SKIA_OUT --args="${GN_ARGS}" -ninja -C $SKIA_OUT ${APP_ARGS[@]} - -# Write the device id into the .android_config file. This tells -# android_run_skia the last build we completed. -echo $DEVICE_ID > .android_config - diff --git a/platform_tools/android/bin/android_ninja b/platform_tools/android/bin/android_ninja deleted file mode 120000 index 68a0fb120e..0000000000 --- a/platform_tools/android/bin/android_ninja +++ /dev/null @@ -1 +0,0 @@ -android_make \ No newline at end of file diff --git a/platform_tools/android/bin/utils/android_setup.sh b/platform_tools/android/bin/utils/android_setup.sh index a50819efa7..a63fcafe65 100755 --- a/platform_tools/android/bin/utils/android_setup.sh +++ b/platform_tools/android/bin/utils/android_setup.sh @@ -14,8 +14,8 @@ set -e IS_DEBUG="false" while (( "$#" )); do - if [[ "$1" == "-d" ]]; then - DEVICE_ID=$2 + if [[ "$1" == "-C" ]]; then + SKIA_OUT=$2 shift elif [[ "$1" == "-i" || "$1" == "--resourcePath" ]]; then RESOURCE_PATH=$2 @@ -24,14 +24,10 @@ while (( "$#" )); do elif [[ "$1" == "-s" ]]; then DEVICE_SERIAL="-s $2" shift - elif [[ "$1" == "--debug" ]]; then - IS_DEBUG="true" elif [[ "$1" == "--logcat" ]]; then LOGCAT=1 elif [[ "$1" == "--verbose" ]]; then VERBOSE="true" - elif [[ "$1" == "--vulkan" ]]; then - SKIA_VULKAN="true" else APP_ARGS=("${APP_ARGS[@]}" "${1}") fi @@ -80,77 +76,6 @@ if [ -z "$ANDROID_NDK_ROOT" ]; then fi fi -# Helper function to configure the GN defines to the appropriate values -# based on the target device. -setup_device() { - DEFINES="ndk=\"${ANDROID_NDK_ROOT}\" is_debug=${IS_DEBUG}" - - if [ $SKIA_VULKAN == "true" ]; then - DEFINES="${DEFINES} ndk_api=24" - fi - - # Setup the build variation depending on the target device - TARGET_DEVICE="$1" - - if [ -z "$TARGET_DEVICE" ]; then - if [ -f .android_config ]; then - TARGET_DEVICE=$(cat .android_config) - verbose "no target device (-d), using ${TARGET_DEVICE} from most recent build" - else - TARGET_DEVICE="arm_v7" - verbose "no target device (-d), using ${TARGET_DEVICE}" - fi - fi - - case $TARGET_DEVICE in - arm_v7 | nexus_4 | nexus_5 | nexus_6 | nexus_7 | nexus_10) - DEFINES="${DEFINES} target_cpu=\"arm\"" - GDBSERVER_DIR="${ANDROID_NDK_ROOT}/prebuilt/android-arm" - IS_64_BIT=false - ;; - arm64 | nexus_9 | nexus_5x | nexus_6p | pixel) - DEFINES="${DEFINES} target_cpu=\"arm64\"" - GDBSERVER_DIR="${ANDROID_NDK_ROOT}/prebuilt/android-arm64" - IS_64_BIT=true - ;; - x86) - DEFINES="${DEFINES} target_cpu=\"x86\"" - GDBSERVER_DIR="${ANDROID_NDK_ROOT}/prebuilt/android-x86" - IS_64_BIT=false - ;; - x86_64 | x64) - DEFINES="${DEFINES} target_cpu=\"x64\"" - GDBSERVER_DIR="${ANDROID_NDK_ROOT}/prebuilt/android-x86_64" - IS_64_BIT=true - ;; - mips) - DEFINES="${DEFINES} target_cpu=\"mipsel\"" - GDBSERVER_DIR="${ANDROID_NDK_ROOT}/prebuilt/android-mips" - IS_64_BIT=false - #DEFINES="${DEFINES} skia_resource_cache_mb_limit=32" - ;; - mips64) - DEFINES="${DEFINES} target_cpu=\"mips64el\"" - GDBSERVER_DIR="${ANDROID_NDK_ROOT}/prebuilt/android-mips64" - IS_64_BIT=true - ;; - *) - echo "ERROR: unknown device $TARGET_DEVICE" - exit 1 - ;; - esac - - verbose "The build is targeting the device: $TARGET_DEVICE" - exportVar DEVICE_ID $TARGET_DEVICE - exportVar GN_ARGS "$DEFINES" - exportVar GDBSERVER_DIR $GDBSERVER_DIR - exportVar IS_64_BIT $IS_64_BIT - - SKIA_SRC_DIR=$(cd "${UTIL_DIR}/../../../.."; pwd) - DEFAULT_SKIA_OUT="${SKIA_SRC_DIR}/out/android-${TARGET_DEVICE}" - exportVar SKIA_OUT "${SKIA_OUT:-${DEFAULT_SKIA_OUT}}" -} - # adb_pull_if_needed(android_src, host_dst) adb_pull_if_needed() { @@ -247,5 +172,3 @@ adb_push_if_needed() { # turn error checking back on set -e } - -setup_device "${DEVICE_ID}" -- cgit v1.2.3