blob: a96d46ce7ddeaa11a4c76a362b9ae081b57aa650 [file] [log] [blame]
Romain Guyb051e892010-09-28 19:09:36 -07001/*
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
17package android.view;
18
Chet Haase9420abd2012-03-29 16:28:32 -070019import android.graphics.Matrix;
Chris Craika2fe7af2014-01-28 17:25:06 -080020import android.graphics.Path;
Chet Haase9420abd2012-03-29 16:28:32 -070021
Chris Craik54389792013-12-20 13:28:11 -080022import java.util.ArrayList;
23
Romain Guyb051e892010-09-28 19:09:36 -070024/**
Romain Guy52036b12013-02-14 18:03:37 -080025 * <p>A display list records a series of graphics related operations and can replay
Romain Guyb051e892010-09-28 19:09:36 -070026 * them later. Display lists are usually built by recording operations on a
Romain Guy52036b12013-02-14 18:03:37 -080027 * {@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 Haasedaf98e92011-01-10 14:10:36 -080029 *
Romain Guy52036b12013-02-14 18:03:37 -080030 * <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 Guy52036b12013-02-14 18:03:37 -080066 * 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 Reck30835792013-11-07 14:21:24 -080092 * 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 Guy52036b12013-02-14 18:03:37 -080098 * }
John Reck30835792013-11-07 14:21:24 -080099 * } finally {
100 * displayList.end();
Romain Guy52036b12013-02-14 18:03:37 -0800101 * }
102 * }
103 *
Romain Guy52036b12013-02-14 18:03:37 -0800104 * 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 Guyb051e892010-09-28 19:09:36 -0700125 */
Chris Craik54389792013-12-20 13:28:11 -0800126public class DisplayList {
Romain Guyfbb93fa2012-12-03 18:50:35 -0800127 private boolean mDirty;
Chris Craik54389792013-12-20 13:28:11 -0800128 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 Guyfbb93fa2012-12-03 18:50:35 -0800139
Romain Guyb051e892010-09-28 19:09:36 -0700140 /**
Romain Guy33f6beb2012-02-16 19:24:51 -0800141 * Flag used when calling
Chris Craik54389792013-12-20 13:28:11 -0800142 * {@link HardwareCanvas#drawDisplayList(DisplayList, android.graphics.Rect, int)}
Romain Guy33f6beb2012-02-16 19:24:51 -0800143 * 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 Guy52036b12013-02-14 18:03:37 -0800146 *
147 * @hide
Romain Guy33f6beb2012-02-16 19:24:51 -0800148 */
149 public static final int FLAG_CLIP_CHILDREN = 0x1;
150
Romain Guy65549432012-03-26 16:45:05 -0700151 // NOTE: The STATUS_* values *must* match the enum in DrawGlInfo.h
152
153 /**
154 * Indicates that the display list is done drawing.
Chris Craika2fe7af2014-01-28 17:25:06 -0800155 *
Romain Guy52036b12013-02-14 18:03:37 -0800156 * @see HardwareCanvas#drawDisplayList(DisplayList, android.graphics.Rect, int)
157 *
158 * @hide
Romain Guy65549432012-03-26 16:45:05 -0700159 */
160 public static final int STATUS_DONE = 0x0;
161
162 /**
163 * Indicates that the display list needs another drawing pass.
Chris Craika2fe7af2014-01-28 17:25:06 -0800164 *
Romain Guy52036b12013-02-14 18:03:37 -0800165 * @see HardwareCanvas#drawDisplayList(DisplayList, android.graphics.Rect, int)
166 *
167 * @hide
Romain Guy65549432012-03-26 16:45:05 -0700168 */
Romain Guyc553fea2012-03-26 17:09:19 -0700169 public static final int STATUS_DRAW = 0x1;
Romain Guy65549432012-03-26 16:45:05 -0700170
171 /**
172 * Indicates that the display list needs to re-execute its GL functors.
Chris Craika2fe7af2014-01-28 17:25:06 -0800173 *
174 * @see HardwareCanvas#drawDisplayList(DisplayList, android.graphics.Rect, int)
175 * @see HardwareCanvas#callDrawGLFunction(long)
Romain Guy52036b12013-02-14 18:03:37 -0800176 *
177 * @hide
Romain Guy65549432012-03-26 16:45:05 -0700178 */
179 public static final int STATUS_INVOKE = 0x2;
180
Romain Guy33f6beb2012-02-16 19:24:51 -0800181 /**
Chet Haase48659092012-05-31 15:21:51 -0700182 * Indicates that the display list performed GL drawing operations.
183 *
184 * @see HardwareCanvas#drawDisplayList(DisplayList, android.graphics.Rect, int)
Romain Guy52036b12013-02-14 18:03:37 -0800185 *
186 * @hide
Chet Haase48659092012-05-31 15:21:51 -0700187 */
188 public static final int STATUS_DREW = 0x4;
189
Chris Craik54389792013-12-20 13:28:11 -0800190 private DisplayList(String name) {
191 mName = name;
192 }
193
Chet Haase48659092012-05-31 15:21:51 -0700194 /**
John Reck339f9012013-11-06 14:51:13 -0800195 * 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 Craik54389792013-12-20 13:28:11 -0800205 return new DisplayList(name);
John Reck339f9012013-11-06 14:51:13 -0800206 }
207
208 /**
Romain Guyb051e892010-09-28 19:09:36 -0700209 * Starts recording the display list. All operations performed on the
210 * returned canvas are recorded and stored in this display list.
Romain Guy52036b12013-02-14 18:03:37 -0800211 *
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 Guyb051e892010-09-28 19:09:36 -0700218 * @return A canvas to record drawing operations.
Romain Guy52036b12013-02-14 18:03:37 -0800219 *
220 * @see #end()
221 * @see #isValid()
Romain Guyb051e892010-09-28 19:09:36 -0700222 */
Chris Craik54389792013-12-20 13:28:11 -0800223 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 Guyb051e892010-09-28 19:09:36 -0700238
239 /**
240 * Ends the recording for this display list. A display list cannot be
Romain Guy52036b12013-02-14 18:03:37 -0800241 * 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 Guyb051e892010-09-28 19:09:36 -0700246 */
Chris Craik54389792013-12-20 13:28:11 -0800247 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 Guyb051e892010-09-28 19:09:36 -0700261
262 /**
Romain Guy52036b12013-02-14 18:03:37 -0800263 * Clears resources held onto by this display list. After calling this method
264 * {@link #isValid()} will return false.
265 *
266 * @see #isValid()
Romain Guy46bfc482013-08-16 18:38:29 -0700267 * @see #reset()
Romain Guy38c2ece2012-05-24 14:20:56 -0700268 */
Chris Craik54389792013-12-20 13:28:11 -0800269 public void clear() {
270 clearDirty();
Romain Guy38c2ece2012-05-24 14:20:56 -0700271
Chris Craik54389792013-12-20 13:28:11 -0800272 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 Guy46bfc482013-08-16 18:38:29 -0700289
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 Craik54389792013-12-20 13:28:11 -0800299 public void reset() {
300 if (hasNativeDisplayList()) {
301 nReset(mFinalizer.mNativeDisplayList);
302 }
303 clear();
304 }
Romain Guy46bfc482013-08-16 18:38:29 -0700305
Romain Guy38c2ece2012-05-24 14:20:56 -0700306 /**
Romain Guy52036b12013-02-14 18:03:37 -0800307 * Sets the dirty flag. When a display list is dirty, {@link #clear()} should
308 * be invoked whenever possible.
Romain Guyfbb93fa2012-12-03 18:50:35 -0800309 *
310 * @see #isDirty()
Romain Guy52036b12013-02-14 18:03:37 -0800311 * @see #clear()
312 *
313 * @hide
Romain Guyfbb93fa2012-12-03 18:50:35 -0800314 */
Romain Guy52036b12013-02-14 18:03:37 -0800315 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 Guyfbb93fa2012-12-03 18:50:35 -0800330 }
331
332 /**
333 * Indicates whether the display list is dirty.
334 *
Romain Guy52036b12013-02-14 18:03:37 -0800335 * @see #markDirty()
336 * @see #clear()
337 *
338 * @hide
Romain Guyfbb93fa2012-12-03 18:50:35 -0800339 */
340 public boolean isDirty() {
341 return mDirty;
342 }
343
344 /**
Chet Haase9e90a992011-01-04 16:23:21 -0800345 * 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 Craik54389792013-12-20 13:28:11 -0800350 public boolean isValid() { return mValid; }
Romain Guy65b345f2011-07-27 18:51:50 -0700351
352 /**
353 * Return the amount of memory used by this display list.
Chris Craik54389792013-12-20 13:28:11 -0800354 *
Romain Guy65b345f2011-07-27 18:51:50 -0700355 * @return The size of this display list in bytes
Romain Guy52036b12013-02-14 18:03:37 -0800356 *
357 * @hide
Romain Guy65b345f2011-07-27 18:51:50 -0700358 */
Chris Craik54389792013-12-20 13:28:11 -0800359 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 Bhat36bef0b2014-01-20 20:08:01 +0000368 long getNativeDisplayList() {
Chris Craik54389792013-12-20 13:28:11 -0800369 if (!mValid || mFinalizer == null) {
370 throw new IllegalStateException("The display list is not valid.");
371 }
372 return mFinalizer.mNativeDisplayList;
373 }
Chet Haasea1cff502012-02-21 13:43:44 -0800374
375 ///////////////////////////////////////////////////////////////////////////
376 // DisplayList Property Setters
377 ///////////////////////////////////////////////////////////////////////////
378
379 /**
Romain Guy52036b12013-02-14 18:03:37 -0800380 * 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 Haasea1cff502012-02-21 13:43:44 -0800382 * handled in the drawLayer operation directly (and more efficiently).
383 *
Romain Guy52036b12013-02-14 18:03:37 -0800384 * @param caching true if the display list represents a hardware layer, false otherwise.
385 *
386 * @hide
Chet Haasea1cff502012-02-21 13:43:44 -0800387 */
Chris Craik54389792013-12-20 13:28:11 -0800388 public void setCaching(boolean caching) {
389 if (hasNativeDisplayList()) {
390 nSetCaching(mFinalizer.mNativeDisplayList, caching);
391 }
392 }
Chet Haasea1cff502012-02-21 13:43:44 -0800393
394 /**
Romain Guy52036b12013-02-14 18:03:37 -0800395 * Set whether the display list should clip itself to its bounds. This property is controlled by
Chet Haasea1cff502012-02-21 13:43:44 -0800396 * the view's parent.
397 *
Chet Haasedd671592013-04-19 14:54:34 -0700398 * @param clipToBounds true if the display list should clip to its bounds
Chet Haasea1cff502012-02-21 13:43:44 -0800399 */
Chris Craik54389792013-12-20 13:28:11 -0800400 public void setClipToBounds(boolean clipToBounds) {
401 if (hasNativeDisplayList()) {
402 nSetClipToBounds(mFinalizer.mNativeDisplayList, clipToBounds);
403 }
404 }
Chet Haasea1cff502012-02-21 13:43:44 -0800405
406 /**
Chris Craikd863a102013-12-19 13:31:15 -0800407 * 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 Craika2fe7af2014-01-28 17:25:06 -0800410 * @param isolatedZVolume true if the display list should collect and Z order descendents.
Chris Craikd863a102013-12-19 13:31:15 -0800411 */
Chris Craik6657a6c2014-01-26 11:30:58 -0800412 public void setIsolatedZVolume(boolean isolatedZVolume) {
Chris Craikd863a102013-12-19 13:31:15 -0800413 if (hasNativeDisplayList()) {
Chris Craik6657a6c2014-01-26 11:30:58 -0800414 nSetIsolatedZVolume(mFinalizer.mNativeDisplayList, isolatedZVolume);
Chris Craikd863a102013-12-19 13:31:15 -0800415 }
416 }
417
418 /**
Alan Viverette58f09b32014-01-08 17:18:19 -0800419 * Sets whether the display list should be drawn immediately after the
Chris Craik6657a6c2014-01-26 11:30:58 -0800420 * closest ancestor display list where isolateZVolume is true. If the
Alan Viverette58f09b32014-01-08 17:18:19 -0800421 * 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 Craik6657a6c2014-01-26 11:30:58 -0800427 public void setProjectBackwards(boolean shouldProject) {
Alan Viverette58f09b32014-01-08 17:18:19 -0800428 if (hasNativeDisplayList()) {
Chris Craik6657a6c2014-01-26 11:30:58 -0800429 nSetProjectBackwards(mFinalizer.mNativeDisplayList, shouldProject);
Alan Viverette58f09b32014-01-08 17:18:19 -0800430 }
431 }
432
433 /**
Chris Craik1df26442014-02-05 16:50:41 -0800434 * 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 /**
ztenghuifad45932014-02-06 10:33:58 -0800445 * Sets the outline, defining the shape that casts a shadow, and the path to
446 * be clipped if setClipToOutline is set.
Chris Craika2fe7af2014-01-28 17:25:06 -0800447 *
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 /**
ztenghuifad45932014-02-06 10:33:58 -0800460 * 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 Guy52036b12013-02-14 18:03:37 -0800471 * 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 Haasea1cff502012-02-21 13:43:44 -0800473 *
Romain Guy52036b12013-02-14 18:03:37 -0800474 * @param matrix A transform matrix to apply to this display list
475 *
476 * @see #getMatrix(android.graphics.Matrix)
477 * @see #getMatrix()
Chet Haasea1cff502012-02-21 13:43:44 -0800478 */
Chris Craik54389792013-12-20 13:28:11 -0800479 public void setMatrix(Matrix matrix) {
480 if (hasNativeDisplayList()) {
481 nSetStaticMatrix(mFinalizer.mNativeDisplayList, matrix.native_instance);
482 }
483 }
Chet Haase9420abd2012-03-29 16:28:32 -0700484
485 /**
Romain Guy52036b12013-02-14 18:03:37 -0800486 * 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 Craik54389792013-12-20 13:28:11 -0800509 public Matrix getMatrix(Matrix matrix) {
510 if (hasNativeDisplayList()) {
511 nGetMatrix(mFinalizer.mNativeDisplayList, matrix.native_instance);
512 }
513 return matrix;
514 }
Romain Guy52036b12013-02-14 18:03:37 -0800515
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 Haase9420abd2012-03-29 16:28:32 -0700519 * 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 Guy52036b12013-02-14 18:03:37 -0800523 *
524 * @hide
Chet Haase9420abd2012-03-29 16:28:32 -0700525 */
Chris Craik54389792013-12-20 13:28:11 -0800526 public void setAnimationMatrix(Matrix matrix) {
527 if (hasNativeDisplayList()) {
528 nSetAnimationMatrix(mFinalizer.mNativeDisplayList,
529 (matrix != null) ? matrix.native_instance : 0);
530 }
531 }
Chet Haasea1cff502012-02-21 13:43:44 -0800532
533 /**
Romain Guy52036b12013-02-14 18:03:37 -0800534 * Sets the translucency level for the display list.
Chet Haasea1cff502012-02-21 13:43:44 -0800535 *
Romain Guy52036b12013-02-14 18:03:37 -0800536 * @param alpha The translucency of the display list, must be a value between 0.0f and 1.0f
537 *
Chet Haasea1cff502012-02-21 13:43:44 -0800538 * @see View#setAlpha(float)
Romain Guy52036b12013-02-14 18:03:37 -0800539 * @see #getAlpha()
Chet Haasea1cff502012-02-21 13:43:44 -0800540 */
Chris Craik54389792013-12-20 13:28:11 -0800541 public void setAlpha(float alpha) {
542 if (hasNativeDisplayList()) {
543 nSetAlpha(mFinalizer.mNativeDisplayList, alpha);
544 }
545 }
Chet Haasea1cff502012-02-21 13:43:44 -0800546
547 /**
Romain Guy52036b12013-02-14 18:03:37 -0800548 * Returns the translucency level of this display list.
Chet Haasedb8c9a62012-03-21 18:54:18 -0700549 *
Romain Guy52036b12013-02-14 18:03:37 -0800550 * @return A value between 0.0f and 1.0f
551 *
552 * @see #setAlpha(float)
553 */
Chris Craik54389792013-12-20 13:28:11 -0800554 public float getAlpha() {
555 if (hasNativeDisplayList()) {
556 return nGetAlpha(mFinalizer.mNativeDisplayList);
557 }
558 return 1.0f;
559 }
Romain Guy52036b12013-02-14 18:03:37 -0800560
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 Haasedb8c9a62012-03-21 18:54:18 -0700569 * @see android.view.View#hasOverlappingRendering()
Romain Guy52036b12013-02-14 18:03:37 -0800570 * @see #hasOverlappingRendering()
Chet Haasedb8c9a62012-03-21 18:54:18 -0700571 */
Chris Craik54389792013-12-20 13:28:11 -0800572 public void setHasOverlappingRendering(boolean hasOverlappingRendering) {
573 if (hasNativeDisplayList()) {
574 nSetHasOverlappingRendering(mFinalizer.mNativeDisplayList, hasOverlappingRendering);
575 }
576 }
Chet Haasedb8c9a62012-03-21 18:54:18 -0700577
578 /**
Romain Guy52036b12013-02-14 18:03:37 -0800579 * Indicates whether the content of this display list overlaps.
Chet Haasea1cff502012-02-21 13:43:44 -0800580 *
Romain Guy52036b12013-02-14 18:03:37 -0800581 * @return True if this display list renders content which overlaps, false otherwise.
582 *
583 * @see #setHasOverlappingRendering(boolean)
584 */
Chris Craik54389792013-12-20 13:28:11 -0800585 public boolean hasOverlappingRendering() {
586 //noinspection SimplifiableIfStatement
587 if (hasNativeDisplayList()) {
588 return nHasOverlappingRendering(mFinalizer.mNativeDisplayList);
589 }
590 return true;
591 }
Romain Guy52036b12013-02-14 18:03:37 -0800592
593 /**
Chris Craikd863a102013-12-19 13:31:15 -0800594 * Sets the translation value for the display list on the X axis.
Romain Guy52036b12013-02-14 18:03:37 -0800595 *
596 * @param translationX The X axis translation value of the display list, in pixels
597 *
Chet Haasea1cff502012-02-21 13:43:44 -0800598 * @see View#setTranslationX(float)
Romain Guy52036b12013-02-14 18:03:37 -0800599 * @see #getTranslationX()
Chet Haasea1cff502012-02-21 13:43:44 -0800600 */
Chris Craik54389792013-12-20 13:28:11 -0800601 public void setTranslationX(float translationX) {
602 if (hasNativeDisplayList()) {
603 nSetTranslationX(mFinalizer.mNativeDisplayList, translationX);
604 }
605 }
Chet Haasea1cff502012-02-21 13:43:44 -0800606
607 /**
Romain Guy52036b12013-02-14 18:03:37 -0800608 * Returns the translation value for this display list on the X axis, in pixels.
Chet Haasea1cff502012-02-21 13:43:44 -0800609 *
Romain Guy52036b12013-02-14 18:03:37 -0800610 * @see #setTranslationX(float)
611 */
Chris Craik54389792013-12-20 13:28:11 -0800612 public float getTranslationX() {
613 if (hasNativeDisplayList()) {
614 return nGetTranslationX(mFinalizer.mNativeDisplayList);
615 }
616 return 0.0f;
617 }
Romain Guy52036b12013-02-14 18:03:37 -0800618
619 /**
Chris Craikd863a102013-12-19 13:31:15 -0800620 * Sets the translation value for the display list on the Y axis.
Romain Guy52036b12013-02-14 18:03:37 -0800621 *
622 * @param translationY The Y axis translation value of the display list, in pixels
623 *
Chet Haasea1cff502012-02-21 13:43:44 -0800624 * @see View#setTranslationY(float)
Romain Guy52036b12013-02-14 18:03:37 -0800625 * @see #getTranslationY()
Chet Haasea1cff502012-02-21 13:43:44 -0800626 */
Chris Craik54389792013-12-20 13:28:11 -0800627 public void setTranslationY(float translationY) {
628 if (hasNativeDisplayList()) {
629 nSetTranslationY(mFinalizer.mNativeDisplayList, translationY);
630 }
631 }
Chet Haasea1cff502012-02-21 13:43:44 -0800632
633 /**
Romain Guy52036b12013-02-14 18:03:37 -0800634 * Returns the translation value for this display list on the Y axis, in pixels.
Chet Haasea1cff502012-02-21 13:43:44 -0800635 *
Romain Guy52036b12013-02-14 18:03:37 -0800636 * @see #setTranslationY(float)
637 */
Chris Craik54389792013-12-20 13:28:11 -0800638 public float getTranslationY() {
639 if (hasNativeDisplayList()) {
640 return nGetTranslationY(mFinalizer.mNativeDisplayList);
641 }
642 return 0.0f;
643 }
Romain Guy52036b12013-02-14 18:03:37 -0800644
645 /**
Chris Craikd863a102013-12-19 13:31:15 -0800646 * Sets the translation value for the display list on the Z axis.
Chris Craikf57776b2013-10-25 18:30:17 -0700647 *
648 * @see View#setTranslationZ(float)
649 * @see #getTranslationZ()
650 */
Chris Craik54389792013-12-20 13:28:11 -0800651 public void setTranslationZ(float translationZ) {
652 if (hasNativeDisplayList()) {
653 nSetTranslationZ(mFinalizer.mNativeDisplayList, translationZ);
654 }
655 }
Chris Craikf57776b2013-10-25 18:30:17 -0700656
657 /**
658 * Returns the translation value for this display list on the Z axis.
659 *
660 * @see #setTranslationZ(float)
661 */
Chris Craik54389792013-12-20 13:28:11 -0800662 public float getTranslationZ() {
663 if (hasNativeDisplayList()) {
664 return nGetTranslationZ(mFinalizer.mNativeDisplayList);
665 }
666 return 0.0f;
667 }
Chris Craikf57776b2013-10-25 18:30:17 -0700668
669 /**
Chris Craikd863a102013-12-19 13:31:15 -0800670 * Sets the rotation value for the display list around the Z axis.
Romain Guy52036b12013-02-14 18:03:37 -0800671 *
672 * @param rotation The rotation value of the display list, in degrees
673 *
Chet Haasea1cff502012-02-21 13:43:44 -0800674 * @see View#setRotation(float)
Romain Guy52036b12013-02-14 18:03:37 -0800675 * @see #getRotation()
Chet Haasea1cff502012-02-21 13:43:44 -0800676 */
Chris Craik54389792013-12-20 13:28:11 -0800677 public void setRotation(float rotation) {
678 if (hasNativeDisplayList()) {
679 nSetRotation(mFinalizer.mNativeDisplayList, rotation);
680 }
681 }
Chet Haasea1cff502012-02-21 13:43:44 -0800682
683 /**
Romain Guy52036b12013-02-14 18:03:37 -0800684 * Returns the rotation value for this display list around the Z axis, in degrees.
Chet Haasea1cff502012-02-21 13:43:44 -0800685 *
Romain Guy52036b12013-02-14 18:03:37 -0800686 * @see #setRotation(float)
687 */
Chris Craik54389792013-12-20 13:28:11 -0800688 public float getRotation() {
689 if (hasNativeDisplayList()) {
690 return nGetRotation(mFinalizer.mNativeDisplayList);
691 }
692 return 0.0f;
693 }
Romain Guy52036b12013-02-14 18:03:37 -0800694
695 /**
Chris Craikd863a102013-12-19 13:31:15 -0800696 * Sets the rotation value for the display list around the X axis.
Romain Guy52036b12013-02-14 18:03:37 -0800697 *
698 * @param rotationX The rotation value of the display list, in degrees
699 *
Chet Haasea1cff502012-02-21 13:43:44 -0800700 * @see View#setRotationX(float)
Romain Guy52036b12013-02-14 18:03:37 -0800701 * @see #getRotationX()
Chet Haasea1cff502012-02-21 13:43:44 -0800702 */
Chris Craik54389792013-12-20 13:28:11 -0800703 public void setRotationX(float rotationX) {
704 if (hasNativeDisplayList()) {
705 nSetRotationX(mFinalizer.mNativeDisplayList, rotationX);
706 }
707 }
Chet Haasea1cff502012-02-21 13:43:44 -0800708
709 /**
Romain Guy52036b12013-02-14 18:03:37 -0800710 * Returns the rotation value for this display list around the X axis, in degrees.
Chet Haasea1cff502012-02-21 13:43:44 -0800711 *
Romain Guy52036b12013-02-14 18:03:37 -0800712 * @see #setRotationX(float)
713 */
Chris Craik54389792013-12-20 13:28:11 -0800714 public float getRotationX() {
715 if (hasNativeDisplayList()) {
716 return nGetRotationX(mFinalizer.mNativeDisplayList);
717 }
718 return 0.0f;
719 }
Romain Guy52036b12013-02-14 18:03:37 -0800720
721 /**
Chris Craikd863a102013-12-19 13:31:15 -0800722 * Sets the rotation value for the display list around the Y axis.
Romain Guy52036b12013-02-14 18:03:37 -0800723 *
724 * @param rotationY The rotation value of the display list, in degrees
725 *
Chet Haasea1cff502012-02-21 13:43:44 -0800726 * @see View#setRotationY(float)
Romain Guy52036b12013-02-14 18:03:37 -0800727 * @see #getRotationY()
Chet Haasea1cff502012-02-21 13:43:44 -0800728 */
Chris Craik54389792013-12-20 13:28:11 -0800729 public void setRotationY(float rotationY) {
730 if (hasNativeDisplayList()) {
731 nSetRotationY(mFinalizer.mNativeDisplayList, rotationY);
732 }
733 }
Chet Haasea1cff502012-02-21 13:43:44 -0800734
735 /**
Romain Guy52036b12013-02-14 18:03:37 -0800736 * Returns the rotation value for this display list around the Y axis, in degrees.
Chet Haasea1cff502012-02-21 13:43:44 -0800737 *
Romain Guy52036b12013-02-14 18:03:37 -0800738 * @see #setRotationY(float)
739 */
Chris Craik54389792013-12-20 13:28:11 -0800740 public float getRotationY() {
741 if (hasNativeDisplayList()) {
742 return nGetRotationY(mFinalizer.mNativeDisplayList);
743 }
744 return 0.0f;
745 }
Romain Guy52036b12013-02-14 18:03:37 -0800746
747 /**
Chris Craikd863a102013-12-19 13:31:15 -0800748 * Sets the scale value for the display list on the X axis.
Romain Guy52036b12013-02-14 18:03:37 -0800749 *
750 * @param scaleX The scale value of the display list
751 *
Chet Haasea1cff502012-02-21 13:43:44 -0800752 * @see View#setScaleX(float)
Romain Guy52036b12013-02-14 18:03:37 -0800753 * @see #getScaleX()
Chet Haasea1cff502012-02-21 13:43:44 -0800754 */
Chris Craik54389792013-12-20 13:28:11 -0800755 public void setScaleX(float scaleX) {
756 if (hasNativeDisplayList()) {
757 nSetScaleX(mFinalizer.mNativeDisplayList, scaleX);
758 }
759 }
Chet Haasea1cff502012-02-21 13:43:44 -0800760
761 /**
Romain Guy52036b12013-02-14 18:03:37 -0800762 * Returns the scale value for this display list on the X axis.
Chet Haasea1cff502012-02-21 13:43:44 -0800763 *
Romain Guy52036b12013-02-14 18:03:37 -0800764 * @see #setScaleX(float)
765 */
Chris Craik54389792013-12-20 13:28:11 -0800766 public float getScaleX() {
767 if (hasNativeDisplayList()) {
768 return nGetScaleX(mFinalizer.mNativeDisplayList);
769 }
770 return 1.0f;
771 }
Romain Guy52036b12013-02-14 18:03:37 -0800772
773 /**
Chris Craikd863a102013-12-19 13:31:15 -0800774 * Sets the scale value for the display list on the Y axis.
Romain Guy52036b12013-02-14 18:03:37 -0800775 *
776 * @param scaleY The scale value of the display list
777 *
Chet Haasea1cff502012-02-21 13:43:44 -0800778 * @see View#setScaleY(float)
Romain Guy52036b12013-02-14 18:03:37 -0800779 * @see #getScaleY()
Chet Haasea1cff502012-02-21 13:43:44 -0800780 */
Chris Craik54389792013-12-20 13:28:11 -0800781 public void setScaleY(float scaleY) {
782 if (hasNativeDisplayList()) {
783 nSetScaleY(mFinalizer.mNativeDisplayList, scaleY);
784 }
785 }
Chet Haasea1cff502012-02-21 13:43:44 -0800786
787 /**
Romain Guy52036b12013-02-14 18:03:37 -0800788 * Returns the scale value for this display list on the Y axis.
Chet Haasea1cff502012-02-21 13:43:44 -0800789 *
Romain Guy52036b12013-02-14 18:03:37 -0800790 * @see #setScaleY(float)
791 */
Chris Craik54389792013-12-20 13:28:11 -0800792 public float getScaleY() {
793 if (hasNativeDisplayList()) {
794 return nGetScaleY(mFinalizer.mNativeDisplayList);
795 }
796 return 1.0f;
797 }
Romain Guy52036b12013-02-14 18:03:37 -0800798
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 Haasea1cff502012-02-21 13:43:44 -0800812 */
Chris Craik54389792013-12-20 13:28:11 -0800813 public void setTransformationInfo(float alpha,
Chris Craikf57776b2013-10-25 18:30:17 -0700814 float translationX, float translationY, float translationZ,
Chris Craik54389792013-12-20 13:28:11 -0800815 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 Haasea1cff502012-02-21 13:43:44 -0800822
823 /**
Romain Guy52036b12013-02-14 18:03:37 -0800824 * Sets the pivot value for the display list on the X axis
Chet Haasea1cff502012-02-21 13:43:44 -0800825 *
Romain Guy52036b12013-02-14 18:03:37 -0800826 * @param pivotX The pivot value of the display list on the X axis, in pixels
827 *
Chet Haasea1cff502012-02-21 13:43:44 -0800828 * @see View#setPivotX(float)
Romain Guy52036b12013-02-14 18:03:37 -0800829 * @see #getPivotX()
Chet Haasea1cff502012-02-21 13:43:44 -0800830 */
Chris Craik54389792013-12-20 13:28:11 -0800831 public void setPivotX(float pivotX) {
832 if (hasNativeDisplayList()) {
833 nSetPivotX(mFinalizer.mNativeDisplayList, pivotX);
834 }
835 }
Chet Haasea1cff502012-02-21 13:43:44 -0800836
837 /**
Romain Guy52036b12013-02-14 18:03:37 -0800838 * Returns the pivot value for this display list on the X axis, in pixels.
Chet Haasea1cff502012-02-21 13:43:44 -0800839 *
Romain Guy52036b12013-02-14 18:03:37 -0800840 * @see #setPivotX(float)
841 */
Chris Craik54389792013-12-20 13:28:11 -0800842 public float getPivotX() {
843 if (hasNativeDisplayList()) {
844 return nGetPivotX(mFinalizer.mNativeDisplayList);
845 }
846 return 0.0f;
847 }
Romain Guy52036b12013-02-14 18:03:37 -0800848
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 Haasea1cff502012-02-21 13:43:44 -0800854 * @see View#setPivotY(float)
Romain Guy52036b12013-02-14 18:03:37 -0800855 * @see #getPivotY()
Chet Haasea1cff502012-02-21 13:43:44 -0800856 */
Chris Craik54389792013-12-20 13:28:11 -0800857 public void setPivotY(float pivotY) {
858 if (hasNativeDisplayList()) {
859 nSetPivotY(mFinalizer.mNativeDisplayList, pivotY);
860 }
861 }
Chet Haasea1cff502012-02-21 13:43:44 -0800862
863 /**
Romain Guy52036b12013-02-14 18:03:37 -0800864 * Returns the pivot value for this display list on the Y axis, in pixels.
Chet Haasea1cff502012-02-21 13:43:44 -0800865 *
Romain Guy52036b12013-02-14 18:03:37 -0800866 * @see #setPivotY(float)
867 */
Chris Craik54389792013-12-20 13:28:11 -0800868 public float getPivotY() {
869 if (hasNativeDisplayList()) {
870 return nGetPivotY(mFinalizer.mNativeDisplayList);
871 }
872 return 0.0f;
873 }
Romain Guy52036b12013-02-14 18:03:37 -0800874
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 Haasea1cff502012-02-21 13:43:44 -0800882 * @see View#setCameraDistance(float)
Romain Guy52036b12013-02-14 18:03:37 -0800883 * @see #getCameraDistance()
Chet Haasea1cff502012-02-21 13:43:44 -0800884 */
Chris Craik54389792013-12-20 13:28:11 -0800885 public void setCameraDistance(float distance) {
886 if (hasNativeDisplayList()) {
887 nSetCameraDistance(mFinalizer.mNativeDisplayList, distance);
888 }
889 }
Chet Haasea1cff502012-02-21 13:43:44 -0800890
891 /**
Romain Guy52036b12013-02-14 18:03:37 -0800892 * Returns the distance in Z of the camera of the display list.
Chet Haasea1cff502012-02-21 13:43:44 -0800893 *
Romain Guy52036b12013-02-14 18:03:37 -0800894 * @see #setCameraDistance(float)
895 */
Chris Craik54389792013-12-20 13:28:11 -0800896 public float getCameraDistance() {
897 if (hasNativeDisplayList()) {
898 return nGetCameraDistance(mFinalizer.mNativeDisplayList);
899 }
900 return 0.0f;
901 }
Romain Guy52036b12013-02-14 18:03:37 -0800902
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 Haasea1cff502012-02-21 13:43:44 -0800908 * @see View#setLeft(int)
Romain Guy52036b12013-02-14 18:03:37 -0800909 * @see #getLeft()
Chet Haasea1cff502012-02-21 13:43:44 -0800910 */
Chris Craik54389792013-12-20 13:28:11 -0800911 public void setLeft(int left) {
912 if (hasNativeDisplayList()) {
913 nSetLeft(mFinalizer.mNativeDisplayList, left);
914 }
915 }
Chet Haasea1cff502012-02-21 13:43:44 -0800916
917 /**
Romain Guy52036b12013-02-14 18:03:37 -0800918 * Returns the left position for the display list in pixels.
Chet Haasea1cff502012-02-21 13:43:44 -0800919 *
Romain Guy52036b12013-02-14 18:03:37 -0800920 * @see #setLeft(int)
921 */
Chris Craik54389792013-12-20 13:28:11 -0800922 public float getLeft() {
923 if (hasNativeDisplayList()) {
924 return nGetLeft(mFinalizer.mNativeDisplayList);
925 }
926 return 0.0f;
927 }
Romain Guy52036b12013-02-14 18:03:37 -0800928
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 Haasea1cff502012-02-21 13:43:44 -0800934 * @see View#setTop(int)
Romain Guy52036b12013-02-14 18:03:37 -0800935 * @see #getTop()
Chet Haasea1cff502012-02-21 13:43:44 -0800936 */
Chris Craik54389792013-12-20 13:28:11 -0800937 public void setTop(int top) {
938 if (hasNativeDisplayList()) {
939 nSetTop(mFinalizer.mNativeDisplayList, top);
940 }
941 }
Chet Haasea1cff502012-02-21 13:43:44 -0800942
943 /**
Romain Guy52036b12013-02-14 18:03:37 -0800944 * Returns the top position for the display list in pixels.
Chet Haasea1cff502012-02-21 13:43:44 -0800945 *
Romain Guy52036b12013-02-14 18:03:37 -0800946 * @see #setTop(int)
947 */
Chris Craik54389792013-12-20 13:28:11 -0800948 public float getTop() {
949 if (hasNativeDisplayList()) {
950 return nGetTop(mFinalizer.mNativeDisplayList);
951 }
952 return 0.0f;
953 }
Romain Guy52036b12013-02-14 18:03:37 -0800954
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 Haasea1cff502012-02-21 13:43:44 -0800960 * @see View#setRight(int)
Romain Guy52036b12013-02-14 18:03:37 -0800961 * @see #getRight()
Chet Haasea1cff502012-02-21 13:43:44 -0800962 */
Chris Craik54389792013-12-20 13:28:11 -0800963 public void setRight(int right) {
964 if (hasNativeDisplayList()) {
965 nSetRight(mFinalizer.mNativeDisplayList, right);
966 }
967 }
Chet Haasea1cff502012-02-21 13:43:44 -0800968
969 /**
Romain Guy52036b12013-02-14 18:03:37 -0800970 * Returns the right position for the display list in pixels.
Chet Haasea1cff502012-02-21 13:43:44 -0800971 *
Romain Guy52036b12013-02-14 18:03:37 -0800972 * @see #setRight(int)
973 */
Chris Craik54389792013-12-20 13:28:11 -0800974 public float getRight() {
975 if (hasNativeDisplayList()) {
976 return nGetRight(mFinalizer.mNativeDisplayList);
977 }
978 return 0.0f;
979 }
Romain Guy52036b12013-02-14 18:03:37 -0800980
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 Haasea1cff502012-02-21 13:43:44 -0800986 * @see View#setBottom(int)
Romain Guy52036b12013-02-14 18:03:37 -0800987 * @see #getBottom()
Chet Haasea1cff502012-02-21 13:43:44 -0800988 */
Chris Craik54389792013-12-20 13:28:11 -0800989 public void setBottom(int bottom) {
990 if (hasNativeDisplayList()) {
991 nSetBottom(mFinalizer.mNativeDisplayList, bottom);
992 }
993 }
Chet Haasea1cff502012-02-21 13:43:44 -0800994
995 /**
Romain Guy52036b12013-02-14 18:03:37 -0800996 * Returns the bottom position for the display list in pixels.
Chet Haasea1cff502012-02-21 13:43:44 -0800997 *
Romain Guy52036b12013-02-14 18:03:37 -0800998 * @see #setBottom(int)
Chet Haasea1cff502012-02-21 13:43:44 -0800999 */
Chris Craik54389792013-12-20 13:28:11 -08001000 public float getBottom() {
1001 if (hasNativeDisplayList()) {
1002 return nGetBottom(mFinalizer.mNativeDisplayList);
1003 }
1004 return 0.0f;
1005 }
Chet Haasea1cff502012-02-21 13:43:44 -08001006
1007 /**
Romain Guy52036b12013-02-14 18:03:37 -08001008 * Sets the left and top positions for the display list
Chet Haasea1cff502012-02-21 13:43:44 -08001009 *
Romain Guy52036b12013-02-14 18:03:37 -08001010 * @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 Haasea1cff502012-02-21 13:43:44 -08001015 * @see View#setLeft(int)
1016 * @see View#setTop(int)
Romain Guy52036b12013-02-14 18:03:37 -08001017 * @see View#setRight(int)
1018 * @see View#setBottom(int)
Chet Haasea1cff502012-02-21 13:43:44 -08001019 */
Chris Craik54389792013-12-20 13:28:11 -08001020 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 Haasea1cff502012-02-21 13:43:44 -08001025
1026 /**
Romain Guy52036b12013-02-14 18:03:37 -08001027 * Offsets the left and right positions for the display list
Chet Haasea1cff502012-02-21 13:43:44 -08001028 *
Romain Guy52036b12013-02-14 18:03:37 -08001029 * @param offset The amount that the left and right positions of the display
1030 * list are offset, in pixels
1031 *
Chet Haasea1cff502012-02-21 13:43:44 -08001032 * @see View#offsetLeftAndRight(int)
1033 */
Chris Craik54389792013-12-20 13:28:11 -08001034 public void offsetLeftAndRight(float offset) {
1035 if (hasNativeDisplayList()) {
1036 nOffsetLeftAndRight(mFinalizer.mNativeDisplayList, offset);
1037 }
1038 }
Chet Haasea1cff502012-02-21 13:43:44 -08001039
1040 /**
Romain Guy52036b12013-02-14 18:03:37 -08001041 * Offsets the top and bottom values for the display list
Chet Haasea1cff502012-02-21 13:43:44 -08001042 *
Romain Guy52036b12013-02-14 18:03:37 -08001043 * @param offset The amount that the top and bottom positions of the display
1044 * list are offset, in pixels
1045 *
Chet Haasea1cff502012-02-21 13:43:44 -08001046 * @see View#offsetTopAndBottom(int)
1047 */
Chris Craik54389792013-12-20 13:28:11 -08001048 public void offsetTopAndBottom(float offset) {
1049 if (hasNativeDisplayList()) {
1050 nOffsetTopAndBottom(mFinalizer.mNativeDisplayList, offset);
1051 }
1052 }
John Reck63049192013-12-10 15:22:01 -08001053
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 Craik54389792013-12-20 13:28:11 -08001060 public void output() {
1061 if (hasNativeDisplayList()) {
1062 nOutput(mFinalizer.mNativeDisplayList);
1063 }
1064 }
1065
1066 ///////////////////////////////////////////////////////////////////////////
1067 // Native methods
1068 ///////////////////////////////////////////////////////////////////////////
1069
Ashok Bhat36bef0b2014-01-20 20:08:01 +00001070 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 Craik54389792013-12-20 13:28:11 -08001073
1074 // Properties
1075
Ashok Bhat36bef0b2014-01-20 20:08:01 +00001076 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 Craik54389792013-12-20 13:28:11 -08001080 int right, int bottom);
Ashok Bhat36bef0b2014-01-20 20:08:01 +00001081 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 Craik6657a6c2014-01-26 11:30:58 -08001090 private static native void nSetProjectBackwards(long displayList, boolean shouldProject);
Chris Craik1df26442014-02-05 16:50:41 -08001091 private static native void nSetProjectionReceiver(long displayList, boolean shouldRecieve);
Chris Craik6657a6c2014-01-26 11:30:58 -08001092 private static native void nSetIsolatedZVolume(long displayList, boolean isolateZVolume);
Chris Craika2fe7af2014-01-28 17:25:06 -08001093 private static native void nSetOutline(long displayList, long nativePath);
ztenghuifad45932014-02-06 10:33:58 -08001094 private static native void nSetClipToOutline(long displayList, boolean clipToOutline);
Ashok Bhat36bef0b2014-01-20 20:08:01 +00001095 private static native void nSetAlpha(long displayList, float alpha);
1096 private static native void nSetHasOverlappingRendering(long displayList,
Chris Craik54389792013-12-20 13:28:11 -08001097 boolean hasOverlappingRendering);
Ashok Bhat36bef0b2014-01-20 20:08:01 +00001098 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 Craik54389792013-12-20 13:28:11 -08001107 float translationX, float translationY, float translationZ,
1108 float rotation, float rotationX, float rotationY, float scaleX, float scaleY);
Ashok Bhat36bef0b2014-01-20 20:08:01 +00001109 private static native void nSetStaticMatrix(long displayList, long nativeMatrix);
1110 private static native void nSetAnimationMatrix(long displayList, long animationMatrix);
Chris Craik54389792013-12-20 13:28:11 -08001111
Ashok Bhat36bef0b2014-01-20 20:08:01 +00001112 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 Craik54389792013-12-20 13:28:11 -08001131
1132 ///////////////////////////////////////////////////////////////////////////
1133 // Finalization
1134 ///////////////////////////////////////////////////////////////////////////
1135
1136 private static class DisplayListFinalizer {
Ashok Bhat36bef0b2014-01-20 20:08:01 +00001137 final long mNativeDisplayList;
Chris Craik54389792013-12-20 13:28:11 -08001138
Ashok Bhat36bef0b2014-01-20 20:08:01 +00001139 public DisplayListFinalizer(long nativeDisplayList) {
Chris Craik54389792013-12-20 13:28:11 -08001140 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 Guyb051e892010-09-28 19:09:36 -07001152}