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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 package com.example;
2
3 import java.util.Timer;
4 import java.util.TimerTask;
5
6 import android.app.Activity;
7 import android.content.Context;
8 import android.graphics.Bitmap;
9 import android.graphics.Canvas;
10 import android.os.Bundle;
11 import android.os.SystemClock;
12 import android.util.Log;
13 import android.view.View;
14
15 public class HelloSkiaActivity extends Activity
16 {
17 private SkiaDrawView fMainView;
18
19 /** Called when the activity is first created. */
20 @Override
21 public void onCreate(Bundle savedInstanceState) {
22 super.onCreate(savedInstanceState);
23
24 // Makes and sets a SkiaDrawView as the only thing seen in this activity
25 fMainView = new SkiaDrawView(this);
26 setContentView(fMainView);
27
28 try {
29 // Load Skia and then the app shared object in this order
30 System.loadLibrary("skia_android");
31 System.loadLibrary("hello_skia_ndk");
32
33 } catch (UnsatisfiedLinkError e) {
34 Log.d("HelloSkia", "Link Error: " + e);
35 return;
36 }
37
38 // Set a timer that will periodically request an update of the SkiaDrawV iew
39 Timer fAnimationTimer = new Timer();
40 fAnimationTimer.schedule(new TimerTask() {
41 public void run()
42 {
43 // This will request an update of the SkiaDrawView, even from ot her threads
44 fMainView.postInvalidate();
45 }
46 }, 0, 5); // 0 means no delay before the timer starts; 5 means repeat ev ery 5 milliseconds
47 }
48
49 private class SkiaDrawView extends View {
50 Bitmap fSkiaBitmap;
51 public SkiaDrawView(Context ctx) {
52 super(ctx);
53 }
54
55 @Override
56 protected void onSizeChanged(int w, int h, int oldw, int oldh)
57 {
58 // Create a bitmap for skia to draw into
59 fSkiaBitmap = Bitmap.createBitmap(w, h, Bitmap.Config.ARGB_8888);
60 }
61
62 @Override
63 protected void onDraw(Canvas canvas) {
64 // Call into our C++ code that renders to the bitmap using Skia
65 drawIntoBitmap(fSkiaBitmap, SystemClock.elapsedRealtime());
66
67 // Present the bitmap on the screen
68 canvas.drawBitmap(fSkiaBitmap, 0, 0, null);
69 }
70 }
71
72
73 private native void drawIntoBitmap(Bitmap image, long elapsedTime);
74 }
OLDNEW
« 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