Romain Guy | b051e89 | 2010-09-28 19:09:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2010 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | package android.view; |
| 18 | |
Jeff Brown | 162a021 | 2011-07-21 17:02:54 -0700 | [diff] [blame] | 19 | import android.graphics.Bitmap; |
Chet Haase | 9420abd | 2012-03-29 16:28:32 -0700 | [diff] [blame] | 20 | import android.graphics.Matrix; |
Jeff Brown | 162a021 | 2011-07-21 17:02:54 -0700 | [diff] [blame] | 21 | |
| 22 | import java.util.ArrayList; |
Chet Haase | daf98e9 | 2011-01-10 14:10:36 -0800 | [diff] [blame] | 23 | |
Romain Guy | b051e89 | 2010-09-28 19:09:36 -0700 | [diff] [blame] | 24 | /** |
| 25 | * An implementation of display list for OpenGL ES 2.0. |
| 26 | */ |
| 27 | class GLES20DisplayList extends DisplayList { |
Chet Haase | ca479d4 | 2012-08-30 17:20:08 -0700 | [diff] [blame] | 28 | // These lists ensure that any Bitmaps and DisplayLists recorded by a DisplayList are kept |
| 29 | // alive as long as the DisplayList is alive. The Bitmap and DisplayList lists |
| 30 | // are populated by the GLES20RecordingCanvas during appropriate drawing calls and are |
| 31 | // cleared at the start of a new drawing frame or when the view is detached from the window. |
Jeff Brown | 162a021 | 2011-07-21 17:02:54 -0700 | [diff] [blame] | 32 | final ArrayList<Bitmap> mBitmaps = new ArrayList<Bitmap>(5); |
Chet Haase | ca479d4 | 2012-08-30 17:20:08 -0700 | [diff] [blame] | 33 | final ArrayList<DisplayList> mChildDisplayLists = new ArrayList<DisplayList>(); |
Romain Guy | b051e89 | 2010-09-28 19:09:36 -0700 | [diff] [blame] | 34 | |
Jeff Brown | 162a021 | 2011-07-21 17:02:54 -0700 | [diff] [blame] | 35 | private GLES20RecordingCanvas mCanvas; |
| 36 | private boolean mValid; |
Romain Guy | b051e89 | 2010-09-28 19:09:36 -0700 | [diff] [blame] | 37 | |
Romain Guy | 13631f3 | 2012-01-30 17:41:55 -0800 | [diff] [blame] | 38 | // Used for debugging |
| 39 | private final String mName; |
| 40 | |
Patrick Dubroy | f890fab | 2010-12-19 16:47:17 -0800 | [diff] [blame] | 41 | // The native display list will be destroyed when this object dies. |
| 42 | // DO NOT overwrite this reference once it is set. |
Patrick Dubroy | f890fab | 2010-12-19 16:47:17 -0800 | [diff] [blame] | 43 | private DisplayListFinalizer mFinalizer; |
| 44 | |
Romain Guy | 13631f3 | 2012-01-30 17:41:55 -0800 | [diff] [blame] | 45 | GLES20DisplayList(String name) { |
| 46 | mName = name; |
| 47 | } |
| 48 | |
Romain Guy | 0d6f4c0 | 2012-06-20 23:59:06 -0700 | [diff] [blame] | 49 | boolean hasNativeDisplayList() { |
| 50 | return mValid && mFinalizer != null; |
| 51 | } |
| 52 | |
Jeff Brown | 162a021 | 2011-07-21 17:02:54 -0700 | [diff] [blame] | 53 | int getNativeDisplayList() { |
| 54 | if (!mValid || mFinalizer == null) { |
| 55 | throw new IllegalStateException("The display list is not valid."); |
| 56 | } |
| 57 | return mFinalizer.mNativeDisplayList; |
Chet Haase | daf98e9 | 2011-01-10 14:10:36 -0800 | [diff] [blame] | 58 | } |
| 59 | |
Romain Guy | b051e89 | 2010-09-28 19:09:36 -0700 | [diff] [blame] | 60 | @Override |
Romain Guy | 52036b1 | 2013-02-14 18:03:37 -0800 | [diff] [blame] | 61 | public HardwareCanvas start(int width, int height) { |
Jeff Brown | 162a021 | 2011-07-21 17:02:54 -0700 | [diff] [blame] | 62 | if (mCanvas != null) { |
Romain Guy | b051e89 | 2010-09-28 19:09:36 -0700 | [diff] [blame] | 63 | throw new IllegalStateException("Recording has already started"); |
| 64 | } |
| 65 | |
Jeff Brown | 162a021 | 2011-07-21 17:02:54 -0700 | [diff] [blame] | 66 | mValid = false; |
| 67 | mCanvas = GLES20RecordingCanvas.obtain(this); |
| 68 | mCanvas.start(); |
Romain Guy | 52036b1 | 2013-02-14 18:03:37 -0800 | [diff] [blame] | 69 | |
| 70 | mCanvas.setViewport(width, height); |
| 71 | // The dirty rect should always be null for a display list |
| 72 | mCanvas.onPreDraw(null); |
| 73 | |
Romain Guy | b051e89 | 2010-09-28 19:09:36 -0700 | [diff] [blame] | 74 | return mCanvas; |
| 75 | } |
Romain Guy | b051e89 | 2010-09-28 19:09:36 -0700 | [diff] [blame] | 76 | @Override |
Romain Guy | 52036b1 | 2013-02-14 18:03:37 -0800 | [diff] [blame] | 77 | public void clear() { |
| 78 | clearDirty(); |
| 79 | |
Jeff Brown | 162a021 | 2011-07-21 17:02:54 -0700 | [diff] [blame] | 80 | if (mCanvas != null) { |
| 81 | mCanvas.recycle(); |
| 82 | mCanvas = null; |
| 83 | } |
Chet Haase | 9e90a99 | 2011-01-04 16:23:21 -0800 | [diff] [blame] | 84 | mValid = false; |
Chet Haase | 9e90a99 | 2011-01-04 16:23:21 -0800 | [diff] [blame] | 85 | |
Romain Guy | 52036b1 | 2013-02-14 18:03:37 -0800 | [diff] [blame] | 86 | mBitmaps.clear(); |
| 87 | mChildDisplayLists.clear(); |
Romain Guy | 38c2ece | 2012-05-24 14:20:56 -0700 | [diff] [blame] | 88 | } |
| 89 | |
| 90 | @Override |
Chet Haase | 6a2d17f | 2012-09-30 12:14:13 -0700 | [diff] [blame] | 91 | public void reset() { |
| 92 | if (hasNativeDisplayList()) { |
| 93 | nReset(mFinalizer.mNativeDisplayList); |
| 94 | } |
| 95 | } |
| 96 | |
| 97 | @Override |
Gilles Debunne | b35ab7b | 2011-12-05 15:54:00 -0800 | [diff] [blame] | 98 | public boolean isValid() { |
Chet Haase | 9e90a99 | 2011-01-04 16:23:21 -0800 | [diff] [blame] | 99 | return mValid; |
| 100 | } |
| 101 | |
| 102 | @Override |
Gilles Debunne | b35ab7b | 2011-12-05 15:54:00 -0800 | [diff] [blame] | 103 | public void end() { |
Romain Guy | b051e89 | 2010-09-28 19:09:36 -0700 | [diff] [blame] | 104 | if (mCanvas != null) { |
Romain Guy | 52036b1 | 2013-02-14 18:03:37 -0800 | [diff] [blame] | 105 | mCanvas.onPostDraw(); |
Jeff Brown | 162a021 | 2011-07-21 17:02:54 -0700 | [diff] [blame] | 106 | if (mFinalizer != null) { |
| 107 | mCanvas.end(mFinalizer.mNativeDisplayList); |
| 108 | } else { |
| 109 | mFinalizer = new DisplayListFinalizer(mCanvas.end(0)); |
Romain Guy | 52036b1 | 2013-02-14 18:03:37 -0800 | [diff] [blame] | 110 | nSetDisplayListName(mFinalizer.mNativeDisplayList, mName); |
Jeff Brown | 162a021 | 2011-07-21 17:02:54 -0700 | [diff] [blame] | 111 | } |
| 112 | mCanvas.recycle(); |
| 113 | mCanvas = null; |
| 114 | mValid = true; |
Romain Guy | b051e89 | 2010-09-28 19:09:36 -0700 | [diff] [blame] | 115 | } |
| 116 | } |
| 117 | |
Romain Guy | 65b345f | 2011-07-27 18:51:50 -0700 | [diff] [blame] | 118 | @Override |
Gilles Debunne | b35ab7b | 2011-12-05 15:54:00 -0800 | [diff] [blame] | 119 | public int getSize() { |
Romain Guy | 65b345f | 2011-07-27 18:51:50 -0700 | [diff] [blame] | 120 | if (mFinalizer == null) return 0; |
Romain Guy | 52036b1 | 2013-02-14 18:03:37 -0800 | [diff] [blame] | 121 | return nGetDisplayListSize(mFinalizer.mNativeDisplayList); |
Romain Guy | 65b345f | 2011-07-27 18:51:50 -0700 | [diff] [blame] | 122 | } |
| 123 | |
Romain Guy | 52036b1 | 2013-02-14 18:03:37 -0800 | [diff] [blame] | 124 | private static native void nDestroyDisplayList(int displayList); |
| 125 | private static native int nGetDisplayListSize(int displayList); |
| 126 | private static native void nSetDisplayListName(int displayList, String name); |
| 127 | |
Chet Haase | a1cff50 | 2012-02-21 13:43:44 -0800 | [diff] [blame] | 128 | /////////////////////////////////////////////////////////////////////////// |
| 129 | // Native View Properties |
| 130 | /////////////////////////////////////////////////////////////////////////// |
| 131 | |
| 132 | @Override |
| 133 | public void setCaching(boolean caching) { |
Romain Guy | 0d6f4c0 | 2012-06-20 23:59:06 -0700 | [diff] [blame] | 134 | if (hasNativeDisplayList()) { |
| 135 | nSetCaching(mFinalizer.mNativeDisplayList, caching); |
Chet Haase | a1cff50 | 2012-02-21 13:43:44 -0800 | [diff] [blame] | 136 | } |
| 137 | } |
| 138 | |
| 139 | @Override |
Chet Haase | dd67159 | 2013-04-19 14:54:34 -0700 | [diff] [blame] | 140 | public void setClipToBounds(boolean clipToBounds) { |
Romain Guy | 0d6f4c0 | 2012-06-20 23:59:06 -0700 | [diff] [blame] | 141 | if (hasNativeDisplayList()) { |
Chet Haase | dd67159 | 2013-04-19 14:54:34 -0700 | [diff] [blame] | 142 | nSetClipToBounds(mFinalizer.mNativeDisplayList, clipToBounds); |
Chet Haase | a1cff50 | 2012-02-21 13:43:44 -0800 | [diff] [blame] | 143 | } |
| 144 | } |
| 145 | |
| 146 | @Override |
Romain Guy | 52036b1 | 2013-02-14 18:03:37 -0800 | [diff] [blame] | 147 | public void setMatrix(Matrix matrix) { |
Romain Guy | 0d6f4c0 | 2012-06-20 23:59:06 -0700 | [diff] [blame] | 148 | if (hasNativeDisplayList()) { |
| 149 | nSetStaticMatrix(mFinalizer.mNativeDisplayList, matrix.native_instance); |
Chet Haase | 9420abd | 2012-03-29 16:28:32 -0700 | [diff] [blame] | 150 | } |
| 151 | } |
| 152 | |
| 153 | @Override |
Romain Guy | 52036b1 | 2013-02-14 18:03:37 -0800 | [diff] [blame] | 154 | public Matrix getMatrix(Matrix matrix) { |
| 155 | if (hasNativeDisplayList()) { |
| 156 | nGetMatrix(mFinalizer.mNativeDisplayList, matrix.native_instance); |
| 157 | } |
| 158 | return matrix; |
| 159 | } |
| 160 | |
| 161 | @Override |
Chet Haase | 9420abd | 2012-03-29 16:28:32 -0700 | [diff] [blame] | 162 | public void setAnimationMatrix(Matrix matrix) { |
Romain Guy | 0d6f4c0 | 2012-06-20 23:59:06 -0700 | [diff] [blame] | 163 | if (hasNativeDisplayList()) { |
| 164 | nSetAnimationMatrix(mFinalizer.mNativeDisplayList, |
Chet Haase | afd5c3e | 2012-05-10 13:21:10 -0700 | [diff] [blame] | 165 | (matrix != null) ? matrix.native_instance : 0); |
Chet Haase | a1cff50 | 2012-02-21 13:43:44 -0800 | [diff] [blame] | 166 | } |
| 167 | } |
| 168 | |
| 169 | @Override |
| 170 | public void setAlpha(float alpha) { |
Romain Guy | 0d6f4c0 | 2012-06-20 23:59:06 -0700 | [diff] [blame] | 171 | if (hasNativeDisplayList()) { |
| 172 | nSetAlpha(mFinalizer.mNativeDisplayList, alpha); |
Chet Haase | a1cff50 | 2012-02-21 13:43:44 -0800 | [diff] [blame] | 173 | } |
| 174 | } |
| 175 | |
| 176 | @Override |
Romain Guy | 52036b1 | 2013-02-14 18:03:37 -0800 | [diff] [blame] | 177 | public float getAlpha() { |
| 178 | if (hasNativeDisplayList()) { |
| 179 | return nGetAlpha(mFinalizer.mNativeDisplayList); |
| 180 | } |
| 181 | return 1.0f; |
| 182 | } |
| 183 | |
| 184 | @Override |
Chet Haase | db8c9a6 | 2012-03-21 18:54:18 -0700 | [diff] [blame] | 185 | public void setHasOverlappingRendering(boolean hasOverlappingRendering) { |
Romain Guy | 0d6f4c0 | 2012-06-20 23:59:06 -0700 | [diff] [blame] | 186 | if (hasNativeDisplayList()) { |
| 187 | nSetHasOverlappingRendering(mFinalizer.mNativeDisplayList, hasOverlappingRendering); |
Chet Haase | db8c9a6 | 2012-03-21 18:54:18 -0700 | [diff] [blame] | 188 | } |
| 189 | } |
| 190 | |
| 191 | @Override |
Romain Guy | 52036b1 | 2013-02-14 18:03:37 -0800 | [diff] [blame] | 192 | public boolean hasOverlappingRendering() { |
| 193 | //noinspection SimplifiableIfStatement |
| 194 | if (hasNativeDisplayList()) { |
| 195 | return nHasOverlappingRendering(mFinalizer.mNativeDisplayList); |
| 196 | } |
| 197 | return true; |
| 198 | } |
| 199 | |
| 200 | @Override |
Chet Haase | a1cff50 | 2012-02-21 13:43:44 -0800 | [diff] [blame] | 201 | public void setTranslationX(float translationX) { |
Romain Guy | 0d6f4c0 | 2012-06-20 23:59:06 -0700 | [diff] [blame] | 202 | if (hasNativeDisplayList()) { |
| 203 | nSetTranslationX(mFinalizer.mNativeDisplayList, translationX); |
Chet Haase | a1cff50 | 2012-02-21 13:43:44 -0800 | [diff] [blame] | 204 | } |
| 205 | } |
| 206 | |
| 207 | @Override |
Romain Guy | 52036b1 | 2013-02-14 18:03:37 -0800 | [diff] [blame] | 208 | public float getTranslationX() { |
| 209 | if (hasNativeDisplayList()) { |
| 210 | return nGetTranslationX(mFinalizer.mNativeDisplayList); |
| 211 | } |
| 212 | return 0.0f; |
| 213 | } |
| 214 | |
| 215 | @Override |
Chet Haase | a1cff50 | 2012-02-21 13:43:44 -0800 | [diff] [blame] | 216 | public void setTranslationY(float translationY) { |
Romain Guy | 0d6f4c0 | 2012-06-20 23:59:06 -0700 | [diff] [blame] | 217 | if (hasNativeDisplayList()) { |
| 218 | nSetTranslationY(mFinalizer.mNativeDisplayList, translationY); |
Chet Haase | a1cff50 | 2012-02-21 13:43:44 -0800 | [diff] [blame] | 219 | } |
| 220 | } |
| 221 | |
| 222 | @Override |
Romain Guy | 52036b1 | 2013-02-14 18:03:37 -0800 | [diff] [blame] | 223 | public float getTranslationY() { |
| 224 | if (hasNativeDisplayList()) { |
| 225 | return nGetTranslationY(mFinalizer.mNativeDisplayList); |
| 226 | } |
| 227 | return 0.0f; |
| 228 | } |
| 229 | |
| 230 | @Override |
Chet Haase | a1cff50 | 2012-02-21 13:43:44 -0800 | [diff] [blame] | 231 | public void setRotation(float rotation) { |
Romain Guy | 0d6f4c0 | 2012-06-20 23:59:06 -0700 | [diff] [blame] | 232 | if (hasNativeDisplayList()) { |
| 233 | nSetRotation(mFinalizer.mNativeDisplayList, rotation); |
Chet Haase | a1cff50 | 2012-02-21 13:43:44 -0800 | [diff] [blame] | 234 | } |
| 235 | } |
| 236 | |
| 237 | @Override |
Romain Guy | 52036b1 | 2013-02-14 18:03:37 -0800 | [diff] [blame] | 238 | public float getRotation() { |
| 239 | if (hasNativeDisplayList()) { |
| 240 | return nGetRotation(mFinalizer.mNativeDisplayList); |
| 241 | } |
| 242 | return 0.0f; |
| 243 | } |
| 244 | |
| 245 | @Override |
Chet Haase | a1cff50 | 2012-02-21 13:43:44 -0800 | [diff] [blame] | 246 | public void setRotationX(float rotationX) { |
Romain Guy | 0d6f4c0 | 2012-06-20 23:59:06 -0700 | [diff] [blame] | 247 | if (hasNativeDisplayList()) { |
| 248 | nSetRotationX(mFinalizer.mNativeDisplayList, rotationX); |
Chet Haase | a1cff50 | 2012-02-21 13:43:44 -0800 | [diff] [blame] | 249 | } |
| 250 | } |
| 251 | |
| 252 | @Override |
Romain Guy | 52036b1 | 2013-02-14 18:03:37 -0800 | [diff] [blame] | 253 | public float getRotationX() { |
| 254 | if (hasNativeDisplayList()) { |
| 255 | return nGetRotationX(mFinalizer.mNativeDisplayList); |
| 256 | } |
| 257 | return 0.0f; |
| 258 | } |
| 259 | |
| 260 | @Override |
Chet Haase | a1cff50 | 2012-02-21 13:43:44 -0800 | [diff] [blame] | 261 | public void setRotationY(float rotationY) { |
Romain Guy | 0d6f4c0 | 2012-06-20 23:59:06 -0700 | [diff] [blame] | 262 | if (hasNativeDisplayList()) { |
| 263 | nSetRotationY(mFinalizer.mNativeDisplayList, rotationY); |
Chet Haase | a1cff50 | 2012-02-21 13:43:44 -0800 | [diff] [blame] | 264 | } |
| 265 | } |
| 266 | |
| 267 | @Override |
Romain Guy | 52036b1 | 2013-02-14 18:03:37 -0800 | [diff] [blame] | 268 | public float getRotationY() { |
| 269 | if (hasNativeDisplayList()) { |
| 270 | return nGetRotationY(mFinalizer.mNativeDisplayList); |
| 271 | } |
| 272 | return 0.0f; |
| 273 | } |
| 274 | |
| 275 | @Override |
Chet Haase | a1cff50 | 2012-02-21 13:43:44 -0800 | [diff] [blame] | 276 | public void setScaleX(float scaleX) { |
Romain Guy | 0d6f4c0 | 2012-06-20 23:59:06 -0700 | [diff] [blame] | 277 | if (hasNativeDisplayList()) { |
| 278 | nSetScaleX(mFinalizer.mNativeDisplayList, scaleX); |
Chet Haase | a1cff50 | 2012-02-21 13:43:44 -0800 | [diff] [blame] | 279 | } |
| 280 | } |
| 281 | |
| 282 | @Override |
Romain Guy | 52036b1 | 2013-02-14 18:03:37 -0800 | [diff] [blame] | 283 | public float getScaleX() { |
| 284 | if (hasNativeDisplayList()) { |
| 285 | return nGetScaleX(mFinalizer.mNativeDisplayList); |
| 286 | } |
| 287 | return 1.0f; |
| 288 | } |
| 289 | |
| 290 | @Override |
Chet Haase | a1cff50 | 2012-02-21 13:43:44 -0800 | [diff] [blame] | 291 | public void setScaleY(float scaleY) { |
Romain Guy | 0d6f4c0 | 2012-06-20 23:59:06 -0700 | [diff] [blame] | 292 | if (hasNativeDisplayList()) { |
| 293 | nSetScaleY(mFinalizer.mNativeDisplayList, scaleY); |
Chet Haase | a1cff50 | 2012-02-21 13:43:44 -0800 | [diff] [blame] | 294 | } |
| 295 | } |
| 296 | |
| 297 | @Override |
Romain Guy | 52036b1 | 2013-02-14 18:03:37 -0800 | [diff] [blame] | 298 | public float getScaleY() { |
| 299 | if (hasNativeDisplayList()) { |
| 300 | return nGetScaleY(mFinalizer.mNativeDisplayList); |
| 301 | } |
| 302 | return 1.0f; |
| 303 | } |
| 304 | |
| 305 | @Override |
Chet Haase | a1cff50 | 2012-02-21 13:43:44 -0800 | [diff] [blame] | 306 | public void setTransformationInfo(float alpha, float translationX, float translationY, |
| 307 | float rotation, float rotationX, float rotationY, float scaleX, float scaleY) { |
Romain Guy | 0d6f4c0 | 2012-06-20 23:59:06 -0700 | [diff] [blame] | 308 | if (hasNativeDisplayList()) { |
| 309 | nSetTransformationInfo(mFinalizer.mNativeDisplayList, alpha, translationX, translationY, |
Chet Haase | a1cff50 | 2012-02-21 13:43:44 -0800 | [diff] [blame] | 310 | rotation, rotationX, rotationY, scaleX, scaleY); |
Chet Haase | a1cff50 | 2012-02-21 13:43:44 -0800 | [diff] [blame] | 311 | } |
| 312 | } |
| 313 | |
| 314 | @Override |
| 315 | public void setPivotX(float pivotX) { |
Romain Guy | 0d6f4c0 | 2012-06-20 23:59:06 -0700 | [diff] [blame] | 316 | if (hasNativeDisplayList()) { |
| 317 | nSetPivotX(mFinalizer.mNativeDisplayList, pivotX); |
Chet Haase | a1cff50 | 2012-02-21 13:43:44 -0800 | [diff] [blame] | 318 | } |
| 319 | } |
| 320 | |
| 321 | @Override |
Romain Guy | 52036b1 | 2013-02-14 18:03:37 -0800 | [diff] [blame] | 322 | public float getPivotX() { |
| 323 | if (hasNativeDisplayList()) { |
| 324 | return nGetPivotX(mFinalizer.mNativeDisplayList); |
| 325 | } |
| 326 | return 0.0f; |
| 327 | } |
| 328 | |
| 329 | @Override |
Chet Haase | a1cff50 | 2012-02-21 13:43:44 -0800 | [diff] [blame] | 330 | public void setPivotY(float pivotY) { |
Romain Guy | 0d6f4c0 | 2012-06-20 23:59:06 -0700 | [diff] [blame] | 331 | if (hasNativeDisplayList()) { |
| 332 | nSetPivotY(mFinalizer.mNativeDisplayList, pivotY); |
Chet Haase | a1cff50 | 2012-02-21 13:43:44 -0800 | [diff] [blame] | 333 | } |
| 334 | } |
| 335 | |
| 336 | @Override |
Romain Guy | 52036b1 | 2013-02-14 18:03:37 -0800 | [diff] [blame] | 337 | public float getPivotY() { |
| 338 | if (hasNativeDisplayList()) { |
| 339 | return nGetPivotY(mFinalizer.mNativeDisplayList); |
| 340 | } |
| 341 | return 0.0f; |
| 342 | } |
| 343 | |
| 344 | @Override |
Chet Haase | a1cff50 | 2012-02-21 13:43:44 -0800 | [diff] [blame] | 345 | public void setCameraDistance(float distance) { |
Romain Guy | 0d6f4c0 | 2012-06-20 23:59:06 -0700 | [diff] [blame] | 346 | if (hasNativeDisplayList()) { |
| 347 | nSetCameraDistance(mFinalizer.mNativeDisplayList, distance); |
Chet Haase | a1cff50 | 2012-02-21 13:43:44 -0800 | [diff] [blame] | 348 | } |
| 349 | } |
| 350 | |
| 351 | @Override |
Romain Guy | 52036b1 | 2013-02-14 18:03:37 -0800 | [diff] [blame] | 352 | public float getCameraDistance() { |
| 353 | if (hasNativeDisplayList()) { |
| 354 | return nGetCameraDistance(mFinalizer.mNativeDisplayList); |
| 355 | } |
| 356 | return 0.0f; |
| 357 | } |
| 358 | |
| 359 | @Override |
Chet Haase | a1cff50 | 2012-02-21 13:43:44 -0800 | [diff] [blame] | 360 | public void setLeft(int left) { |
Romain Guy | 0d6f4c0 | 2012-06-20 23:59:06 -0700 | [diff] [blame] | 361 | if (hasNativeDisplayList()) { |
| 362 | nSetLeft(mFinalizer.mNativeDisplayList, left); |
Chet Haase | a1cff50 | 2012-02-21 13:43:44 -0800 | [diff] [blame] | 363 | } |
| 364 | } |
| 365 | |
| 366 | @Override |
Romain Guy | 52036b1 | 2013-02-14 18:03:37 -0800 | [diff] [blame] | 367 | public float getLeft() { |
| 368 | if (hasNativeDisplayList()) { |
| 369 | return nGetLeft(mFinalizer.mNativeDisplayList); |
| 370 | } |
| 371 | return 0.0f; |
| 372 | } |
| 373 | |
| 374 | @Override |
Chet Haase | a1cff50 | 2012-02-21 13:43:44 -0800 | [diff] [blame] | 375 | public void setTop(int top) { |
Romain Guy | 0d6f4c0 | 2012-06-20 23:59:06 -0700 | [diff] [blame] | 376 | if (hasNativeDisplayList()) { |
| 377 | nSetTop(mFinalizer.mNativeDisplayList, top); |
Chet Haase | a1cff50 | 2012-02-21 13:43:44 -0800 | [diff] [blame] | 378 | } |
| 379 | } |
| 380 | |
| 381 | @Override |
Romain Guy | 52036b1 | 2013-02-14 18:03:37 -0800 | [diff] [blame] | 382 | public float getTop() { |
| 383 | if (hasNativeDisplayList()) { |
| 384 | return nGetTop(mFinalizer.mNativeDisplayList); |
| 385 | } |
| 386 | return 0.0f; |
| 387 | } |
| 388 | |
| 389 | @Override |
Chet Haase | a1cff50 | 2012-02-21 13:43:44 -0800 | [diff] [blame] | 390 | public void setRight(int right) { |
Romain Guy | 0d6f4c0 | 2012-06-20 23:59:06 -0700 | [diff] [blame] | 391 | if (hasNativeDisplayList()) { |
| 392 | nSetRight(mFinalizer.mNativeDisplayList, right); |
Chet Haase | a1cff50 | 2012-02-21 13:43:44 -0800 | [diff] [blame] | 393 | } |
| 394 | } |
| 395 | |
| 396 | @Override |
Romain Guy | 52036b1 | 2013-02-14 18:03:37 -0800 | [diff] [blame] | 397 | public float getRight() { |
| 398 | if (hasNativeDisplayList()) { |
| 399 | return nGetRight(mFinalizer.mNativeDisplayList); |
| 400 | } |
| 401 | return 0.0f; |
| 402 | } |
| 403 | |
| 404 | @Override |
Chet Haase | a1cff50 | 2012-02-21 13:43:44 -0800 | [diff] [blame] | 405 | public void setBottom(int bottom) { |
Romain Guy | 0d6f4c0 | 2012-06-20 23:59:06 -0700 | [diff] [blame] | 406 | if (hasNativeDisplayList()) { |
| 407 | nSetBottom(mFinalizer.mNativeDisplayList, bottom); |
Chet Haase | a1cff50 | 2012-02-21 13:43:44 -0800 | [diff] [blame] | 408 | } |
| 409 | } |
| 410 | |
| 411 | @Override |
Romain Guy | 52036b1 | 2013-02-14 18:03:37 -0800 | [diff] [blame] | 412 | public float getBottom() { |
Romain Guy | 0d6f4c0 | 2012-06-20 23:59:06 -0700 | [diff] [blame] | 413 | if (hasNativeDisplayList()) { |
Romain Guy | 52036b1 | 2013-02-14 18:03:37 -0800 | [diff] [blame] | 414 | return nGetBottom(mFinalizer.mNativeDisplayList); |
Chet Haase | a1cff50 | 2012-02-21 13:43:44 -0800 | [diff] [blame] | 415 | } |
Romain Guy | 52036b1 | 2013-02-14 18:03:37 -0800 | [diff] [blame] | 416 | return 0.0f; |
Chet Haase | a1cff50 | 2012-02-21 13:43:44 -0800 | [diff] [blame] | 417 | } |
| 418 | |
| 419 | @Override |
| 420 | public void setLeftTopRightBottom(int left, int top, int right, int bottom) { |
Romain Guy | 0d6f4c0 | 2012-06-20 23:59:06 -0700 | [diff] [blame] | 421 | if (hasNativeDisplayList()) { |
| 422 | nSetLeftTopRightBottom(mFinalizer.mNativeDisplayList, left, top, right, bottom); |
Chet Haase | a1cff50 | 2012-02-21 13:43:44 -0800 | [diff] [blame] | 423 | } |
| 424 | } |
| 425 | |
| 426 | @Override |
Romain Guy | 52036b1 | 2013-02-14 18:03:37 -0800 | [diff] [blame] | 427 | public void offsetLeftAndRight(float offset) { |
Romain Guy | 0d6f4c0 | 2012-06-20 23:59:06 -0700 | [diff] [blame] | 428 | if (hasNativeDisplayList()) { |
Romain Guy | 52036b1 | 2013-02-14 18:03:37 -0800 | [diff] [blame] | 429 | nOffsetLeftAndRight(mFinalizer.mNativeDisplayList, offset); |
Chet Haase | a1cff50 | 2012-02-21 13:43:44 -0800 | [diff] [blame] | 430 | } |
| 431 | } |
| 432 | |
| 433 | @Override |
Romain Guy | 52036b1 | 2013-02-14 18:03:37 -0800 | [diff] [blame] | 434 | public void offsetTopAndBottom(float offset) { |
Romain Guy | 0d6f4c0 | 2012-06-20 23:59:06 -0700 | [diff] [blame] | 435 | if (hasNativeDisplayList()) { |
Romain Guy | 52036b1 | 2013-02-14 18:03:37 -0800 | [diff] [blame] | 436 | nOffsetTopAndBottom(mFinalizer.mNativeDisplayList, offset); |
Chet Haase | a1cff50 | 2012-02-21 13:43:44 -0800 | [diff] [blame] | 437 | } |
| 438 | } |
| 439 | |
Chet Haase | 6a2d17f | 2012-09-30 12:14:13 -0700 | [diff] [blame] | 440 | private static native void nReset(int displayList); |
Romain Guy | 52036b1 | 2013-02-14 18:03:37 -0800 | [diff] [blame] | 441 | private static native void nOffsetTopAndBottom(int displayList, float offset); |
| 442 | private static native void nOffsetLeftAndRight(int displayList, float offset); |
Chet Haase | a1cff50 | 2012-02-21 13:43:44 -0800 | [diff] [blame] | 443 | private static native void nSetLeftTopRightBottom(int displayList, int left, int top, |
| 444 | int right, int bottom); |
Chet Haase | a1cff50 | 2012-02-21 13:43:44 -0800 | [diff] [blame] | 445 | private static native void nSetBottom(int displayList, int bottom); |
| 446 | private static native void nSetRight(int displayList, int right); |
| 447 | private static native void nSetTop(int displayList, int top); |
| 448 | private static native void nSetLeft(int displayList, int left); |
| 449 | private static native void nSetCameraDistance(int displayList, float distance); |
| 450 | private static native void nSetPivotY(int displayList, float pivotY); |
| 451 | private static native void nSetPivotX(int displayList, float pivotX); |
| 452 | private static native void nSetCaching(int displayList, boolean caching); |
Chet Haase | dd67159 | 2013-04-19 14:54:34 -0700 | [diff] [blame] | 453 | private static native void nSetClipToBounds(int displayList, boolean clipToBounds); |
Chet Haase | a1cff50 | 2012-02-21 13:43:44 -0800 | [diff] [blame] | 454 | private static native void nSetAlpha(int displayList, float alpha); |
Chet Haase | db8c9a6 | 2012-03-21 18:54:18 -0700 | [diff] [blame] | 455 | private static native void nSetHasOverlappingRendering(int displayList, |
| 456 | boolean hasOverlappingRendering); |
Chet Haase | a1cff50 | 2012-02-21 13:43:44 -0800 | [diff] [blame] | 457 | private static native void nSetTranslationX(int displayList, float translationX); |
| 458 | private static native void nSetTranslationY(int displayList, float translationY); |
| 459 | private static native void nSetRotation(int displayList, float rotation); |
| 460 | private static native void nSetRotationX(int displayList, float rotationX); |
| 461 | private static native void nSetRotationY(int displayList, float rotationY); |
| 462 | private static native void nSetScaleX(int displayList, float scaleX); |
| 463 | private static native void nSetScaleY(int displayList, float scaleY); |
| 464 | private static native void nSetTransformationInfo(int displayList, float alpha, |
| 465 | float translationX, float translationY, float rotation, float rotationX, |
| 466 | float rotationY, float scaleX, float scaleY); |
Chet Haase | 9420abd | 2012-03-29 16:28:32 -0700 | [diff] [blame] | 467 | private static native void nSetStaticMatrix(int displayList, int nativeMatrix); |
| 468 | private static native void nSetAnimationMatrix(int displayList, int animationMatrix); |
Chet Haase | a1cff50 | 2012-02-21 13:43:44 -0800 | [diff] [blame] | 469 | |
Romain Guy | 52036b1 | 2013-02-14 18:03:37 -0800 | [diff] [blame] | 470 | private static native boolean nHasOverlappingRendering(int displayList); |
| 471 | private static native void nGetMatrix(int displayList, int matrix); |
| 472 | private static native float nGetAlpha(int displayList); |
| 473 | private static native float nGetLeft(int displayList); |
| 474 | private static native float nGetTop(int displayList); |
| 475 | private static native float nGetRight(int displayList); |
| 476 | private static native float nGetBottom(int displayList); |
| 477 | private static native float nGetCameraDistance(int displayList); |
| 478 | private static native float nGetScaleX(int displayList); |
| 479 | private static native float nGetScaleY(int displayList); |
| 480 | private static native float nGetTranslationX(int displayList); |
| 481 | private static native float nGetTranslationY(int displayList); |
| 482 | private static native float nGetRotation(int displayList); |
| 483 | private static native float nGetRotationX(int displayList); |
| 484 | private static native float nGetRotationY(int displayList); |
| 485 | private static native float nGetPivotX(int displayList); |
| 486 | private static native float nGetPivotY(int displayList); |
Chet Haase | a1cff50 | 2012-02-21 13:43:44 -0800 | [diff] [blame] | 487 | |
| 488 | /////////////////////////////////////////////////////////////////////////// |
| 489 | // Finalization |
| 490 | /////////////////////////////////////////////////////////////////////////// |
| 491 | |
Patrick Dubroy | f890fab | 2010-12-19 16:47:17 -0800 | [diff] [blame] | 492 | private static class DisplayListFinalizer { |
Jeff Brown | 162a021 | 2011-07-21 17:02:54 -0700 | [diff] [blame] | 493 | final int mNativeDisplayList; |
Chet Haase | 5c13d89 | 2010-10-08 08:37:55 -0700 | [diff] [blame] | 494 | |
Jeff Brown | 162a021 | 2011-07-21 17:02:54 -0700 | [diff] [blame] | 495 | public DisplayListFinalizer(int nativeDisplayList) { |
Patrick Dubroy | f890fab | 2010-12-19 16:47:17 -0800 | [diff] [blame] | 496 | mNativeDisplayList = nativeDisplayList; |
Chet Haase | 5c13d89 | 2010-10-08 08:37:55 -0700 | [diff] [blame] | 497 | } |
| 498 | |
| 499 | @Override |
Patrick Dubroy | f890fab | 2010-12-19 16:47:17 -0800 | [diff] [blame] | 500 | protected void finalize() throws Throwable { |
Romain Guy | 6c319ca | 2011-01-11 14:29:25 -0800 | [diff] [blame] | 501 | try { |
Romain Guy | 52036b1 | 2013-02-14 18:03:37 -0800 | [diff] [blame] | 502 | nDestroyDisplayList(mNativeDisplayList); |
Romain Guy | 6c319ca | 2011-01-11 14:29:25 -0800 | [diff] [blame] | 503 | } finally { |
| 504 | super.finalize(); |
| 505 | } |
Chet Haase | 5c13d89 | 2010-10-08 08:37:55 -0700 | [diff] [blame] | 506 | } |
| 507 | } |
Romain Guy | b051e89 | 2010-09-28 19:09:36 -0700 | [diff] [blame] | 508 | } |