Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(408)

Unified Diff: platform_tools/android/examples/hello_skia_app/src/com/example/HelloSkiaActivity.java

Issue 16336004: create simple skia app for android using jni (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: remove binary files Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « platform_tools/android/examples/hello_skia_app/res/values/strings.xml ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: platform_tools/android/examples/hello_skia_app/src/com/example/HelloSkiaActivity.java
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
new file mode 100644
index 0000000000000000000000000000000000000000..53daeaf756ecb5eaa32ed01a7f53f32019a56153
--- /dev/null
+++ b/platform_tools/android/examples/hello_skia_app/src/com/example/HelloSkiaActivity.java
@@ -0,0 +1,74 @@
+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);
+}
« no previous file with comments | « platform_tools/android/examples/hello_skia_app/res/values/strings.xml ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698