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 | |
Chet Haase | 9420abd | 2012-03-29 16:28:32 -0700 | [diff] [blame] | 19 | import android.graphics.Matrix; |
Chris Craik | a2fe7af | 2014-01-28 17:25:06 -0800 | [diff] [blame] | 20 | import android.graphics.Path; |
Chet Haase | 9420abd | 2012-03-29 16:28:32 -0700 | [diff] [blame] | 21 | |
Chris Craik | 5438979 | 2013-12-20 13:28:11 -0800 | [diff] [blame] | 22 | import java.util.ArrayList; |
| 23 | |
Romain Guy | b051e89 | 2010-09-28 19:09:36 -0700 | [diff] [blame] | 24 | /** |
Romain Guy | 52036b1 | 2013-02-14 18:03:37 -0800 | [diff] [blame] | 25 | * <p>A display list records a series of graphics related operations and can replay |
Romain Guy | b051e89 | 2010-09-28 19:09:36 -0700 | [diff] [blame] | 26 | * them later. Display lists are usually built by recording operations on a |
Romain Guy | 52036b1 | 2013-02-14 18:03:37 -0800 | [diff] [blame] | 27 | * {@link HardwareCanvas}. Replaying the operations from a display list avoids |
| 28 | * executing application code on every frame, and is thus much more efficient.</p> |
Chet Haase | daf98e9 | 2011-01-10 14:10:36 -0800 | [diff] [blame] | 29 | * |
Romain Guy | 52036b1 | 2013-02-14 18:03:37 -0800 | [diff] [blame] | 30 | * <p>Display lists are used internally for all views by default, and are not |
| 31 | * typically used directly. One reason to consider using a display is a custom |
| 32 | * {@link View} implementation that needs to issue a large number of drawing commands. |
| 33 | * When the view invalidates, all the drawing commands must be reissued, even if |
| 34 | * large portions of the drawing command stream stay the same frame to frame, which |
| 35 | * can become a performance bottleneck. To solve this issue, a custom View might split |
| 36 | * its content into several display lists. A display list is updated only when its |
| 37 | * content, and only its content, needs to be updated.</p> |
| 38 | * |
| 39 | * <p>A text editor might for instance store each paragraph into its own display list. |
| 40 | * Thus when the user inserts or removes characters, only the display list of the |
| 41 | * affected paragraph needs to be recorded again.</p> |
| 42 | * |
| 43 | * <h3>Hardware acceleration</h3> |
| 44 | * <p>Display lists can only be replayed using a {@link HardwareCanvas}. They are not |
| 45 | * supported in software. Always make sure that the {@link android.graphics.Canvas} |
| 46 | * you are using to render a display list is hardware accelerated using |
| 47 | * {@link android.graphics.Canvas#isHardwareAccelerated()}.</p> |
| 48 | * |
| 49 | * <h3>Creating a display list</h3> |
| 50 | * <pre class="prettyprint"> |
| 51 | * HardwareRenderer renderer = myView.getHardwareRenderer(); |
| 52 | * if (renderer != null) { |
| 53 | * DisplayList displayList = renderer.createDisplayList(); |
| 54 | * HardwareCanvas canvas = displayList.start(width, height); |
| 55 | * try { |
| 56 | * // Draw onto the canvas |
| 57 | * // For instance: canvas.drawBitmap(...); |
| 58 | * } finally { |
| 59 | * displayList.end(); |
| 60 | * } |
| 61 | * } |
| 62 | * </pre> |
| 63 | * |
| 64 | * <h3>Rendering a display list on a View</h3> |
| 65 | * <pre class="prettyprint"> |
Romain Guy | 52036b1 | 2013-02-14 18:03:37 -0800 | [diff] [blame] | 66 | * protected void onDraw(Canvas canvas) { |
| 67 | * if (canvas.isHardwareAccelerated()) { |
| 68 | * HardwareCanvas hardwareCanvas = (HardwareCanvas) canvas; |
| 69 | * hardwareCanvas.drawDisplayList(mDisplayList); |
| 70 | * } |
| 71 | * } |
| 72 | * </pre> |
| 73 | * |
| 74 | * <h3>Releasing resources</h3> |
| 75 | * <p>This step is not mandatory but recommended if you want to release resources |
| 76 | * held by a display list as soon as possible.</p> |
| 77 | * <pre class="prettyprint"> |
| 78 | * // Mark this display list invalid, it cannot be used for drawing anymore, |
| 79 | * // and release resources held by this display list |
| 80 | * displayList.clear(); |
| 81 | * </pre> |
| 82 | * |
| 83 | * <h3>Properties</h3> |
| 84 | * <p>In addition, a display list offers several properties, such as |
| 85 | * {@link #setScaleX(float)} or {@link #setLeft(int)}, that can be used to affect all |
| 86 | * the drawing commands recorded within. For instance, these properties can be used |
| 87 | * to move around a large number of images without re-issuing all the individual |
| 88 | * <code>drawBitmap()</code> calls.</p> |
| 89 | * |
| 90 | * <pre class="prettyprint"> |
| 91 | * private void createDisplayList() { |
John Reck | 3083579 | 2013-11-07 14:21:24 -0800 | [diff] [blame] | 92 | * mDisplayList = DisplayList.create("MyDisplayList"); |
| 93 | * HardwareCanvas canvas = mDisplayList.start(width, height); |
| 94 | * try { |
| 95 | * for (Bitmap b : mBitmaps) { |
| 96 | * canvas.drawBitmap(b, 0.0f, 0.0f, null); |
| 97 | * canvas.translate(0.0f, b.getHeight()); |
Romain Guy | 52036b1 | 2013-02-14 18:03:37 -0800 | [diff] [blame] | 98 | * } |
John Reck | 3083579 | 2013-11-07 14:21:24 -0800 | [diff] [blame] | 99 | * } finally { |
| 100 | * displayList.end(); |
Romain Guy | 52036b1 | 2013-02-14 18:03:37 -0800 | [diff] [blame] | 101 | * } |
| 102 | * } |
| 103 | * |
Romain Guy | 52036b1 | 2013-02-14 18:03:37 -0800 | [diff] [blame] | 104 | * protected void onDraw(Canvas canvas) { |
| 105 | * if (canvas.isHardwareAccelerated()) { |
| 106 | * HardwareCanvas hardwareCanvas = (HardwareCanvas) canvas; |
| 107 | * hardwareCanvas.drawDisplayList(mDisplayList); |
| 108 | * } |
| 109 | * } |
| 110 | * |
| 111 | * private void moveContentBy(int x) { |
| 112 | * // This will move all the bitmaps recorded inside the display list |
| 113 | * // by x pixels to the right and redraw this view. All the commands |
| 114 | * // recorded in createDisplayList() won't be re-issued, only onDraw() |
| 115 | * // will be invoked and will execute very quickly |
| 116 | * mDisplayList.offsetLeftAndRight(x); |
| 117 | * invalidate(); |
| 118 | * } |
| 119 | * </pre> |
| 120 | * |
| 121 | * <h3>Threading</h3> |
| 122 | * <p>Display lists must be created on and manipulated from the UI thread only.</p> |
| 123 | * |
| 124 | * @hide |
Romain Guy | b051e89 | 2010-09-28 19:09:36 -0700 | [diff] [blame] | 125 | */ |
Chris Craik | 5438979 | 2013-12-20 13:28:11 -0800 | [diff] [blame] | 126 | public class DisplayList { |
Romain Guy | fbb93fa | 2012-12-03 18:50:35 -0800 | [diff] [blame] | 127 | private boolean mDirty; |
Chris Craik | 5438979 | 2013-12-20 13:28:11 -0800 | [diff] [blame] | 128 | private ArrayList<DisplayList> mChildDisplayLists; |
| 129 | |
| 130 | private GLES20RecordingCanvas mCanvas; |
| 131 | private boolean mValid; |
| 132 | |
| 133 | // Used for debugging |
| 134 | private final String mName; |
| 135 | |
| 136 | // The native display list will be destroyed when this object dies. |
| 137 | // DO NOT overwrite this reference once it is set. |
| 138 | private DisplayListFinalizer mFinalizer; |
Romain Guy | fbb93fa | 2012-12-03 18:50:35 -0800 | [diff] [blame] | 139 | |
Romain Guy | b051e89 | 2010-09-28 19:09:36 -0700 | [diff] [blame] | 140 | /** |
Romain Guy | 33f6beb | 2012-02-16 19:24:51 -0800 | [diff] [blame] | 141 | * Flag used when calling |
Chris Craik | 5438979 | 2013-12-20 13:28:11 -0800 | [diff] [blame] | 142 | * {@link HardwareCanvas#drawDisplayList(DisplayList, android.graphics.Rect, int)} |
Romain Guy | 33f6beb | 2012-02-16 19:24:51 -0800 | [diff] [blame] | 143 | * When this flag is set, draw operations lying outside of the bounds of the |
| 144 | * display list will be culled early. It is recommeneded to always set this |
| 145 | * flag. |
Romain Guy | 52036b1 | 2013-02-14 18:03:37 -0800 | [diff] [blame] | 146 | * |
| 147 | * @hide |
Romain Guy | 33f6beb | 2012-02-16 19:24:51 -0800 | [diff] [blame] | 148 | */ |
| 149 | public static final int FLAG_CLIP_CHILDREN = 0x1; |
| 150 | |
Romain Guy | 6554943 | 2012-03-26 16:45:05 -0700 | [diff] [blame] | 151 | // NOTE: The STATUS_* values *must* match the enum in DrawGlInfo.h |
| 152 | |
| 153 | /** |
| 154 | * Indicates that the display list is done drawing. |
Chris Craik | a2fe7af | 2014-01-28 17:25:06 -0800 | [diff] [blame] | 155 | * |
Romain Guy | 52036b1 | 2013-02-14 18:03:37 -0800 | [diff] [blame] | 156 | * @see HardwareCanvas#drawDisplayList(DisplayList, android.graphics.Rect, int) |
| 157 | * |
| 158 | * @hide |
Romain Guy | 6554943 | 2012-03-26 16:45:05 -0700 | [diff] [blame] | 159 | */ |
| 160 | public static final int STATUS_DONE = 0x0; |
| 161 | |
| 162 | /** |
| 163 | * Indicates that the display list needs another drawing pass. |
Chris Craik | a2fe7af | 2014-01-28 17:25:06 -0800 | [diff] [blame] | 164 | * |
Romain Guy | 52036b1 | 2013-02-14 18:03:37 -0800 | [diff] [blame] | 165 | * @see HardwareCanvas#drawDisplayList(DisplayList, android.graphics.Rect, int) |
| 166 | * |
| 167 | * @hide |
Romain Guy | 6554943 | 2012-03-26 16:45:05 -0700 | [diff] [blame] | 168 | */ |
Romain Guy | c553fea | 2012-03-26 17:09:19 -0700 | [diff] [blame] | 169 | public static final int STATUS_DRAW = 0x1; |
Romain Guy | 6554943 | 2012-03-26 16:45:05 -0700 | [diff] [blame] | 170 | |
| 171 | /** |
| 172 | * Indicates that the display list needs to re-execute its GL functors. |
Chris Craik | a2fe7af | 2014-01-28 17:25:06 -0800 | [diff] [blame] | 173 | * |
| 174 | * @see HardwareCanvas#drawDisplayList(DisplayList, android.graphics.Rect, int) |
| 175 | * @see HardwareCanvas#callDrawGLFunction(long) |
Romain Guy | 52036b1 | 2013-02-14 18:03:37 -0800 | [diff] [blame] | 176 | * |
| 177 | * @hide |
Romain Guy | 6554943 | 2012-03-26 16:45:05 -0700 | [diff] [blame] | 178 | */ |
| 179 | public static final int STATUS_INVOKE = 0x2; |
| 180 | |
Romain Guy | 33f6beb | 2012-02-16 19:24:51 -0800 | [diff] [blame] | 181 | /** |
Chet Haase | 4865909 | 2012-05-31 15:21:51 -0700 | [diff] [blame] | 182 | * Indicates that the display list performed GL drawing operations. |
| 183 | * |
| 184 | * @see HardwareCanvas#drawDisplayList(DisplayList, android.graphics.Rect, int) |
Romain Guy | 52036b1 | 2013-02-14 18:03:37 -0800 | [diff] [blame] | 185 | * |
| 186 | * @hide |
Chet Haase | 4865909 | 2012-05-31 15:21:51 -0700 | [diff] [blame] | 187 | */ |
| 188 | public static final int STATUS_DREW = 0x4; |
| 189 | |
Chris Craik | 5438979 | 2013-12-20 13:28:11 -0800 | [diff] [blame] | 190 | private DisplayList(String name) { |
| 191 | mName = name; |
| 192 | } |
| 193 | |
Chet Haase | 4865909 | 2012-05-31 15:21:51 -0700 | [diff] [blame] | 194 | /** |
John Reck | 339f901 | 2013-11-06 14:51:13 -0800 | [diff] [blame] | 195 | * Creates a new display list that can be used to record batches of |
| 196 | * drawing operations. |
| 197 | * |
| 198 | * @param name The name of the display list, used for debugging purpose. May be null. |
| 199 | * |
| 200 | * @return A new display list. |
| 201 | * |
| 202 | * @hide |
| 203 | */ |
| 204 | public static DisplayList create(String name) { |
Chris Craik | 5438979 | 2013-12-20 13:28:11 -0800 | [diff] [blame] | 205 | return new DisplayList(name); |
John Reck | 339f901 | 2013-11-06 14:51:13 -0800 | [diff] [blame] | 206 | } |
| 207 | |
| 208 | /** |
Romain Guy | b051e89 | 2010-09-28 19:09:36 -0700 | [diff] [blame] | 209 | * Starts recording the display list. All operations performed on the |
| 210 | * returned canvas are recorded and stored in this display list. |
Romain Guy | 52036b1 | 2013-02-14 18:03:37 -0800 | [diff] [blame] | 211 | * |
| 212 | * Calling this method will mark the display list invalid until |
| 213 | * {@link #end()} is called. Only valid display lists can be replayed. |
| 214 | * |
| 215 | * @param width The width of the display list's viewport |
| 216 | * @param height The height of the display list's viewport |
| 217 | * |
Romain Guy | b051e89 | 2010-09-28 19:09:36 -0700 | [diff] [blame] | 218 | * @return A canvas to record drawing operations. |
Romain Guy | 52036b1 | 2013-02-14 18:03:37 -0800 | [diff] [blame] | 219 | * |
| 220 | * @see #end() |
| 221 | * @see #isValid() |
Romain Guy | b051e89 | 2010-09-28 19:09:36 -0700 | [diff] [blame] | 222 | */ |
Chris Craik | 5438979 | 2013-12-20 13:28:11 -0800 | [diff] [blame] | 223 | public HardwareCanvas start(int width, int height) { |
| 224 | if (mCanvas != null) { |
| 225 | throw new IllegalStateException("Recording has already started"); |
| 226 | } |
| 227 | |
| 228 | mValid = false; |
| 229 | mCanvas = GLES20RecordingCanvas.obtain(this); |
| 230 | mCanvas.start(); |
| 231 | |
| 232 | mCanvas.setViewport(width, height); |
| 233 | // The dirty rect should always be null for a display list |
| 234 | mCanvas.onPreDraw(null); |
| 235 | |
| 236 | return mCanvas; |
| 237 | } |
Romain Guy | b051e89 | 2010-09-28 19:09:36 -0700 | [diff] [blame] | 238 | |
| 239 | /** |
| 240 | * Ends the recording for this display list. A display list cannot be |
Romain Guy | 52036b1 | 2013-02-14 18:03:37 -0800 | [diff] [blame] | 241 | * replayed if recording is not finished. Calling this method marks |
| 242 | * the display list valid and {@link #isValid()} will return true. |
| 243 | * |
| 244 | * @see #start(int, int) |
| 245 | * @see #isValid() |
Romain Guy | b051e89 | 2010-09-28 19:09:36 -0700 | [diff] [blame] | 246 | */ |
Chris Craik | 5438979 | 2013-12-20 13:28:11 -0800 | [diff] [blame] | 247 | public void end() { |
| 248 | if (mCanvas != null) { |
| 249 | mCanvas.onPostDraw(); |
| 250 | if (mFinalizer != null) { |
| 251 | mCanvas.end(mFinalizer.mNativeDisplayList); |
| 252 | } else { |
| 253 | mFinalizer = new DisplayListFinalizer(mCanvas.end(0)); |
| 254 | nSetDisplayListName(mFinalizer.mNativeDisplayList, mName); |
| 255 | } |
| 256 | mCanvas.recycle(); |
| 257 | mCanvas = null; |
| 258 | mValid = true; |
| 259 | } |
| 260 | } |
Romain Guy | b051e89 | 2010-09-28 19:09:36 -0700 | [diff] [blame] | 261 | |
| 262 | /** |
Romain Guy | 52036b1 | 2013-02-14 18:03:37 -0800 | [diff] [blame] | 263 | * Clears resources held onto by this display list. After calling this method |
| 264 | * {@link #isValid()} will return false. |
| 265 | * |
| 266 | * @see #isValid() |
Romain Guy | 46bfc48 | 2013-08-16 18:38:29 -0700 | [diff] [blame] | 267 | * @see #reset() |
Romain Guy | 38c2ece | 2012-05-24 14:20:56 -0700 | [diff] [blame] | 268 | */ |
Chris Craik | 5438979 | 2013-12-20 13:28:11 -0800 | [diff] [blame] | 269 | public void clear() { |
| 270 | clearDirty(); |
Romain Guy | 38c2ece | 2012-05-24 14:20:56 -0700 | [diff] [blame] | 271 | |
Chris Craik | 5438979 | 2013-12-20 13:28:11 -0800 | [diff] [blame] | 272 | if (mCanvas != null) { |
| 273 | mCanvas.recycle(); |
| 274 | mCanvas = null; |
| 275 | } |
| 276 | mValid = false; |
| 277 | |
| 278 | clearReferences(); |
| 279 | } |
| 280 | |
| 281 | void clearReferences() { |
| 282 | if (mChildDisplayLists != null) mChildDisplayLists.clear(); |
| 283 | } |
| 284 | |
| 285 | ArrayList<DisplayList> getChildDisplayLists() { |
| 286 | if (mChildDisplayLists == null) mChildDisplayLists = new ArrayList<DisplayList>(); |
| 287 | return mChildDisplayLists; |
| 288 | } |
Romain Guy | 46bfc48 | 2013-08-16 18:38:29 -0700 | [diff] [blame] | 289 | |
| 290 | /** |
| 291 | * Reset native resources. This is called when cleaning up the state of display lists |
| 292 | * during destruction of hardware resources, to ensure that we do not hold onto |
| 293 | * obsolete resources after related resources are gone. |
| 294 | * |
| 295 | * @see #clear() |
| 296 | * |
| 297 | * @hide |
| 298 | */ |
Chris Craik | 5438979 | 2013-12-20 13:28:11 -0800 | [diff] [blame] | 299 | public void reset() { |
| 300 | if (hasNativeDisplayList()) { |
| 301 | nReset(mFinalizer.mNativeDisplayList); |
| 302 | } |
| 303 | clear(); |
| 304 | } |
Romain Guy | 46bfc48 | 2013-08-16 18:38:29 -0700 | [diff] [blame] | 305 | |
Romain Guy | 38c2ece | 2012-05-24 14:20:56 -0700 | [diff] [blame] | 306 | /** |
Romain Guy | 52036b1 | 2013-02-14 18:03:37 -0800 | [diff] [blame] | 307 | * Sets the dirty flag. When a display list is dirty, {@link #clear()} should |
| 308 | * be invoked whenever possible. |
Romain Guy | fbb93fa | 2012-12-03 18:50:35 -0800 | [diff] [blame] | 309 | * |
| 310 | * @see #isDirty() |
Romain Guy | 52036b1 | 2013-02-14 18:03:37 -0800 | [diff] [blame] | 311 | * @see #clear() |
| 312 | * |
| 313 | * @hide |
Romain Guy | fbb93fa | 2012-12-03 18:50:35 -0800 | [diff] [blame] | 314 | */ |
Romain Guy | 52036b1 | 2013-02-14 18:03:37 -0800 | [diff] [blame] | 315 | public void markDirty() { |
| 316 | mDirty = true; |
| 317 | } |
| 318 | |
| 319 | /** |
| 320 | * Removes the dirty flag. This method can be used to cancel a cleanup |
| 321 | * previously scheduled by setting the dirty flag. |
| 322 | * |
| 323 | * @see #isDirty() |
| 324 | * @see #clear() |
| 325 | * |
| 326 | * @hide |
| 327 | */ |
| 328 | protected void clearDirty() { |
| 329 | mDirty = false; |
Romain Guy | fbb93fa | 2012-12-03 18:50:35 -0800 | [diff] [blame] | 330 | } |
| 331 | |
| 332 | /** |
| 333 | * Indicates whether the display list is dirty. |
| 334 | * |
Romain Guy | 52036b1 | 2013-02-14 18:03:37 -0800 | [diff] [blame] | 335 | * @see #markDirty() |
| 336 | * @see #clear() |
| 337 | * |
| 338 | * @hide |
Romain Guy | fbb93fa | 2012-12-03 18:50:35 -0800 | [diff] [blame] | 339 | */ |
| 340 | public boolean isDirty() { |
| 341 | return mDirty; |
| 342 | } |
| 343 | |
| 344 | /** |
Chet Haase | 9e90a99 | 2011-01-04 16:23:21 -0800 | [diff] [blame] | 345 | * Returns whether the display list is currently usable. If this returns false, |
| 346 | * the display list should be re-recorded prior to replaying it. |
| 347 | * |
| 348 | * @return boolean true if the display list is able to be replayed, false otherwise. |
| 349 | */ |
Chris Craik | 5438979 | 2013-12-20 13:28:11 -0800 | [diff] [blame] | 350 | public boolean isValid() { return mValid; } |
Romain Guy | 65b345f | 2011-07-27 18:51:50 -0700 | [diff] [blame] | 351 | |
| 352 | /** |
| 353 | * Return the amount of memory used by this display list. |
Chris Craik | 5438979 | 2013-12-20 13:28:11 -0800 | [diff] [blame] | 354 | * |
Romain Guy | 65b345f | 2011-07-27 18:51:50 -0700 | [diff] [blame] | 355 | * @return The size of this display list in bytes |
Romain Guy | 52036b1 | 2013-02-14 18:03:37 -0800 | [diff] [blame] | 356 | * |
| 357 | * @hide |
Romain Guy | 65b345f | 2011-07-27 18:51:50 -0700 | [diff] [blame] | 358 | */ |
Chris Craik | 5438979 | 2013-12-20 13:28:11 -0800 | [diff] [blame] | 359 | public int getSize() { |
| 360 | if (mFinalizer == null) return 0; |
| 361 | return nGetDisplayListSize(mFinalizer.mNativeDisplayList); |
| 362 | } |
| 363 | |
| 364 | boolean hasNativeDisplayList() { |
| 365 | return mValid && mFinalizer != null; |
| 366 | } |
| 367 | |
Ashok Bhat | 36bef0b | 2014-01-20 20:08:01 +0000 | [diff] [blame] | 368 | long getNativeDisplayList() { |
Chris Craik | 5438979 | 2013-12-20 13:28:11 -0800 | [diff] [blame] | 369 | if (!mValid || mFinalizer == null) { |
| 370 | throw new IllegalStateException("The display list is not valid."); |
| 371 | } |
| 372 | return mFinalizer.mNativeDisplayList; |
| 373 | } |
Chet Haase | a1cff50 | 2012-02-21 13:43:44 -0800 | [diff] [blame] | 374 | |
| 375 | /////////////////////////////////////////////////////////////////////////// |
| 376 | // DisplayList Property Setters |
| 377 | /////////////////////////////////////////////////////////////////////////// |
| 378 | |
| 379 | /** |
Romain Guy | 52036b1 | 2013-02-14 18:03:37 -0800 | [diff] [blame] | 380 | * Set the caching property on the display list, which indicates whether the display list |
| 381 | * holds a layer. Layer display lists should avoid creating an alpha layer, since alpha is |
Chet Haase | a1cff50 | 2012-02-21 13:43:44 -0800 | [diff] [blame] | 382 | * handled in the drawLayer operation directly (and more efficiently). |
| 383 | * |
Romain Guy | 52036b1 | 2013-02-14 18:03:37 -0800 | [diff] [blame] | 384 | * @param caching true if the display list represents a hardware layer, false otherwise. |
| 385 | * |
| 386 | * @hide |
Chet Haase | a1cff50 | 2012-02-21 13:43:44 -0800 | [diff] [blame] | 387 | */ |
Chris Craik | 5438979 | 2013-12-20 13:28:11 -0800 | [diff] [blame] | 388 | public void setCaching(boolean caching) { |
| 389 | if (hasNativeDisplayList()) { |
| 390 | nSetCaching(mFinalizer.mNativeDisplayList, caching); |
| 391 | } |
| 392 | } |
Chet Haase | a1cff50 | 2012-02-21 13:43:44 -0800 | [diff] [blame] | 393 | |
| 394 | /** |
Romain Guy | 52036b1 | 2013-02-14 18:03:37 -0800 | [diff] [blame] | 395 | * Set whether the display list should clip itself to its bounds. This property is controlled by |
Chet Haase | a1cff50 | 2012-02-21 13:43:44 -0800 | [diff] [blame] | 396 | * the view's parent. |
| 397 | * |
Chet Haase | dd67159 | 2013-04-19 14:54:34 -0700 | [diff] [blame] | 398 | * @param clipToBounds true if the display list should clip to its bounds |
Chet Haase | a1cff50 | 2012-02-21 13:43:44 -0800 | [diff] [blame] | 399 | */ |
Chris Craik | 5438979 | 2013-12-20 13:28:11 -0800 | [diff] [blame] | 400 | public void setClipToBounds(boolean clipToBounds) { |
| 401 | if (hasNativeDisplayList()) { |
| 402 | nSetClipToBounds(mFinalizer.mNativeDisplayList, clipToBounds); |
| 403 | } |
| 404 | } |
Chet Haase | a1cff50 | 2012-02-21 13:43:44 -0800 | [diff] [blame] | 405 | |
| 406 | /** |
Chris Craik | d863a10 | 2013-12-19 13:31:15 -0800 | [diff] [blame] | 407 | * Set whether the display list should collect and Z order all 3d composited descendents, and |
| 408 | * draw them in order with the default Z=0 content. |
| 409 | * |
Chris Craik | a2fe7af | 2014-01-28 17:25:06 -0800 | [diff] [blame] | 410 | * @param isolatedZVolume true if the display list should collect and Z order descendents. |
Chris Craik | d863a10 | 2013-12-19 13:31:15 -0800 | [diff] [blame] | 411 | */ |
Chris Craik | 6657a6c | 2014-01-26 11:30:58 -0800 | [diff] [blame] | 412 | public void setIsolatedZVolume(boolean isolatedZVolume) { |
Chris Craik | d863a10 | 2013-12-19 13:31:15 -0800 | [diff] [blame] | 413 | if (hasNativeDisplayList()) { |
Chris Craik | 6657a6c | 2014-01-26 11:30:58 -0800 | [diff] [blame] | 414 | nSetIsolatedZVolume(mFinalizer.mNativeDisplayList, isolatedZVolume); |
Chris Craik | d863a10 | 2013-12-19 13:31:15 -0800 | [diff] [blame] | 415 | } |
| 416 | } |
| 417 | |
| 418 | /** |
Alan Viverette | 58f09b3 | 2014-01-08 17:18:19 -0800 | [diff] [blame] | 419 | * Sets whether the display list should be drawn immediately after the |
Chris Craik | 6657a6c | 2014-01-26 11:30:58 -0800 | [diff] [blame] | 420 | * closest ancestor display list where isolateZVolume is true. If the |
Alan Viverette | 58f09b3 | 2014-01-08 17:18:19 -0800 | [diff] [blame] | 421 | * display list itself satisfies this constraint, changing this attribute |
| 422 | * has no effect on drawing order. |
| 423 | * |
| 424 | * @param shouldProject true if the display list should be projected onto a |
| 425 | * containing volume. |
| 426 | */ |
Chris Craik | 6657a6c | 2014-01-26 11:30:58 -0800 | [diff] [blame] | 427 | public void setProjectBackwards(boolean shouldProject) { |
Alan Viverette | 58f09b3 | 2014-01-08 17:18:19 -0800 | [diff] [blame] | 428 | if (hasNativeDisplayList()) { |
Chris Craik | 6657a6c | 2014-01-26 11:30:58 -0800 | [diff] [blame] | 429 | nSetProjectBackwards(mFinalizer.mNativeDisplayList, shouldProject); |
Alan Viverette | 58f09b3 | 2014-01-08 17:18:19 -0800 | [diff] [blame] | 430 | } |
| 431 | } |
| 432 | |
| 433 | /** |
Chris Craik | 1df2644 | 2014-02-05 16:50:41 -0800 | [diff] [blame] | 434 | * Sets whether the display list is a projection receiver - that its parent |
| 435 | * DisplayList should draw any descendent DisplayLists with |
| 436 | * ProjectBackwards=true directly on top of it. Default value is false. |
| 437 | */ |
| 438 | public void setProjectionReceiver(boolean shouldRecieve) { |
| 439 | if (hasNativeDisplayList()) { |
| 440 | nSetProjectionReceiver(mFinalizer.mNativeDisplayList, shouldRecieve); |
| 441 | } |
| 442 | } |
| 443 | |
| 444 | /** |
ztenghui | fad4593 | 2014-02-06 10:33:58 -0800 | [diff] [blame] | 445 | * Sets the outline, defining the shape that casts a shadow, and the path to |
| 446 | * be clipped if setClipToOutline is set. |
Chris Craik | a2fe7af | 2014-01-28 17:25:06 -0800 | [diff] [blame] | 447 | * |
| 448 | * Deep copies the native path to simplify reference ownership. |
| 449 | * |
| 450 | * @param outline Convex, CW Path to store in the DisplayList. May be null. |
| 451 | */ |
| 452 | public void setOutline(Path outline) { |
| 453 | if (hasNativeDisplayList()) { |
| 454 | long nativePath = (outline == null) ? 0 : outline.mNativePath; |
| 455 | nSetOutline(mFinalizer.mNativeDisplayList, nativePath); |
| 456 | } |
| 457 | } |
| 458 | |
| 459 | /** |
ztenghui | fad4593 | 2014-02-06 10:33:58 -0800 | [diff] [blame] | 460 | * Enables or disables clipping to the outline. |
| 461 | * |
| 462 | * @param clipToOutline true if clipping to the outline. |
| 463 | */ |
| 464 | public void setClipToOutline(boolean clipToOutline) { |
| 465 | if (hasNativeDisplayList()) { |
| 466 | nSetClipToOutline(mFinalizer.mNativeDisplayList, clipToOutline); |
| 467 | } |
| 468 | } |
| 469 | |
| 470 | /** |
Romain Guy | 52036b1 | 2013-02-14 18:03:37 -0800 | [diff] [blame] | 471 | * Set the static matrix on the display list. The specified matrix is combined with other |
| 472 | * transforms (such as {@link #setScaleX(float)}, {@link #setRotation(float)}, etc.) |
Chet Haase | a1cff50 | 2012-02-21 13:43:44 -0800 | [diff] [blame] | 473 | * |
Romain Guy | 52036b1 | 2013-02-14 18:03:37 -0800 | [diff] [blame] | 474 | * @param matrix A transform matrix to apply to this display list |
| 475 | * |
| 476 | * @see #getMatrix(android.graphics.Matrix) |
| 477 | * @see #getMatrix() |
Chet Haase | a1cff50 | 2012-02-21 13:43:44 -0800 | [diff] [blame] | 478 | */ |
Chris Craik | 5438979 | 2013-12-20 13:28:11 -0800 | [diff] [blame] | 479 | public void setMatrix(Matrix matrix) { |
| 480 | if (hasNativeDisplayList()) { |
| 481 | nSetStaticMatrix(mFinalizer.mNativeDisplayList, matrix.native_instance); |
| 482 | } |
| 483 | } |
Chet Haase | 9420abd | 2012-03-29 16:28:32 -0700 | [diff] [blame] | 484 | |
| 485 | /** |
Romain Guy | 52036b1 | 2013-02-14 18:03:37 -0800 | [diff] [blame] | 486 | * Returns the static matrix set on this display list. |
| 487 | * |
| 488 | * @return A new {@link Matrix} instance populated with this display list's static |
| 489 | * matrix |
| 490 | * |
| 491 | * @see #getMatrix(android.graphics.Matrix) |
| 492 | * @see #setMatrix(android.graphics.Matrix) |
| 493 | */ |
| 494 | public Matrix getMatrix() { |
| 495 | return getMatrix(new Matrix()); |
| 496 | } |
| 497 | |
| 498 | /** |
| 499 | * Copies this display list's static matrix into the specified matrix. |
| 500 | * |
| 501 | * @param matrix The {@link Matrix} instance in which to copy this display |
| 502 | * list's static matrix. Cannot be null |
| 503 | * |
| 504 | * @return The <code>matrix</code> parameter, for convenience |
| 505 | * |
| 506 | * @see #getMatrix() |
| 507 | * @see #setMatrix(android.graphics.Matrix) |
| 508 | */ |
Chris Craik | 5438979 | 2013-12-20 13:28:11 -0800 | [diff] [blame] | 509 | public Matrix getMatrix(Matrix matrix) { |
| 510 | if (hasNativeDisplayList()) { |
| 511 | nGetMatrix(mFinalizer.mNativeDisplayList, matrix.native_instance); |
| 512 | } |
| 513 | return matrix; |
| 514 | } |
Romain Guy | 52036b1 | 2013-02-14 18:03:37 -0800 | [diff] [blame] | 515 | |
| 516 | /** |
| 517 | * Set the Animation matrix on the display list. This matrix exists if an Animation is |
| 518 | * currently playing on a View, and is set on the display list during at draw() time. When |
Chet Haase | 9420abd | 2012-03-29 16:28:32 -0700 | [diff] [blame] | 519 | * the Animation finishes, the matrix should be cleared by sending <code>null</code> |
| 520 | * for the matrix parameter. |
| 521 | * |
| 522 | * @param matrix The matrix, null indicates that the matrix should be cleared. |
Romain Guy | 52036b1 | 2013-02-14 18:03:37 -0800 | [diff] [blame] | 523 | * |
| 524 | * @hide |
Chet Haase | 9420abd | 2012-03-29 16:28:32 -0700 | [diff] [blame] | 525 | */ |
Chris Craik | 5438979 | 2013-12-20 13:28:11 -0800 | [diff] [blame] | 526 | public void setAnimationMatrix(Matrix matrix) { |
| 527 | if (hasNativeDisplayList()) { |
| 528 | nSetAnimationMatrix(mFinalizer.mNativeDisplayList, |
| 529 | (matrix != null) ? matrix.native_instance : 0); |
| 530 | } |
| 531 | } |
Chet Haase | a1cff50 | 2012-02-21 13:43:44 -0800 | [diff] [blame] | 532 | |
| 533 | /** |
Romain Guy | 52036b1 | 2013-02-14 18:03:37 -0800 | [diff] [blame] | 534 | * Sets the translucency level for the display list. |
Chet Haase | a1cff50 | 2012-02-21 13:43:44 -0800 | [diff] [blame] | 535 | * |
Romain Guy | 52036b1 | 2013-02-14 18:03:37 -0800 | [diff] [blame] | 536 | * @param alpha The translucency of the display list, must be a value between 0.0f and 1.0f |
| 537 | * |
Chet Haase | a1cff50 | 2012-02-21 13:43:44 -0800 | [diff] [blame] | 538 | * @see View#setAlpha(float) |
Romain Guy | 52036b1 | 2013-02-14 18:03:37 -0800 | [diff] [blame] | 539 | * @see #getAlpha() |
Chet Haase | a1cff50 | 2012-02-21 13:43:44 -0800 | [diff] [blame] | 540 | */ |
Chris Craik | 5438979 | 2013-12-20 13:28:11 -0800 | [diff] [blame] | 541 | public void setAlpha(float alpha) { |
| 542 | if (hasNativeDisplayList()) { |
| 543 | nSetAlpha(mFinalizer.mNativeDisplayList, alpha); |
| 544 | } |
| 545 | } |
Chet Haase | a1cff50 | 2012-02-21 13:43:44 -0800 | [diff] [blame] | 546 | |
| 547 | /** |
Romain Guy | 52036b1 | 2013-02-14 18:03:37 -0800 | [diff] [blame] | 548 | * Returns the translucency level of this display list. |
Chet Haase | db8c9a6 | 2012-03-21 18:54:18 -0700 | [diff] [blame] | 549 | * |
Romain Guy | 52036b1 | 2013-02-14 18:03:37 -0800 | [diff] [blame] | 550 | * @return A value between 0.0f and 1.0f |
| 551 | * |
| 552 | * @see #setAlpha(float) |
| 553 | */ |
Chris Craik | 5438979 | 2013-12-20 13:28:11 -0800 | [diff] [blame] | 554 | public float getAlpha() { |
| 555 | if (hasNativeDisplayList()) { |
| 556 | return nGetAlpha(mFinalizer.mNativeDisplayList); |
| 557 | } |
| 558 | return 1.0f; |
| 559 | } |
Romain Guy | 52036b1 | 2013-02-14 18:03:37 -0800 | [diff] [blame] | 560 | |
| 561 | /** |
| 562 | * Sets whether the display list renders content which overlaps. Non-overlapping rendering |
| 563 | * can use a fast path for alpha that avoids rendering to an offscreen buffer. By default |
| 564 | * display lists consider they do not have overlapping content. |
| 565 | * |
| 566 | * @param hasOverlappingRendering False if the content is guaranteed to be non-overlapping, |
| 567 | * true otherwise. |
| 568 | * |
Chet Haase | db8c9a6 | 2012-03-21 18:54:18 -0700 | [diff] [blame] | 569 | * @see android.view.View#hasOverlappingRendering() |
Romain Guy | 52036b1 | 2013-02-14 18:03:37 -0800 | [diff] [blame] | 570 | * @see #hasOverlappingRendering() |
Chet Haase | db8c9a6 | 2012-03-21 18:54:18 -0700 | [diff] [blame] | 571 | */ |
Chris Craik | 5438979 | 2013-12-20 13:28:11 -0800 | [diff] [blame] | 572 | public void setHasOverlappingRendering(boolean hasOverlappingRendering) { |
| 573 | if (hasNativeDisplayList()) { |
| 574 | nSetHasOverlappingRendering(mFinalizer.mNativeDisplayList, hasOverlappingRendering); |
| 575 | } |
| 576 | } |
Chet Haase | db8c9a6 | 2012-03-21 18:54:18 -0700 | [diff] [blame] | 577 | |
| 578 | /** |
Romain Guy | 52036b1 | 2013-02-14 18:03:37 -0800 | [diff] [blame] | 579 | * Indicates whether the content of this display list overlaps. |
Chet Haase | a1cff50 | 2012-02-21 13:43:44 -0800 | [diff] [blame] | 580 | * |
Romain Guy | 52036b1 | 2013-02-14 18:03:37 -0800 | [diff] [blame] | 581 | * @return True if this display list renders content which overlaps, false otherwise. |
| 582 | * |
| 583 | * @see #setHasOverlappingRendering(boolean) |
| 584 | */ |
Chris Craik | 5438979 | 2013-12-20 13:28:11 -0800 | [diff] [blame] | 585 | public boolean hasOverlappingRendering() { |
| 586 | //noinspection SimplifiableIfStatement |
| 587 | if (hasNativeDisplayList()) { |
| 588 | return nHasOverlappingRendering(mFinalizer.mNativeDisplayList); |
| 589 | } |
| 590 | return true; |
| 591 | } |
Romain Guy | 52036b1 | 2013-02-14 18:03:37 -0800 | [diff] [blame] | 592 | |
| 593 | /** |
Chris Craik | d863a10 | 2013-12-19 13:31:15 -0800 | [diff] [blame] | 594 | * Sets the translation value for the display list on the X axis. |
Romain Guy | 52036b1 | 2013-02-14 18:03:37 -0800 | [diff] [blame] | 595 | * |
| 596 | * @param translationX The X axis translation value of the display list, in pixels |
| 597 | * |
Chet Haase | a1cff50 | 2012-02-21 13:43:44 -0800 | [diff] [blame] | 598 | * @see View#setTranslationX(float) |
Romain Guy | 52036b1 | 2013-02-14 18:03:37 -0800 | [diff] [blame] | 599 | * @see #getTranslationX() |
Chet Haase | a1cff50 | 2012-02-21 13:43:44 -0800 | [diff] [blame] | 600 | */ |
Chris Craik | 5438979 | 2013-12-20 13:28:11 -0800 | [diff] [blame] | 601 | public void setTranslationX(float translationX) { |
| 602 | if (hasNativeDisplayList()) { |
| 603 | nSetTranslationX(mFinalizer.mNativeDisplayList, translationX); |
| 604 | } |
| 605 | } |
Chet Haase | a1cff50 | 2012-02-21 13:43:44 -0800 | [diff] [blame] | 606 | |
| 607 | /** |
Romain Guy | 52036b1 | 2013-02-14 18:03:37 -0800 | [diff] [blame] | 608 | * Returns the translation value for this display list on the X axis, in pixels. |
Chet Haase | a1cff50 | 2012-02-21 13:43:44 -0800 | [diff] [blame] | 609 | * |
Romain Guy | 52036b1 | 2013-02-14 18:03:37 -0800 | [diff] [blame] | 610 | * @see #setTranslationX(float) |
| 611 | */ |
Chris Craik | 5438979 | 2013-12-20 13:28:11 -0800 | [diff] [blame] | 612 | public float getTranslationX() { |
| 613 | if (hasNativeDisplayList()) { |
| 614 | return nGetTranslationX(mFinalizer.mNativeDisplayList); |
| 615 | } |
| 616 | return 0.0f; |
| 617 | } |
Romain Guy | 52036b1 | 2013-02-14 18:03:37 -0800 | [diff] [blame] | 618 | |
| 619 | /** |
Chris Craik | d863a10 | 2013-12-19 13:31:15 -0800 | [diff] [blame] | 620 | * Sets the translation value for the display list on the Y axis. |
Romain Guy | 52036b1 | 2013-02-14 18:03:37 -0800 | [diff] [blame] | 621 | * |
| 622 | * @param translationY The Y axis translation value of the display list, in pixels |
| 623 | * |
Chet Haase | a1cff50 | 2012-02-21 13:43:44 -0800 | [diff] [blame] | 624 | * @see View#setTranslationY(float) |
Romain Guy | 52036b1 | 2013-02-14 18:03:37 -0800 | [diff] [blame] | 625 | * @see #getTranslationY() |
Chet Haase | a1cff50 | 2012-02-21 13:43:44 -0800 | [diff] [blame] | 626 | */ |
Chris Craik | 5438979 | 2013-12-20 13:28:11 -0800 | [diff] [blame] | 627 | public void setTranslationY(float translationY) { |
| 628 | if (hasNativeDisplayList()) { |
| 629 | nSetTranslationY(mFinalizer.mNativeDisplayList, translationY); |
| 630 | } |
| 631 | } |
Chet Haase | a1cff50 | 2012-02-21 13:43:44 -0800 | [diff] [blame] | 632 | |
| 633 | /** |
Romain Guy | 52036b1 | 2013-02-14 18:03:37 -0800 | [diff] [blame] | 634 | * Returns the translation value for this display list on the Y axis, in pixels. |
Chet Haase | a1cff50 | 2012-02-21 13:43:44 -0800 | [diff] [blame] | 635 | * |
Romain Guy | 52036b1 | 2013-02-14 18:03:37 -0800 | [diff] [blame] | 636 | * @see #setTranslationY(float) |
| 637 | */ |
Chris Craik | 5438979 | 2013-12-20 13:28:11 -0800 | [diff] [blame] | 638 | public float getTranslationY() { |
| 639 | if (hasNativeDisplayList()) { |
| 640 | return nGetTranslationY(mFinalizer.mNativeDisplayList); |
| 641 | } |
| 642 | return 0.0f; |
| 643 | } |
Romain Guy | 52036b1 | 2013-02-14 18:03:37 -0800 | [diff] [blame] | 644 | |
| 645 | /** |
Chris Craik | d863a10 | 2013-12-19 13:31:15 -0800 | [diff] [blame] | 646 | * Sets the translation value for the display list on the Z axis. |
Chris Craik | f57776b | 2013-10-25 18:30:17 -0700 | [diff] [blame] | 647 | * |
| 648 | * @see View#setTranslationZ(float) |
| 649 | * @see #getTranslationZ() |
| 650 | */ |
Chris Craik | 5438979 | 2013-12-20 13:28:11 -0800 | [diff] [blame] | 651 | public void setTranslationZ(float translationZ) { |
| 652 | if (hasNativeDisplayList()) { |
| 653 | nSetTranslationZ(mFinalizer.mNativeDisplayList, translationZ); |
| 654 | } |
| 655 | } |
Chris Craik | f57776b | 2013-10-25 18:30:17 -0700 | [diff] [blame] | 656 | |
| 657 | /** |
| 658 | * Returns the translation value for this display list on the Z axis. |
| 659 | * |
| 660 | * @see #setTranslationZ(float) |
| 661 | */ |
Chris Craik | 5438979 | 2013-12-20 13:28:11 -0800 | [diff] [blame] | 662 | public float getTranslationZ() { |
| 663 | if (hasNativeDisplayList()) { |
| 664 | return nGetTranslationZ(mFinalizer.mNativeDisplayList); |
| 665 | } |
| 666 | return 0.0f; |
| 667 | } |
Chris Craik | f57776b | 2013-10-25 18:30:17 -0700 | [diff] [blame] | 668 | |
| 669 | /** |
Chris Craik | d863a10 | 2013-12-19 13:31:15 -0800 | [diff] [blame] | 670 | * Sets the rotation value for the display list around the Z axis. |
Romain Guy | 52036b1 | 2013-02-14 18:03:37 -0800 | [diff] [blame] | 671 | * |
| 672 | * @param rotation The rotation value of the display list, in degrees |
| 673 | * |
Chet Haase | a1cff50 | 2012-02-21 13:43:44 -0800 | [diff] [blame] | 674 | * @see View#setRotation(float) |
Romain Guy | 52036b1 | 2013-02-14 18:03:37 -0800 | [diff] [blame] | 675 | * @see #getRotation() |
Chet Haase | a1cff50 | 2012-02-21 13:43:44 -0800 | [diff] [blame] | 676 | */ |
Chris Craik | 5438979 | 2013-12-20 13:28:11 -0800 | [diff] [blame] | 677 | public void setRotation(float rotation) { |
| 678 | if (hasNativeDisplayList()) { |
| 679 | nSetRotation(mFinalizer.mNativeDisplayList, rotation); |
| 680 | } |
| 681 | } |
Chet Haase | a1cff50 | 2012-02-21 13:43:44 -0800 | [diff] [blame] | 682 | |
| 683 | /** |
Romain Guy | 52036b1 | 2013-02-14 18:03:37 -0800 | [diff] [blame] | 684 | * Returns the rotation value for this display list around the Z axis, in degrees. |
Chet Haase | a1cff50 | 2012-02-21 13:43:44 -0800 | [diff] [blame] | 685 | * |
Romain Guy | 52036b1 | 2013-02-14 18:03:37 -0800 | [diff] [blame] | 686 | * @see #setRotation(float) |
| 687 | */ |
Chris Craik | 5438979 | 2013-12-20 13:28:11 -0800 | [diff] [blame] | 688 | public float getRotation() { |
| 689 | if (hasNativeDisplayList()) { |
| 690 | return nGetRotation(mFinalizer.mNativeDisplayList); |
| 691 | } |
| 692 | return 0.0f; |
| 693 | } |
Romain Guy | 52036b1 | 2013-02-14 18:03:37 -0800 | [diff] [blame] | 694 | |
| 695 | /** |
Chris Craik | d863a10 | 2013-12-19 13:31:15 -0800 | [diff] [blame] | 696 | * Sets the rotation value for the display list around the X axis. |
Romain Guy | 52036b1 | 2013-02-14 18:03:37 -0800 | [diff] [blame] | 697 | * |
| 698 | * @param rotationX The rotation value of the display list, in degrees |
| 699 | * |
Chet Haase | a1cff50 | 2012-02-21 13:43:44 -0800 | [diff] [blame] | 700 | * @see View#setRotationX(float) |
Romain Guy | 52036b1 | 2013-02-14 18:03:37 -0800 | [diff] [blame] | 701 | * @see #getRotationX() |
Chet Haase | a1cff50 | 2012-02-21 13:43:44 -0800 | [diff] [blame] | 702 | */ |
Chris Craik | 5438979 | 2013-12-20 13:28:11 -0800 | [diff] [blame] | 703 | public void setRotationX(float rotationX) { |
| 704 | if (hasNativeDisplayList()) { |
| 705 | nSetRotationX(mFinalizer.mNativeDisplayList, rotationX); |
| 706 | } |
| 707 | } |
Chet Haase | a1cff50 | 2012-02-21 13:43:44 -0800 | [diff] [blame] | 708 | |
| 709 | /** |
Romain Guy | 52036b1 | 2013-02-14 18:03:37 -0800 | [diff] [blame] | 710 | * Returns the rotation value for this display list around the X axis, in degrees. |
Chet Haase | a1cff50 | 2012-02-21 13:43:44 -0800 | [diff] [blame] | 711 | * |
Romain Guy | 52036b1 | 2013-02-14 18:03:37 -0800 | [diff] [blame] | 712 | * @see #setRotationX(float) |
| 713 | */ |
Chris Craik | 5438979 | 2013-12-20 13:28:11 -0800 | [diff] [blame] | 714 | public float getRotationX() { |
| 715 | if (hasNativeDisplayList()) { |
| 716 | return nGetRotationX(mFinalizer.mNativeDisplayList); |
| 717 | } |
| 718 | return 0.0f; |
| 719 | } |
Romain Guy | 52036b1 | 2013-02-14 18:03:37 -0800 | [diff] [blame] | 720 | |
| 721 | /** |
Chris Craik | d863a10 | 2013-12-19 13:31:15 -0800 | [diff] [blame] | 722 | * Sets the rotation value for the display list around the Y axis. |
Romain Guy | 52036b1 | 2013-02-14 18:03:37 -0800 | [diff] [blame] | 723 | * |
| 724 | * @param rotationY The rotation value of the display list, in degrees |
| 725 | * |
Chet Haase | a1cff50 | 2012-02-21 13:43:44 -0800 | [diff] [blame] | 726 | * @see View#setRotationY(float) |
Romain Guy | 52036b1 | 2013-02-14 18:03:37 -0800 | [diff] [blame] | 727 | * @see #getRotationY() |
Chet Haase | a1cff50 | 2012-02-21 13:43:44 -0800 | [diff] [blame] | 728 | */ |
Chris Craik | 5438979 | 2013-12-20 13:28:11 -0800 | [diff] [blame] | 729 | public void setRotationY(float rotationY) { |
| 730 | if (hasNativeDisplayList()) { |
| 731 | nSetRotationY(mFinalizer.mNativeDisplayList, rotationY); |
| 732 | } |
| 733 | } |
Chet Haase | a1cff50 | 2012-02-21 13:43:44 -0800 | [diff] [blame] | 734 | |
| 735 | /** |
Romain Guy | 52036b1 | 2013-02-14 18:03:37 -0800 | [diff] [blame] | 736 | * Returns the rotation value for this display list around the Y axis, in degrees. |
Chet Haase | a1cff50 | 2012-02-21 13:43:44 -0800 | [diff] [blame] | 737 | * |
Romain Guy | 52036b1 | 2013-02-14 18:03:37 -0800 | [diff] [blame] | 738 | * @see #setRotationY(float) |
| 739 | */ |
Chris Craik | 5438979 | 2013-12-20 13:28:11 -0800 | [diff] [blame] | 740 | public float getRotationY() { |
| 741 | if (hasNativeDisplayList()) { |
| 742 | return nGetRotationY(mFinalizer.mNativeDisplayList); |
| 743 | } |
| 744 | return 0.0f; |
| 745 | } |
Romain Guy | 52036b1 | 2013-02-14 18:03:37 -0800 | [diff] [blame] | 746 | |
| 747 | /** |
Chris Craik | d863a10 | 2013-12-19 13:31:15 -0800 | [diff] [blame] | 748 | * Sets the scale value for the display list on the X axis. |
Romain Guy | 52036b1 | 2013-02-14 18:03:37 -0800 | [diff] [blame] | 749 | * |
| 750 | * @param scaleX The scale value of the display list |
| 751 | * |
Chet Haase | a1cff50 | 2012-02-21 13:43:44 -0800 | [diff] [blame] | 752 | * @see View#setScaleX(float) |
Romain Guy | 52036b1 | 2013-02-14 18:03:37 -0800 | [diff] [blame] | 753 | * @see #getScaleX() |
Chet Haase | a1cff50 | 2012-02-21 13:43:44 -0800 | [diff] [blame] | 754 | */ |
Chris Craik | 5438979 | 2013-12-20 13:28:11 -0800 | [diff] [blame] | 755 | public void setScaleX(float scaleX) { |
| 756 | if (hasNativeDisplayList()) { |
| 757 | nSetScaleX(mFinalizer.mNativeDisplayList, scaleX); |
| 758 | } |
| 759 | } |
Chet Haase | a1cff50 | 2012-02-21 13:43:44 -0800 | [diff] [blame] | 760 | |
| 761 | /** |
Romain Guy | 52036b1 | 2013-02-14 18:03:37 -0800 | [diff] [blame] | 762 | * Returns the scale value for this display list on the X axis. |
Chet Haase | a1cff50 | 2012-02-21 13:43:44 -0800 | [diff] [blame] | 763 | * |
Romain Guy | 52036b1 | 2013-02-14 18:03:37 -0800 | [diff] [blame] | 764 | * @see #setScaleX(float) |
| 765 | */ |
Chris Craik | 5438979 | 2013-12-20 13:28:11 -0800 | [diff] [blame] | 766 | public float getScaleX() { |
| 767 | if (hasNativeDisplayList()) { |
| 768 | return nGetScaleX(mFinalizer.mNativeDisplayList); |
| 769 | } |
| 770 | return 1.0f; |
| 771 | } |
Romain Guy | 52036b1 | 2013-02-14 18:03:37 -0800 | [diff] [blame] | 772 | |
| 773 | /** |
Chris Craik | d863a10 | 2013-12-19 13:31:15 -0800 | [diff] [blame] | 774 | * Sets the scale value for the display list on the Y axis. |
Romain Guy | 52036b1 | 2013-02-14 18:03:37 -0800 | [diff] [blame] | 775 | * |
| 776 | * @param scaleY The scale value of the display list |
| 777 | * |
Chet Haase | a1cff50 | 2012-02-21 13:43:44 -0800 | [diff] [blame] | 778 | * @see View#setScaleY(float) |
Romain Guy | 52036b1 | 2013-02-14 18:03:37 -0800 | [diff] [blame] | 779 | * @see #getScaleY() |
Chet Haase | a1cff50 | 2012-02-21 13:43:44 -0800 | [diff] [blame] | 780 | */ |
Chris Craik | 5438979 | 2013-12-20 13:28:11 -0800 | [diff] [blame] | 781 | public void setScaleY(float scaleY) { |
| 782 | if (hasNativeDisplayList()) { |
| 783 | nSetScaleY(mFinalizer.mNativeDisplayList, scaleY); |
| 784 | } |
| 785 | } |
Chet Haase | a1cff50 | 2012-02-21 13:43:44 -0800 | [diff] [blame] | 786 | |
| 787 | /** |
Romain Guy | 52036b1 | 2013-02-14 18:03:37 -0800 | [diff] [blame] | 788 | * Returns the scale value for this display list on the Y axis. |
Chet Haase | a1cff50 | 2012-02-21 13:43:44 -0800 | [diff] [blame] | 789 | * |
Romain Guy | 52036b1 | 2013-02-14 18:03:37 -0800 | [diff] [blame] | 790 | * @see #setScaleY(float) |
| 791 | */ |
Chris Craik | 5438979 | 2013-12-20 13:28:11 -0800 | [diff] [blame] | 792 | public float getScaleY() { |
| 793 | if (hasNativeDisplayList()) { |
| 794 | return nGetScaleY(mFinalizer.mNativeDisplayList); |
| 795 | } |
| 796 | return 1.0f; |
| 797 | } |
Romain Guy | 52036b1 | 2013-02-14 18:03:37 -0800 | [diff] [blame] | 798 | |
| 799 | /** |
| 800 | * Sets all of the transform-related values of the display list |
| 801 | * |
| 802 | * @param alpha The alpha value of the display list |
| 803 | * @param translationX The translationX value of the display list |
| 804 | * @param translationY The translationY value of the display list |
| 805 | * @param rotation The rotation value of the display list |
| 806 | * @param rotationX The rotationX value of the display list |
| 807 | * @param rotationY The rotationY value of the display list |
| 808 | * @param scaleX The scaleX value of the display list |
| 809 | * @param scaleY The scaleY value of the display list |
| 810 | * |
| 811 | * @hide |
Chet Haase | a1cff50 | 2012-02-21 13:43:44 -0800 | [diff] [blame] | 812 | */ |
Chris Craik | 5438979 | 2013-12-20 13:28:11 -0800 | [diff] [blame] | 813 | public void setTransformationInfo(float alpha, |
Chris Craik | f57776b | 2013-10-25 18:30:17 -0700 | [diff] [blame] | 814 | float translationX, float translationY, float translationZ, |
Chris Craik | 5438979 | 2013-12-20 13:28:11 -0800 | [diff] [blame] | 815 | float rotation, float rotationX, float rotationY, float scaleX, float scaleY) { |
| 816 | if (hasNativeDisplayList()) { |
| 817 | nSetTransformationInfo(mFinalizer.mNativeDisplayList, alpha, |
| 818 | translationX, translationY, translationZ, |
| 819 | rotation, rotationX, rotationY, scaleX, scaleY); |
| 820 | } |
| 821 | } |
Chet Haase | a1cff50 | 2012-02-21 13:43:44 -0800 | [diff] [blame] | 822 | |
| 823 | /** |
Romain Guy | 52036b1 | 2013-02-14 18:03:37 -0800 | [diff] [blame] | 824 | * Sets the pivot value for the display list on the X axis |
Chet Haase | a1cff50 | 2012-02-21 13:43:44 -0800 | [diff] [blame] | 825 | * |
Romain Guy | 52036b1 | 2013-02-14 18:03:37 -0800 | [diff] [blame] | 826 | * @param pivotX The pivot value of the display list on the X axis, in pixels |
| 827 | * |
Chet Haase | a1cff50 | 2012-02-21 13:43:44 -0800 | [diff] [blame] | 828 | * @see View#setPivotX(float) |
Romain Guy | 52036b1 | 2013-02-14 18:03:37 -0800 | [diff] [blame] | 829 | * @see #getPivotX() |
Chet Haase | a1cff50 | 2012-02-21 13:43:44 -0800 | [diff] [blame] | 830 | */ |
Chris Craik | 5438979 | 2013-12-20 13:28:11 -0800 | [diff] [blame] | 831 | public void setPivotX(float pivotX) { |
| 832 | if (hasNativeDisplayList()) { |
| 833 | nSetPivotX(mFinalizer.mNativeDisplayList, pivotX); |
| 834 | } |
| 835 | } |
Chet Haase | a1cff50 | 2012-02-21 13:43:44 -0800 | [diff] [blame] | 836 | |
| 837 | /** |
Romain Guy | 52036b1 | 2013-02-14 18:03:37 -0800 | [diff] [blame] | 838 | * Returns the pivot value for this display list on the X axis, in pixels. |
Chet Haase | a1cff50 | 2012-02-21 13:43:44 -0800 | [diff] [blame] | 839 | * |
Romain Guy | 52036b1 | 2013-02-14 18:03:37 -0800 | [diff] [blame] | 840 | * @see #setPivotX(float) |
| 841 | */ |
Chris Craik | 5438979 | 2013-12-20 13:28:11 -0800 | [diff] [blame] | 842 | public float getPivotX() { |
| 843 | if (hasNativeDisplayList()) { |
| 844 | return nGetPivotX(mFinalizer.mNativeDisplayList); |
| 845 | } |
| 846 | return 0.0f; |
| 847 | } |
Romain Guy | 52036b1 | 2013-02-14 18:03:37 -0800 | [diff] [blame] | 848 | |
| 849 | /** |
| 850 | * Sets the pivot value for the display list on the Y axis |
| 851 | * |
| 852 | * @param pivotY The pivot value of the display list on the Y axis, in pixels |
| 853 | * |
Chet Haase | a1cff50 | 2012-02-21 13:43:44 -0800 | [diff] [blame] | 854 | * @see View#setPivotY(float) |
Romain Guy | 52036b1 | 2013-02-14 18:03:37 -0800 | [diff] [blame] | 855 | * @see #getPivotY() |
Chet Haase | a1cff50 | 2012-02-21 13:43:44 -0800 | [diff] [blame] | 856 | */ |
Chris Craik | 5438979 | 2013-12-20 13:28:11 -0800 | [diff] [blame] | 857 | public void setPivotY(float pivotY) { |
| 858 | if (hasNativeDisplayList()) { |
| 859 | nSetPivotY(mFinalizer.mNativeDisplayList, pivotY); |
| 860 | } |
| 861 | } |
Chet Haase | a1cff50 | 2012-02-21 13:43:44 -0800 | [diff] [blame] | 862 | |
| 863 | /** |
Romain Guy | 52036b1 | 2013-02-14 18:03:37 -0800 | [diff] [blame] | 864 | * Returns the pivot value for this display list on the Y axis, in pixels. |
Chet Haase | a1cff50 | 2012-02-21 13:43:44 -0800 | [diff] [blame] | 865 | * |
Romain Guy | 52036b1 | 2013-02-14 18:03:37 -0800 | [diff] [blame] | 866 | * @see #setPivotY(float) |
| 867 | */ |
Chris Craik | 5438979 | 2013-12-20 13:28:11 -0800 | [diff] [blame] | 868 | public float getPivotY() { |
| 869 | if (hasNativeDisplayList()) { |
| 870 | return nGetPivotY(mFinalizer.mNativeDisplayList); |
| 871 | } |
| 872 | return 0.0f; |
| 873 | } |
Romain Guy | 52036b1 | 2013-02-14 18:03:37 -0800 | [diff] [blame] | 874 | |
| 875 | /** |
| 876 | * Sets the camera distance for the display list. Refer to |
| 877 | * {@link View#setCameraDistance(float)} for more information on how to |
| 878 | * use this property. |
| 879 | * |
| 880 | * @param distance The distance in Z of the camera of the display list |
| 881 | * |
Chet Haase | a1cff50 | 2012-02-21 13:43:44 -0800 | [diff] [blame] | 882 | * @see View#setCameraDistance(float) |
Romain Guy | 52036b1 | 2013-02-14 18:03:37 -0800 | [diff] [blame] | 883 | * @see #getCameraDistance() |
Chet Haase | a1cff50 | 2012-02-21 13:43:44 -0800 | [diff] [blame] | 884 | */ |
Chris Craik | 5438979 | 2013-12-20 13:28:11 -0800 | [diff] [blame] | 885 | public void setCameraDistance(float distance) { |
| 886 | if (hasNativeDisplayList()) { |
| 887 | nSetCameraDistance(mFinalizer.mNativeDisplayList, distance); |
| 888 | } |
| 889 | } |
Chet Haase | a1cff50 | 2012-02-21 13:43:44 -0800 | [diff] [blame] | 890 | |
| 891 | /** |
Romain Guy | 52036b1 | 2013-02-14 18:03:37 -0800 | [diff] [blame] | 892 | * Returns the distance in Z of the camera of the display list. |
Chet Haase | a1cff50 | 2012-02-21 13:43:44 -0800 | [diff] [blame] | 893 | * |
Romain Guy | 52036b1 | 2013-02-14 18:03:37 -0800 | [diff] [blame] | 894 | * @see #setCameraDistance(float) |
| 895 | */ |
Chris Craik | 5438979 | 2013-12-20 13:28:11 -0800 | [diff] [blame] | 896 | public float getCameraDistance() { |
| 897 | if (hasNativeDisplayList()) { |
| 898 | return nGetCameraDistance(mFinalizer.mNativeDisplayList); |
| 899 | } |
| 900 | return 0.0f; |
| 901 | } |
Romain Guy | 52036b1 | 2013-02-14 18:03:37 -0800 | [diff] [blame] | 902 | |
| 903 | /** |
| 904 | * Sets the left position for the display list. |
| 905 | * |
| 906 | * @param left The left position, in pixels, of the display list |
| 907 | * |
Chet Haase | a1cff50 | 2012-02-21 13:43:44 -0800 | [diff] [blame] | 908 | * @see View#setLeft(int) |
Romain Guy | 52036b1 | 2013-02-14 18:03:37 -0800 | [diff] [blame] | 909 | * @see #getLeft() |
Chet Haase | a1cff50 | 2012-02-21 13:43:44 -0800 | [diff] [blame] | 910 | */ |
Chris Craik | 5438979 | 2013-12-20 13:28:11 -0800 | [diff] [blame] | 911 | public void setLeft(int left) { |
| 912 | if (hasNativeDisplayList()) { |
| 913 | nSetLeft(mFinalizer.mNativeDisplayList, left); |
| 914 | } |
| 915 | } |
Chet Haase | a1cff50 | 2012-02-21 13:43:44 -0800 | [diff] [blame] | 916 | |
| 917 | /** |
Romain Guy | 52036b1 | 2013-02-14 18:03:37 -0800 | [diff] [blame] | 918 | * Returns the left position for the display list in pixels. |
Chet Haase | a1cff50 | 2012-02-21 13:43:44 -0800 | [diff] [blame] | 919 | * |
Romain Guy | 52036b1 | 2013-02-14 18:03:37 -0800 | [diff] [blame] | 920 | * @see #setLeft(int) |
| 921 | */ |
Chris Craik | 5438979 | 2013-12-20 13:28:11 -0800 | [diff] [blame] | 922 | public float getLeft() { |
| 923 | if (hasNativeDisplayList()) { |
| 924 | return nGetLeft(mFinalizer.mNativeDisplayList); |
| 925 | } |
| 926 | return 0.0f; |
| 927 | } |
Romain Guy | 52036b1 | 2013-02-14 18:03:37 -0800 | [diff] [blame] | 928 | |
| 929 | /** |
| 930 | * Sets the top position for the display list. |
| 931 | * |
| 932 | * @param top The top position, in pixels, of the display list |
| 933 | * |
Chet Haase | a1cff50 | 2012-02-21 13:43:44 -0800 | [diff] [blame] | 934 | * @see View#setTop(int) |
Romain Guy | 52036b1 | 2013-02-14 18:03:37 -0800 | [diff] [blame] | 935 | * @see #getTop() |
Chet Haase | a1cff50 | 2012-02-21 13:43:44 -0800 | [diff] [blame] | 936 | */ |
Chris Craik | 5438979 | 2013-12-20 13:28:11 -0800 | [diff] [blame] | 937 | public void setTop(int top) { |
| 938 | if (hasNativeDisplayList()) { |
| 939 | nSetTop(mFinalizer.mNativeDisplayList, top); |
| 940 | } |
| 941 | } |
Chet Haase | a1cff50 | 2012-02-21 13:43:44 -0800 | [diff] [blame] | 942 | |
| 943 | /** |
Romain Guy | 52036b1 | 2013-02-14 18:03:37 -0800 | [diff] [blame] | 944 | * Returns the top position for the display list in pixels. |
Chet Haase | a1cff50 | 2012-02-21 13:43:44 -0800 | [diff] [blame] | 945 | * |
Romain Guy | 52036b1 | 2013-02-14 18:03:37 -0800 | [diff] [blame] | 946 | * @see #setTop(int) |
| 947 | */ |
Chris Craik | 5438979 | 2013-12-20 13:28:11 -0800 | [diff] [blame] | 948 | public float getTop() { |
| 949 | if (hasNativeDisplayList()) { |
| 950 | return nGetTop(mFinalizer.mNativeDisplayList); |
| 951 | } |
| 952 | return 0.0f; |
| 953 | } |
Romain Guy | 52036b1 | 2013-02-14 18:03:37 -0800 | [diff] [blame] | 954 | |
| 955 | /** |
| 956 | * Sets the right position for the display list. |
| 957 | * |
| 958 | * @param right The right position, in pixels, of the display list |
| 959 | * |
Chet Haase | a1cff50 | 2012-02-21 13:43:44 -0800 | [diff] [blame] | 960 | * @see View#setRight(int) |
Romain Guy | 52036b1 | 2013-02-14 18:03:37 -0800 | [diff] [blame] | 961 | * @see #getRight() |
Chet Haase | a1cff50 | 2012-02-21 13:43:44 -0800 | [diff] [blame] | 962 | */ |
Chris Craik | 5438979 | 2013-12-20 13:28:11 -0800 | [diff] [blame] | 963 | public void setRight(int right) { |
| 964 | if (hasNativeDisplayList()) { |
| 965 | nSetRight(mFinalizer.mNativeDisplayList, right); |
| 966 | } |
| 967 | } |
Chet Haase | a1cff50 | 2012-02-21 13:43:44 -0800 | [diff] [blame] | 968 | |
| 969 | /** |
Romain Guy | 52036b1 | 2013-02-14 18:03:37 -0800 | [diff] [blame] | 970 | * Returns the right position for the display list in pixels. |
Chet Haase | a1cff50 | 2012-02-21 13:43:44 -0800 | [diff] [blame] | 971 | * |
Romain Guy | 52036b1 | 2013-02-14 18:03:37 -0800 | [diff] [blame] | 972 | * @see #setRight(int) |
| 973 | */ |
Chris Craik | 5438979 | 2013-12-20 13:28:11 -0800 | [diff] [blame] | 974 | public float getRight() { |
| 975 | if (hasNativeDisplayList()) { |
| 976 | return nGetRight(mFinalizer.mNativeDisplayList); |
| 977 | } |
| 978 | return 0.0f; |
| 979 | } |
Romain Guy | 52036b1 | 2013-02-14 18:03:37 -0800 | [diff] [blame] | 980 | |
| 981 | /** |
| 982 | * Sets the bottom position for the display list. |
| 983 | * |
| 984 | * @param bottom The bottom position, in pixels, of the display list |
| 985 | * |
Chet Haase | a1cff50 | 2012-02-21 13:43:44 -0800 | [diff] [blame] | 986 | * @see View#setBottom(int) |
Romain Guy | 52036b1 | 2013-02-14 18:03:37 -0800 | [diff] [blame] | 987 | * @see #getBottom() |
Chet Haase | a1cff50 | 2012-02-21 13:43:44 -0800 | [diff] [blame] | 988 | */ |
Chris Craik | 5438979 | 2013-12-20 13:28:11 -0800 | [diff] [blame] | 989 | public void setBottom(int bottom) { |
| 990 | if (hasNativeDisplayList()) { |
| 991 | nSetBottom(mFinalizer.mNativeDisplayList, bottom); |
| 992 | } |
| 993 | } |
Chet Haase | a1cff50 | 2012-02-21 13:43:44 -0800 | [diff] [blame] | 994 | |
| 995 | /** |
Romain Guy | 52036b1 | 2013-02-14 18:03:37 -0800 | [diff] [blame] | 996 | * Returns the bottom position for the display list in pixels. |
Chet Haase | a1cff50 | 2012-02-21 13:43:44 -0800 | [diff] [blame] | 997 | * |
Romain Guy | 52036b1 | 2013-02-14 18:03:37 -0800 | [diff] [blame] | 998 | * @see #setBottom(int) |
Chet Haase | a1cff50 | 2012-02-21 13:43:44 -0800 | [diff] [blame] | 999 | */ |
Chris Craik | 5438979 | 2013-12-20 13:28:11 -0800 | [diff] [blame] | 1000 | public float getBottom() { |
| 1001 | if (hasNativeDisplayList()) { |
| 1002 | return nGetBottom(mFinalizer.mNativeDisplayList); |
| 1003 | } |
| 1004 | return 0.0f; |
| 1005 | } |
Chet Haase | a1cff50 | 2012-02-21 13:43:44 -0800 | [diff] [blame] | 1006 | |
| 1007 | /** |
Romain Guy | 52036b1 | 2013-02-14 18:03:37 -0800 | [diff] [blame] | 1008 | * Sets the left and top positions for the display list |
Chet Haase | a1cff50 | 2012-02-21 13:43:44 -0800 | [diff] [blame] | 1009 | * |
Romain Guy | 52036b1 | 2013-02-14 18:03:37 -0800 | [diff] [blame] | 1010 | * @param left The left position of the display list, in pixels |
| 1011 | * @param top The top position of the display list, in pixels |
| 1012 | * @param right The right position of the display list, in pixels |
| 1013 | * @param bottom The bottom position of the display list, in pixels |
| 1014 | * |
Chet Haase | a1cff50 | 2012-02-21 13:43:44 -0800 | [diff] [blame] | 1015 | * @see View#setLeft(int) |
| 1016 | * @see View#setTop(int) |
Romain Guy | 52036b1 | 2013-02-14 18:03:37 -0800 | [diff] [blame] | 1017 | * @see View#setRight(int) |
| 1018 | * @see View#setBottom(int) |
Chet Haase | a1cff50 | 2012-02-21 13:43:44 -0800 | [diff] [blame] | 1019 | */ |
Chris Craik | 5438979 | 2013-12-20 13:28:11 -0800 | [diff] [blame] | 1020 | public void setLeftTopRightBottom(int left, int top, int right, int bottom) { |
| 1021 | if (hasNativeDisplayList()) { |
| 1022 | nSetLeftTopRightBottom(mFinalizer.mNativeDisplayList, left, top, right, bottom); |
| 1023 | } |
| 1024 | } |
Chet Haase | a1cff50 | 2012-02-21 13:43:44 -0800 | [diff] [blame] | 1025 | |
| 1026 | /** |
Romain Guy | 52036b1 | 2013-02-14 18:03:37 -0800 | [diff] [blame] | 1027 | * Offsets the left and right positions for the display list |
Chet Haase | a1cff50 | 2012-02-21 13:43:44 -0800 | [diff] [blame] | 1028 | * |
Romain Guy | 52036b1 | 2013-02-14 18:03:37 -0800 | [diff] [blame] | 1029 | * @param offset The amount that the left and right positions of the display |
| 1030 | * list are offset, in pixels |
| 1031 | * |
Chet Haase | a1cff50 | 2012-02-21 13:43:44 -0800 | [diff] [blame] | 1032 | * @see View#offsetLeftAndRight(int) |
| 1033 | */ |
Chris Craik | 5438979 | 2013-12-20 13:28:11 -0800 | [diff] [blame] | 1034 | public void offsetLeftAndRight(float offset) { |
| 1035 | if (hasNativeDisplayList()) { |
| 1036 | nOffsetLeftAndRight(mFinalizer.mNativeDisplayList, offset); |
| 1037 | } |
| 1038 | } |
Chet Haase | a1cff50 | 2012-02-21 13:43:44 -0800 | [diff] [blame] | 1039 | |
| 1040 | /** |
Romain Guy | 52036b1 | 2013-02-14 18:03:37 -0800 | [diff] [blame] | 1041 | * Offsets the top and bottom values for the display list |
Chet Haase | a1cff50 | 2012-02-21 13:43:44 -0800 | [diff] [blame] | 1042 | * |
Romain Guy | 52036b1 | 2013-02-14 18:03:37 -0800 | [diff] [blame] | 1043 | * @param offset The amount that the top and bottom positions of the display |
| 1044 | * list are offset, in pixels |
| 1045 | * |
Chet Haase | a1cff50 | 2012-02-21 13:43:44 -0800 | [diff] [blame] | 1046 | * @see View#offsetTopAndBottom(int) |
| 1047 | */ |
Chris Craik | 5438979 | 2013-12-20 13:28:11 -0800 | [diff] [blame] | 1048 | public void offsetTopAndBottom(float offset) { |
| 1049 | if (hasNativeDisplayList()) { |
| 1050 | nOffsetTopAndBottom(mFinalizer.mNativeDisplayList, offset); |
| 1051 | } |
| 1052 | } |
John Reck | 6304919 | 2013-12-10 15:22:01 -0800 | [diff] [blame] | 1053 | |
| 1054 | /** |
| 1055 | * Outputs the display list to the log. This method exists for use by |
| 1056 | * tools to output display lists for selected nodes to the log. |
| 1057 | * |
| 1058 | * @hide |
| 1059 | */ |
Chris Craik | 5438979 | 2013-12-20 13:28:11 -0800 | [diff] [blame] | 1060 | public void output() { |
| 1061 | if (hasNativeDisplayList()) { |
| 1062 | nOutput(mFinalizer.mNativeDisplayList); |
| 1063 | } |
| 1064 | } |
| 1065 | |
| 1066 | /////////////////////////////////////////////////////////////////////////// |
| 1067 | // Native methods |
| 1068 | /////////////////////////////////////////////////////////////////////////// |
| 1069 | |
Ashok Bhat | 36bef0b | 2014-01-20 20:08:01 +0000 | [diff] [blame] | 1070 | private static native void nDestroyDisplayList(long displayList); |
| 1071 | private static native int nGetDisplayListSize(long displayList); |
| 1072 | private static native void nSetDisplayListName(long displayList, String name); |
Chris Craik | 5438979 | 2013-12-20 13:28:11 -0800 | [diff] [blame] | 1073 | |
| 1074 | // Properties |
| 1075 | |
Ashok Bhat | 36bef0b | 2014-01-20 20:08:01 +0000 | [diff] [blame] | 1076 | private static native void nReset(long displayList); |
| 1077 | private static native void nOffsetTopAndBottom(long displayList, float offset); |
| 1078 | private static native void nOffsetLeftAndRight(long displayList, float offset); |
| 1079 | private static native void nSetLeftTopRightBottom(long displayList, int left, int top, |
Chris Craik | 5438979 | 2013-12-20 13:28:11 -0800 | [diff] [blame] | 1080 | int right, int bottom); |
Ashok Bhat | 36bef0b | 2014-01-20 20:08:01 +0000 | [diff] [blame] | 1081 | private static native void nSetBottom(long displayList, int bottom); |
| 1082 | private static native void nSetRight(long displayList, int right); |
| 1083 | private static native void nSetTop(long displayList, int top); |
| 1084 | private static native void nSetLeft(long displayList, int left); |
| 1085 | private static native void nSetCameraDistance(long displayList, float distance); |
| 1086 | private static native void nSetPivotY(long displayList, float pivotY); |
| 1087 | private static native void nSetPivotX(long displayList, float pivotX); |
| 1088 | private static native void nSetCaching(long displayList, boolean caching); |
| 1089 | private static native void nSetClipToBounds(long displayList, boolean clipToBounds); |
Chris Craik | 6657a6c | 2014-01-26 11:30:58 -0800 | [diff] [blame] | 1090 | private static native void nSetProjectBackwards(long displayList, boolean shouldProject); |
Chris Craik | 1df2644 | 2014-02-05 16:50:41 -0800 | [diff] [blame] | 1091 | private static native void nSetProjectionReceiver(long displayList, boolean shouldRecieve); |
Chris Craik | 6657a6c | 2014-01-26 11:30:58 -0800 | [diff] [blame] | 1092 | private static native void nSetIsolatedZVolume(long displayList, boolean isolateZVolume); |
Chris Craik | a2fe7af | 2014-01-28 17:25:06 -0800 | [diff] [blame] | 1093 | private static native void nSetOutline(long displayList, long nativePath); |
ztenghui | fad4593 | 2014-02-06 10:33:58 -0800 | [diff] [blame] | 1094 | private static native void nSetClipToOutline(long displayList, boolean clipToOutline); |
Ashok Bhat | 36bef0b | 2014-01-20 20:08:01 +0000 | [diff] [blame] | 1095 | private static native void nSetAlpha(long displayList, float alpha); |
| 1096 | private static native void nSetHasOverlappingRendering(long displayList, |
Chris Craik | 5438979 | 2013-12-20 13:28:11 -0800 | [diff] [blame] | 1097 | boolean hasOverlappingRendering); |
Ashok Bhat | 36bef0b | 2014-01-20 20:08:01 +0000 | [diff] [blame] | 1098 | private static native void nSetTranslationX(long displayList, float translationX); |
| 1099 | private static native void nSetTranslationY(long displayList, float translationY); |
| 1100 | private static native void nSetTranslationZ(long displayList, float translationZ); |
| 1101 | private static native void nSetRotation(long displayList, float rotation); |
| 1102 | private static native void nSetRotationX(long displayList, float rotationX); |
| 1103 | private static native void nSetRotationY(long displayList, float rotationY); |
| 1104 | private static native void nSetScaleX(long displayList, float scaleX); |
| 1105 | private static native void nSetScaleY(long displayList, float scaleY); |
| 1106 | private static native void nSetTransformationInfo(long displayList, float alpha, |
Chris Craik | 5438979 | 2013-12-20 13:28:11 -0800 | [diff] [blame] | 1107 | float translationX, float translationY, float translationZ, |
| 1108 | float rotation, float rotationX, float rotationY, float scaleX, float scaleY); |
Ashok Bhat | 36bef0b | 2014-01-20 20:08:01 +0000 | [diff] [blame] | 1109 | private static native void nSetStaticMatrix(long displayList, long nativeMatrix); |
| 1110 | private static native void nSetAnimationMatrix(long displayList, long animationMatrix); |
Chris Craik | 5438979 | 2013-12-20 13:28:11 -0800 | [diff] [blame] | 1111 | |
Ashok Bhat | 36bef0b | 2014-01-20 20:08:01 +0000 | [diff] [blame] | 1112 | private static native boolean nHasOverlappingRendering(long displayList); |
| 1113 | private static native void nGetMatrix(long displayList, long matrix); |
| 1114 | private static native float nGetAlpha(long displayList); |
| 1115 | private static native float nGetLeft(long displayList); |
| 1116 | private static native float nGetTop(long displayList); |
| 1117 | private static native float nGetRight(long displayList); |
| 1118 | private static native float nGetBottom(long displayList); |
| 1119 | private static native float nGetCameraDistance(long displayList); |
| 1120 | private static native float nGetScaleX(long displayList); |
| 1121 | private static native float nGetScaleY(long displayList); |
| 1122 | private static native float nGetTranslationX(long displayList); |
| 1123 | private static native float nGetTranslationY(long displayList); |
| 1124 | private static native float nGetTranslationZ(long displayList); |
| 1125 | private static native float nGetRotation(long displayList); |
| 1126 | private static native float nGetRotationX(long displayList); |
| 1127 | private static native float nGetRotationY(long displayList); |
| 1128 | private static native float nGetPivotX(long displayList); |
| 1129 | private static native float nGetPivotY(long displayList); |
| 1130 | private static native void nOutput(long displayList); |
Chris Craik | 5438979 | 2013-12-20 13:28:11 -0800 | [diff] [blame] | 1131 | |
| 1132 | /////////////////////////////////////////////////////////////////////////// |
| 1133 | // Finalization |
| 1134 | /////////////////////////////////////////////////////////////////////////// |
| 1135 | |
| 1136 | private static class DisplayListFinalizer { |
Ashok Bhat | 36bef0b | 2014-01-20 20:08:01 +0000 | [diff] [blame] | 1137 | final long mNativeDisplayList; |
Chris Craik | 5438979 | 2013-12-20 13:28:11 -0800 | [diff] [blame] | 1138 | |
Ashok Bhat | 36bef0b | 2014-01-20 20:08:01 +0000 | [diff] [blame] | 1139 | public DisplayListFinalizer(long nativeDisplayList) { |
Chris Craik | 5438979 | 2013-12-20 13:28:11 -0800 | [diff] [blame] | 1140 | mNativeDisplayList = nativeDisplayList; |
| 1141 | } |
| 1142 | |
| 1143 | @Override |
| 1144 | protected void finalize() throws Throwable { |
| 1145 | try { |
| 1146 | nDestroyDisplayList(mNativeDisplayList); |
| 1147 | } finally { |
| 1148 | super.finalize(); |
| 1149 | } |
| 1150 | } |
| 1151 | } |
Romain Guy | b051e89 | 2010-09-28 19:09:36 -0700 | [diff] [blame] | 1152 | } |