From a92c383e2f1ceb0323aef79fa444450e6a3e1c03 Mon Sep 17 00:00:00 2001 From: Mike Klein Date: Thu, 8 Dec 2016 09:49:39 -0500 Subject: [PATCH] libviewer.so on Android, delete hello_skia_app This spins off parts of 5620 to bake while we work through how to do the rest of libviewer.so -> viewer.apk. Change-Id: I1cbf135cc952eeb7593e80a5a752dcadaa2dbb00 Reviewed-on: https://skia-review.googlesource.com/5656 Reviewed-by: Derek Sollenberger Commit-Queue: Mike Klein --- BUILD.gn | 20 +++- .../hello_skia_app/AndroidManifest.xml | 17 ---- .../android/examples/hello_skia_app/README | 39 -------- .../android/examples/hello_skia_app/build.xml | 92 ------------------ .../examples/hello_skia_app/jni/Android.mk | 42 -------- .../examples/hello_skia_app/jni/helloskia.cpp | 77 --------------- .../hello_skia_app/project.properties | 14 --- .../res/drawable-mdpi/ic_launcher.png | Bin 5237 -> 0 bytes .../hello_skia_app/res/values/strings.xml | 4 - .../src/com/example/HelloSkiaActivity.java | 74 -------------- 10 files changed, 18 insertions(+), 361 deletions(-) delete mode 100644 platform_tools/android/examples/hello_skia_app/AndroidManifest.xml delete mode 100644 platform_tools/android/examples/hello_skia_app/README delete mode 100644 platform_tools/android/examples/hello_skia_app/build.xml delete mode 100644 platform_tools/android/examples/hello_skia_app/jni/Android.mk delete mode 100644 platform_tools/android/examples/hello_skia_app/jni/helloskia.cpp delete mode 100644 platform_tools/android/examples/hello_skia_app/project.properties delete mode 100755 platform_tools/android/examples/hello_skia_app/res/drawable-mdpi/ic_launcher.png delete mode 100644 platform_tools/android/examples/hello_skia_app/res/values/strings.xml delete mode 100644 platform_tools/android/examples/hello_skia_app/src/com/example/HelloSkiaActivity.java diff --git a/BUILD.gn b/BUILD.gn index 1ee4d609c1..c687ded6de 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -1311,8 +1311,8 @@ if (skia_enable_tools) { testonly = true } - if (skia_enable_gpu && (is_linux || is_win || is_mac)) { - executable("viewer") { + if (skia_enable_gpu && (is_android || is_linux || is_win || is_mac)) { + source_set("viewer_sources") { sources = [ "tools/viewer/GMSlide.cpp", "tools/viewer/ImageSlide.cpp", @@ -1389,6 +1389,22 @@ if (skia_enable_tools) { } testonly = true } + + if (is_android) { + shared_library("libviewer") { + deps = [ + ":viewer_sources", + ] + testonly = true + } + } else { + executable("viewer") { + deps = [ + ":viewer_sources", + ] + testonly = true + } + } } if (skia_enable_gpu) { diff --git a/platform_tools/android/examples/hello_skia_app/AndroidManifest.xml b/platform_tools/android/examples/hello_skia_app/AndroidManifest.xml deleted file mode 100644 index 1fc187f581..0000000000 --- a/platform_tools/android/examples/hello_skia_app/AndroidManifest.xml +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - - - - - - - diff --git a/platform_tools/android/examples/hello_skia_app/README b/platform_tools/android/examples/hello_skia_app/README deleted file mode 100644 index 0bc66afa8a..0000000000 --- a/platform_tools/android/examples/hello_skia_app/README +++ /dev/null @@ -1,39 +0,0 @@ -HelloSkia -========= - -Intro ------ - -This is a minimal Android app that uses JNI and Skia to do rendering. - -Setup ------ - -These instructions need to be followed only once to setup your copy of HelloSkia. Path parts that -are surrounded with curly braces should be replaced with the paths that are described. - -1. Follow the quick start guide on building Skia for Android. - -2. Copy {Skia root directory}/trunk/out/config/android-{your architecture}/{Relase or -Debug}/lib.target/libskia_android.so into {HellSkia root directory}/jni/skia/libskia_android.so - -3. Copy {Skia root directory}/trunk/include into {HellSkia root directory}/jni/skia. This should be -done so that the path {HellSkia root directory}/jni/skia/include is a folder that contains, to name -just a few, the folders config and core. - - -Building --------- - -The following assumes that the platform-tools directory of the Android SDK and the Android NDK -directory are both on the system path. This also assumes that adb is working and connected with some -device or virtual device. - -1. Open a terminal to the HelloSkia root directory and enter these commands: - -$ ndk-build # Builds the modules inside of jni/ -$ ant debug # Builds the Activity and packages it with all resources and modules of jni/ -$ adb install -r bin/HelloSkia-debug.apk # Installs the app onto a device - -2. To run the app, open your Android device's launcher and start the application labeled -HelloSkiaActivity. diff --git a/platform_tools/android/examples/hello_skia_app/build.xml b/platform_tools/android/examples/hello_skia_app/build.xml deleted file mode 100644 index 785b87b0a2..0000000000 --- a/platform_tools/android/examples/hello_skia_app/build.xml +++ /dev/null @@ -1,92 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/platform_tools/android/examples/hello_skia_app/jni/Android.mk b/platform_tools/android/examples/hello_skia_app/jni/Android.mk deleted file mode 100644 index 45a57c7860..0000000000 --- a/platform_tools/android/examples/hello_skia_app/jni/Android.mk +++ /dev/null @@ -1,42 +0,0 @@ -LOCAL_PATH := $(call my-dir) - -## -# Sets up a module for the skia shared object to be copied into the apk. -## - -include $(CLEAR_VARS) - -# Name for referencing this module in other modules -LOCAL_MODULE := skia_android - -# Local filename of the skia shared object -LOCAL_SRC_FILES := skia/libskia_android.so - -# Makes this module into shared object that is simply copied into the apk -include $(PREBUILT_SHARED_LIBRARY) - - -## -# Sets up the JNI module that our app calls into to draw things with skia. -## - -include $(CLEAR_VARS) # clear out the variables of the previous module - -# Name of the module that the app will reference with System.loadLibrary -LOCAL_MODULE := hello_skia_ndk - -# List of the source files compiled for this module -LOCAL_SRC_FILES := helloskia.cpp - -# Makes the skia shared object get pulled in as a reference -LOCAL_SHARED_LIBRARIES := skia_android - -# jnigraphics defines the function AndroidBitmap_lockPixels, which we need in order to draw into -# android.graphics.Bitmap -LOCAL_LDLIBS := -ljnigraphics - -# Allows the compiler to find the Skia header files -LOCAL_C_INCLUDES := $(LOCAL_PATH)/skia/include/config \ - $(LOCAL_PATH)/skia/include/core - -include $(BUILD_SHARED_LIBRARY) diff --git a/platform_tools/android/examples/hello_skia_app/jni/helloskia.cpp b/platform_tools/android/examples/hello_skia_app/jni/helloskia.cpp deleted file mode 100644 index 2e12d37a6b..0000000000 --- a/platform_tools/android/examples/hello_skia_app/jni/helloskia.cpp +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Copyright 2016 Google Inc. - * - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include -#include -#include - -#include "SkCanvas.h" -#include "SkGraphics.h" -#include "SkSurface.h" -#include "SkString.h" -#include "SkTime.h" - - -/** - * Draws something into the given bitmap - * @param env - * @param thiz - * @param dstBitmap The bitmap to place the results of skia into - * @param elapsedTime The number of milliseconds since the app was started - */ -extern "C" -JNIEXPORT void JNICALL Java_com_example_HelloSkiaActivity_drawIntoBitmap(JNIEnv* env, - jobject thiz, jobject dstBitmap, jlong elapsedTime) -{ - // Grab the dst bitmap info and pixels - AndroidBitmapInfo dstInfo; - void* dstPixels; - AndroidBitmap_getInfo(env, dstBitmap, &dstInfo); - AndroidBitmap_lockPixels(env, dstBitmap, &dstPixels); - - SkImageInfo info = SkImageInfo::MakeN32Premul(dstInfo.width, dstInfo.height); - - // Create a surface from the given bitmap - sk_sp surface(SkSurface::MakeRasterDirect(info, dstPixels, dstInfo.stride)); - SkCanvas* canvas = surface->getCanvas(); - - // Draw something "interesting" - - // Clear the canvas with a white color - canvas->drawColor(SK_ColorWHITE); - - // Setup a SkPaint for drawing our text - SkPaint paint; - paint.setColor(SK_ColorBLACK); // This is a solid black color for our text - paint.setTextSize(SkIntToScalar(30)); // Sets the text size to 30 pixels - paint.setAntiAlias(true); // We turn on anti-aliasing so that the text to looks good. - - // Draw some text - SkString text("Skia is Best!"); - SkScalar fontHeight = paint.getFontSpacing(); - canvas->drawText(text.c_str(), text.size(), // text's data and length - 10, fontHeight, // X and Y coordinates to place the text - paint); // SkPaint to tell how to draw the text - - // Adapt the SkPaint for drawing blue lines - paint.setAntiAlias(false); // Turning off anti-aliasing speeds up the line drawing - paint.setColor(0xFF0000FF); // This is a solid blue color for our lines - paint.setStrokeWidth(SkIntToScalar(2)); // This makes the lines have a thickness of 2 pixels - - // Draw some interesting lines using trig functions - for (int i = 0; i < 100; i++) - { - float x = (float)i / 99.0f; - float offset = elapsedTime / 1000.0f; - canvas->drawLine(sin(x * M_PI + offset) * 800.0f, 0, // first endpoint - cos(x * M_PI + offset) * 800.0f, 800, // second endpoint - paint); // SkPapint to tell how to draw the line - } - - // Unlock the dst's pixels - AndroidBitmap_unlockPixels(env, dstBitmap); -} diff --git a/platform_tools/android/examples/hello_skia_app/project.properties b/platform_tools/android/examples/hello_skia_app/project.properties deleted file mode 100644 index e0a848dbcc..0000000000 --- a/platform_tools/android/examples/hello_skia_app/project.properties +++ /dev/null @@ -1,14 +0,0 @@ -# This file is automatically generated by Android Tools. -# Do not modify this file -- YOUR CHANGES WILL BE ERASED! -# -# This file must be checked in Version Control Systems. -# -# To customize properties used by the Ant build system edit -# "ant.properties", and override values to adapt the script to your -# project structure. -# -# To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home): -#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt - -# Project target. -target=Google Inc.:Google APIs:15 diff --git a/platform_tools/android/examples/hello_skia_app/res/drawable-mdpi/ic_launcher.png b/platform_tools/android/examples/hello_skia_app/res/drawable-mdpi/ic_launcher.png deleted file mode 100755 index 359047dfa4ed206e41e2354f9c6b307e713efe32..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 5237 zcmV-*6pHJKP)!xJWW@nmR0Ns^Wrk)72_X;&VM@qLNZyn;-h1m-)j4PH{!#b7fObo=TF+Xw z)_t{JRqgNW{e9m)=MZ*rJl6A%IHK!gcqM)U)>TjF8ytMTRLpN39jns9J?@oOe47l4 z1dw7d06;*nuu_+V$6Qs4K>#PCRHVFExV^duw#+4>?(j) z*AHP%*L5@qEpM#j?*@5nOq@HlBR^5M@^_J9)U!&MV7N?QAAfFbdJaGWPgRws)6~+R z-NrZmx0V*7Od$!{dkY1w*wll3j_1b``)C%NHS6N>yBU998+?y%)4SU2YA} zA%$NKSGVi)4!sVH=l1lla~XcBLKrfnO2~CXCa>$GlX_p?dYsM`3%)hidhs()bzlDL zr7zEG>kK#SwpW`1YyR;!pa1&-`0t?)V)3FnK7V~pCo%hYIQUj+f?7Oh#@-(|a?XKA zr;?n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fxbar$}K3^bGfWT*$Wd5R*hEfJ52%w-LATTp*YNZ}ksTNg7J=bnd z-Pkqa!RO=D(kYB&|Wjqg0rvF8kum{NfucTYqrP z`5U%u**G!G6{S=zQMp`3K3_yWUyzoz^2Q(tmC>3+s5Oq`4(BY=)S@2MFgiNo;u?&k zg`0}`37-~9P0%vHiA@+H2!cEy8o#>wuOImB)G_Pj7yce!TXGVt#ORn z(=jFB*q2Zp6$}lGp?}+$um^#4QjKaSEI75c$z6AAYL348>#uKEccl>fFbuUZ0R$d} zZ~}6sT!$|qC`YPurgrtQ76=RC$YS~T-}$t1r_YJ6x+vSq`|xwOl@gGLU>BhcFBv~FMie-ahi$Rz-LINpu0Hu~Za`}LYEdk2y0hQVU6k7}mB|~9e!x(}I6ii4k;VvE0 z?|KG+Oj%0Bi3m(dlp;$c5Cu`1CM@ypLV(%bX9 zr_WVSKiJ10x1!vdPr`gLXF?@f1r%~#N8UkH?XgO1p%e>?-DLnfb z=86?7j~f~sKElT8lSw^&-{|PJ_Z)D@o-cw6^yvN1aY@hS38meM!r|M7s_XW%93Aak za$IUh=gpcu=jzR`4$^18^F8_11#h4-#Jd^}{s&{CB`(>qac=+s03~!qSaf7zbY(hY za%Ew3WdJfTF)=MLIW00WR4_R@Gcr0eGA%GSIxsM(l48sN001R)MObuXVRU6WZEs|0 vW_bWIFflPLFgYzTHdHV-Ix;spGd3+SH##sdcWUue00000NkvXXu0mjfB?gph diff --git a/platform_tools/android/examples/hello_skia_app/res/values/strings.xml b/platform_tools/android/examples/hello_skia_app/res/values/strings.xml deleted file mode 100644 index 9e57560fbd..0000000000 --- a/platform_tools/android/examples/hello_skia_app/res/values/strings.xml +++ /dev/null @@ -1,4 +0,0 @@ - - - HelloSkiaActivity - diff --git a/platform_tools/android/examples/hello_skia_app/src/com/example/HelloSkiaActivity.java b/platform_tools/android/examples/hello_skia_app/src/com/example/HelloSkiaActivity.java deleted file mode 100644 index 53daeaf756..0000000000 --- a/platform_tools/android/examples/hello_skia_app/src/com/example/HelloSkiaActivity.java +++ /dev/null @@ -1,74 +0,0 @@ -package com.example; - -import java.util.Timer; -import java.util.TimerTask; - -import android.app.Activity; -import android.content.Context; -import android.graphics.Bitmap; -import android.graphics.Canvas; -import android.os.Bundle; -import android.os.SystemClock; -import android.util.Log; -import android.view.View; - -public class HelloSkiaActivity extends Activity -{ - private SkiaDrawView fMainView; - - /** Called when the activity is first created. */ - @Override - public void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - - // Makes and sets a SkiaDrawView as the only thing seen in this activity - fMainView = new SkiaDrawView(this); - setContentView(fMainView); - - try { - // Load Skia and then the app shared object in this order - System.loadLibrary("skia_android"); - System.loadLibrary("hello_skia_ndk"); - - } catch (UnsatisfiedLinkError e) { - Log.d("HelloSkia", "Link Error: " + e); - return; - } - - // Set a timer that will periodically request an update of the SkiaDrawView - Timer fAnimationTimer = new Timer(); - fAnimationTimer.schedule(new TimerTask() { - public void run() - { - // This will request an update of the SkiaDrawView, even from other threads - fMainView.postInvalidate(); - } - }, 0, 5); // 0 means no delay before the timer starts; 5 means repeat every 5 milliseconds - } - - private class SkiaDrawView extends View { - Bitmap fSkiaBitmap; - public SkiaDrawView(Context ctx) { - super(ctx); - } - - @Override - protected void onSizeChanged(int w, int h, int oldw, int oldh) - { - // Create a bitmap for skia to draw into - fSkiaBitmap = Bitmap.createBitmap(w, h, Bitmap.Config.ARGB_8888); - } - - @Override - protected void onDraw(Canvas canvas) { - // Call into our C++ code that renders to the bitmap using Skia - drawIntoBitmap(fSkiaBitmap, SystemClock.elapsedRealtime()); - - // Present the bitmap on the screen - canvas.drawBitmap(fSkiaBitmap, 0, 0, null); - } - } - - - private native void drawIntoBitmap(Bitmap image, long elapsedTime); -} -- 2.34.1