| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2012 Google Inc. | 2 * Copyright 2012 Google Inc. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 6 */ | 6 */ |
| 7 | 7 |
| 8 package com.skia; | 8 package com.skia; |
| 9 | 9 |
| 10 import android.opengl.GLSurfaceView; | 10 import android.opengl.GLSurfaceView; |
| 11 import android.os.Handler; | 11 import android.os.Handler; |
| 12 import android.util.Log; | 12 import android.util.Log; |
| 13 | 13 |
| 14 import javax.microedition.khronos.egl.EGLConfig; | 14 import javax.microedition.khronos.egl.EGLConfig; |
| 15 import javax.microedition.khronos.opengles.GL10; | 15 import javax.microedition.khronos.opengles.GL10; |
| 16 import javax.microedition.khronos.opengles.GL11; | 16 import javax.microedition.khronos.opengles.GL11; |
| 17 | 17 |
| 18 public class SkiaSampleRenderer implements GLSurfaceView.Renderer { | 18 public class SkiaSampleRenderer implements GLSurfaceView.Renderer { |
| 19 | 19 |
| 20 private final SkiaSampleView mSampleView; | 20 private final SkiaSampleView mSampleView; |
| 21 private Handler mHandler = new Handler(); | 21 private Handler mHandler = new Handler(); |
| 22 private int mMSAASampleCount; | 22 private int mMSAASampleCount; |
| 23 private String mCmdLineFlags; |
| 23 | 24 |
| 24 SkiaSampleRenderer(SkiaSampleView view) { | 25 SkiaSampleRenderer(SkiaSampleView view, String cmdLineFlags) { |
| 25 mSampleView = view; | 26 mSampleView = view; |
| 27 mCmdLineFlags = cmdLineFlags; |
| 26 } | 28 } |
| 27 | 29 |
| 28 @Override | 30 @Override |
| 29 public void onDrawFrame(GL10 gl) { | 31 public void onDrawFrame(GL10 gl) { |
| 30 draw(); | 32 draw(); |
| 31 } | 33 } |
| 32 | 34 |
| 33 @Override | 35 @Override |
| 34 public void onSurfaceChanged(GL10 gl, int width, int height) { | 36 public void onSurfaceChanged(GL10 gl, int width, int height) { |
| 35 updateSize(width, height); | 37 updateSize(width, height); |
| 36 } | 38 } |
| 37 | 39 |
| 38 @Override | 40 @Override |
| 39 public void onSurfaceCreated(GL10 gl, EGLConfig config) { | 41 public void onSurfaceCreated(GL10 gl, EGLConfig config) { |
| 40 if (gl instanceof GL11) { | 42 if (gl instanceof GL11) { |
| 41 int value[] = new int[1]; | 43 int value[] = new int[1]; |
| 42 ((GL11) gl).glGetIntegerv(GL11.GL_SAMPLES, value, 0); | 44 ((GL11) gl).glGetIntegerv(GL11.GL_SAMPLES, value, 0); |
| 43 if (value[0] == 1) { | 45 if (value[0] == 1) { |
| 44 mMSAASampleCount = 0; | 46 mMSAASampleCount = 0; |
| 45 } else { | 47 } else { |
| 46 mMSAASampleCount = value[0]; | 48 mMSAASampleCount = value[0]; |
| 47 } | 49 } |
| 48 } | 50 } |
| 49 | 51 |
| 50 gl.glClearStencil(0); | 52 gl.glClearStencil(0); |
| 51 gl.glClear(GL10.GL_STENCIL_BUFFER_BIT); | 53 gl.glClear(GL10.GL_STENCIL_BUFFER_BIT); |
| 52 init((SkiaSampleActivity)mSampleView.getContext(), mMSAASampleCount); | 54 |
| 55 init((SkiaSampleActivity)mSampleView.getContext(), mCmdLineFlags, mMSAAS
ampleCount); |
| 53 } | 56 } |
| 54 | 57 |
| 55 // Called by JNI and the view. | 58 // Called by JNI and the view. |
| 56 synchronized public int getMSAASampleCount() { | 59 synchronized public int getMSAASampleCount() { |
| 57 return mMSAASampleCount; | 60 return mMSAASampleCount; |
| 58 } | 61 } |
| 59 | 62 |
| 60 // Called by JNI | 63 // Called by JNI |
| 61 private void startTimer(int ms) { | 64 private void startTimer(int ms) { |
| 62 // After the delay, queue an event to the Renderer's thread | 65 // After the delay, queue an event to the Renderer's thread |
| (...skipping 19 matching lines...) Expand all Loading... |
| 82 processSkEvent(); | 85 processSkEvent(); |
| 83 } | 86 } |
| 84 }); | 87 }); |
| 85 } | 88 } |
| 86 | 89 |
| 87 // Called by JNI | 90 // Called by JNI |
| 88 private void requestRender() { | 91 private void requestRender() { |
| 89 mSampleView.requestRender(); | 92 mSampleView.requestRender(); |
| 90 } | 93 } |
| 91 | 94 |
| 92 native void init(SkiaSampleActivity activity, int msaaSampleCount); | 95 native void init(SkiaSampleActivity activity, String flags, int msaaSampleCo
unt); |
| 93 native void term(); | 96 native void term(); |
| 94 native void draw(); | 97 native void draw(); |
| 95 native void updateSize(int w, int h); | 98 native void updateSize(int w, int h); |
| 96 native void handleClick(int owner, float x, float y, int state); | 99 native void handleClick(int owner, float x, float y, int state); |
| 97 native void showOverview(); | 100 native void showOverview(); |
| 98 native void nextSample(); | 101 native void nextSample(); |
| 99 native void previousSample(); | 102 native void previousSample(); |
| 100 native void goToSample(int position); | 103 native void goToSample(int position); |
| 101 native void toggleRenderingMode(); | 104 native void toggleRenderingMode(); |
| 102 native void toggleSlideshow(); | 105 native void toggleSlideshow(); |
| 103 native void toggleFPS(); | 106 native void toggleFPS(); |
| 104 native void toggleTiling(); | 107 native void toggleTiling(); |
| 105 native void toggleBBox(); | 108 native void toggleBBox(); |
| 106 native void processSkEvent(); | 109 native void processSkEvent(); |
| 107 native void serviceQueueTimer(); | 110 native void serviceQueueTimer(); |
| 108 native void saveToPDF(); | 111 native void saveToPDF(); |
| 109 native void postInval(); | 112 native void postInval(); |
| 110 } | 113 } |
| OLD | NEW |