Canvas.java revision caa08ff5e9ee004634a95776fc72bb769f1286de
1/*
2 * Copyright (C) 2006 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.graphics;
18
19import android.annotation.ColorInt;
20import android.annotation.IntDef;
21import android.annotation.NonNull;
22import android.annotation.Nullable;
23import android.annotation.Size;
24import android.text.GraphicsOperations;
25import android.text.SpannableString;
26import android.text.SpannedString;
27import android.text.TextUtils;
28
29import dalvik.annotation.optimization.FastNative;
30
31import libcore.util.NativeAllocationRegistry;
32
33import java.lang.annotation.Retention;
34import java.lang.annotation.RetentionPolicy;
35
36import javax.microedition.khronos.opengles.GL;
37
38/**
39 * The Canvas class holds the "draw" calls. To draw something, you need
40 * 4 basic components: A Bitmap to hold the pixels, a Canvas to host
41 * the draw calls (writing into the bitmap), a drawing primitive (e.g. Rect,
42 * Path, text, Bitmap), and a paint (to describe the colors and styles for the
43 * drawing).
44 *
45 * <div class="special reference">
46 * <h3>Developer Guides</h3>
47 * <p>For more information about how to use Canvas, read the
48 * <a href="{@docRoot}guide/topics/graphics/2d-graphics.html">
49 * Canvas and Drawables</a> developer guide.</p></div>
50 */
51public class Canvas extends BaseCanvas {
52    /** @hide */
53    public static boolean sCompatibilityRestore = false;
54
55    /** @hide */
56    public long getNativeCanvasWrapper() {
57        return mNativeCanvasWrapper;
58    }
59
60    /** @hide */
61    public boolean isRecordingFor(Object o) { return false; }
62
63    // may be null
64    private Bitmap mBitmap;
65
66    // optional field set by the caller
67    private DrawFilter mDrawFilter;
68
69    // Maximum bitmap size as defined in Skia's native code
70    // (see SkCanvas.cpp, SkDraw.cpp)
71    private static final int MAXMIMUM_BITMAP_SIZE = 32766;
72
73    // The approximate size of the native allocation associated with
74    // a Canvas object.
75    private static final long NATIVE_ALLOCATION_SIZE = 525;
76
77    // Use a Holder to allow static initialization of Canvas in the boot image.
78    private static class NoImagePreloadHolder {
79        public static final NativeAllocationRegistry sRegistry = new NativeAllocationRegistry(
80                Canvas.class.getClassLoader(), nGetNativeFinalizer(), NATIVE_ALLOCATION_SIZE);
81    }
82
83    // This field is used to finalize the native Canvas properly
84    private Runnable mFinalizer;
85
86    /**
87     * Construct an empty raster canvas. Use setBitmap() to specify a bitmap to
88     * draw into.  The initial target density is {@link Bitmap#DENSITY_NONE};
89     * this will typically be replaced when a target bitmap is set for the
90     * canvas.
91     */
92    public Canvas() {
93        if (!isHardwareAccelerated()) {
94            // 0 means no native bitmap
95            mNativeCanvasWrapper = nInitRaster(null);
96            mFinalizer = NoImagePreloadHolder.sRegistry.registerNativeAllocation(
97                    this, mNativeCanvasWrapper);
98        } else {
99            mFinalizer = null;
100        }
101    }
102
103    /**
104     * Construct a canvas with the specified bitmap to draw into. The bitmap
105     * must be mutable.
106     *
107     * <p>The initial target density of the canvas is the same as the given
108     * bitmap's density.
109     *
110     * @param bitmap Specifies a mutable bitmap for the canvas to draw into.
111     */
112    public Canvas(@NonNull Bitmap bitmap) {
113        if (!bitmap.isMutable()) {
114            throw new IllegalStateException("Immutable bitmap passed to Canvas constructor");
115        }
116        throwIfCannotDraw(bitmap);
117        mNativeCanvasWrapper = nInitRaster(bitmap);
118        mFinalizer = NoImagePreloadHolder.sRegistry.registerNativeAllocation(
119                this, mNativeCanvasWrapper);
120        mBitmap = bitmap;
121        mDensity = bitmap.mDensity;
122    }
123
124    /** @hide */
125    public Canvas(long nativeCanvas) {
126        if (nativeCanvas == 0) {
127            throw new IllegalStateException();
128        }
129        mNativeCanvasWrapper = nativeCanvas;
130        mFinalizer = NoImagePreloadHolder.sRegistry.registerNativeAllocation(
131                this, mNativeCanvasWrapper);
132        mDensity = Bitmap.getDefaultDensity();
133    }
134
135    /**
136     * Returns null.
137     *
138     * @deprecated This method is not supported and should not be invoked.
139     *
140     * @hide
141     */
142    @Deprecated
143    protected GL getGL() {
144        return null;
145    }
146
147    /**
148     * Indicates whether this Canvas uses hardware acceleration.
149     *
150     * Note that this method does not define what type of hardware acceleration
151     * may or may not be used.
152     *
153     * @return True if drawing operations are hardware accelerated,
154     *         false otherwise.
155     */
156    public boolean isHardwareAccelerated() {
157        return false;
158    }
159
160    /**
161     * Specify a bitmap for the canvas to draw into. All canvas state such as
162     * layers, filters, and the save/restore stack are reset with the exception
163     * of the current matrix and clip stack. Additionally, as a side-effect
164     * the canvas' target density is updated to match that of the bitmap.
165     *
166     * @param bitmap Specifies a mutable bitmap for the canvas to draw into.
167     * @see #setDensity(int)
168     * @see #getDensity()
169     */
170    public void setBitmap(@Nullable Bitmap bitmap) {
171        if (isHardwareAccelerated()) {
172            throw new RuntimeException("Can't set a bitmap device on a HW accelerated canvas");
173        }
174
175        if (bitmap == null) {
176            nSetBitmap(mNativeCanvasWrapper, null);
177            mDensity = Bitmap.DENSITY_NONE;
178        } else {
179            if (!bitmap.isMutable()) {
180                throw new IllegalStateException();
181            }
182            throwIfCannotDraw(bitmap);
183
184            nSetBitmap(mNativeCanvasWrapper, bitmap);
185            mDensity = bitmap.mDensity;
186        }
187
188        mBitmap = bitmap;
189    }
190
191    /** @hide */
192    public void setHighContrastText(boolean highContrastText) {
193        nSetHighContrastText(mNativeCanvasWrapper, highContrastText);
194    }
195
196    /** @hide */
197    public void insertReorderBarrier() {}
198
199    /** @hide */
200    public void insertInorderBarrier() {}
201
202    /**
203     * Return true if the device that the current layer draws into is opaque
204     * (i.e. does not support per-pixel alpha).
205     *
206     * @return true if the device that the current layer draws into is opaque
207     */
208    public boolean isOpaque() {
209        return nIsOpaque(mNativeCanvasWrapper);
210    }
211
212    /**
213     * Returns the width of the current drawing layer
214     *
215     * @return the width of the current drawing layer
216     */
217    public int getWidth() {
218        return nGetWidth(mNativeCanvasWrapper);
219    }
220
221    /**
222     * Returns the height of the current drawing layer
223     *
224     * @return the height of the current drawing layer
225     */
226    public int getHeight() {
227        return nGetHeight(mNativeCanvasWrapper);
228    }
229
230    /**
231     * <p>Returns the target density of the canvas.  The default density is
232     * derived from the density of its backing bitmap, or
233     * {@link Bitmap#DENSITY_NONE} if there is not one.</p>
234     *
235     * @return Returns the current target density of the canvas, which is used
236     * to determine the scaling factor when drawing a bitmap into it.
237     *
238     * @see #setDensity(int)
239     * @see Bitmap#getDensity()
240     */
241    public int getDensity() {
242        return mDensity;
243    }
244
245    /**
246     * <p>Specifies the density for this Canvas' backing bitmap.  This modifies
247     * the target density of the canvas itself, as well as the density of its
248     * backing bitmap via {@link Bitmap#setDensity(int) Bitmap.setDensity(int)}.
249     *
250     * @param density The new target density of the canvas, which is used
251     * to determine the scaling factor when drawing a bitmap into it.  Use
252     * {@link Bitmap#DENSITY_NONE} to disable bitmap scaling.
253     *
254     * @see #getDensity()
255     * @see Bitmap#setDensity(int)
256     */
257    public void setDensity(int density) {
258        if (mBitmap != null) {
259            mBitmap.setDensity(density);
260        }
261        mDensity = density;
262    }
263
264    /** @hide */
265    public void setScreenDensity(int density) {
266        mScreenDensity = density;
267    }
268
269    /**
270     * Returns the maximum allowed width for bitmaps drawn with this canvas.
271     * Attempting to draw with a bitmap wider than this value will result
272     * in an error.
273     *
274     * @see #getMaximumBitmapHeight()
275     */
276    public int getMaximumBitmapWidth() {
277        return MAXMIMUM_BITMAP_SIZE;
278    }
279
280    /**
281     * Returns the maximum allowed height for bitmaps drawn with this canvas.
282     * Attempting to draw with a bitmap taller than this value will result
283     * in an error.
284     *
285     * @see #getMaximumBitmapWidth()
286     */
287    public int getMaximumBitmapHeight() {
288        return MAXMIMUM_BITMAP_SIZE;
289    }
290
291    // the SAVE_FLAG constants must match their native equivalents
292
293    /** @hide */
294    @IntDef(flag = true,
295            value = {
296                MATRIX_SAVE_FLAG,
297                CLIP_SAVE_FLAG,
298                HAS_ALPHA_LAYER_SAVE_FLAG,
299                FULL_COLOR_LAYER_SAVE_FLAG,
300                CLIP_TO_LAYER_SAVE_FLAG,
301                ALL_SAVE_FLAG
302            })
303    @Retention(RetentionPolicy.SOURCE)
304    public @interface Saveflags {}
305
306    /**
307     * Restore the current matrix when restore() is called.
308     */
309    public static final int MATRIX_SAVE_FLAG = 0x01;
310
311    /**
312     * Restore the current clip when restore() is called.
313     */
314    public static final int CLIP_SAVE_FLAG = 0x02;
315
316    /**
317     * The layer requires a per-pixel alpha channel.
318     */
319    public static final int HAS_ALPHA_LAYER_SAVE_FLAG = 0x04;
320
321    /**
322     * The layer requires full 8-bit precision for each color channel.
323     */
324    public static final int FULL_COLOR_LAYER_SAVE_FLAG = 0x08;
325
326    /**
327     * Clip drawing to the bounds of the offscreen layer, omit at your own peril.
328     * <p class="note"><strong>Note:</strong> it is strongly recommended to not
329     * omit this flag for any call to <code>saveLayer()</code> and
330     * <code>saveLayerAlpha()</code> variants. Not passing this flag generally
331     * triggers extremely poor performance with hardware accelerated rendering.
332     */
333    public static final int CLIP_TO_LAYER_SAVE_FLAG = 0x10;
334
335    /**
336     * Restore everything when restore() is called (standard save flags).
337     * <p class="note"><strong>Note:</strong> for performance reasons, it is
338     * strongly recommended to pass this - the complete set of flags - to any
339     * call to <code>saveLayer()</code> and <code>saveLayerAlpha()</code>
340     * variants.
341     */
342    public static final int ALL_SAVE_FLAG = 0x1F;
343
344    /**
345     * Saves the current matrix and clip onto a private stack.
346     * <p>
347     * Subsequent calls to translate,scale,rotate,skew,concat or clipRect,
348     * clipPath will all operate as usual, but when the balancing call to
349     * restore() is made, those calls will be forgotten, and the settings that
350     * existed before the save() will be reinstated.
351     *
352     * @return The value to pass to restoreToCount() to balance this save()
353     */
354    public int save() {
355        return nSave(mNativeCanvasWrapper, MATRIX_SAVE_FLAG | CLIP_SAVE_FLAG);
356    }
357
358    /**
359     * Based on saveFlags, can save the current matrix and clip onto a private
360     * stack.
361     * <p class="note"><strong>Note:</strong> if possible, use the
362     * parameter-less save(). It is simpler and faster than individually
363     * disabling the saving of matrix or clip with this method.
364     * <p>
365     * Subsequent calls to translate,scale,rotate,skew,concat or clipRect,
366     * clipPath will all operate as usual, but when the balancing call to
367     * restore() is made, those calls will be forgotten, and the settings that
368     * existed before the save() will be reinstated.
369     *
370     * @param saveFlags flag bits that specify which parts of the Canvas state
371     *                  to save/restore
372     * @return The value to pass to restoreToCount() to balance this save()
373     */
374    public int save(@Saveflags int saveFlags) {
375        return nSave(mNativeCanvasWrapper, saveFlags);
376    }
377
378    /**
379     * This behaves the same as save(), but in addition it allocates and
380     * redirects drawing to an offscreen bitmap.
381     * <p class="note"><strong>Note:</strong> this method is very expensive,
382     * incurring more than double rendering cost for contained content. Avoid
383     * using this method, especially if the bounds provided are large, or if
384     * the {@link #CLIP_TO_LAYER_SAVE_FLAG} is omitted from the
385     * {@code saveFlags} parameter. It is recommended to use a
386     * {@link android.view.View#LAYER_TYPE_HARDWARE hardware layer} on a View
387     * to apply an xfermode, color filter, or alpha, as it will perform much
388     * better than this method.
389     * <p>
390     * All drawing calls are directed to a newly allocated offscreen bitmap.
391     * Only when the balancing call to restore() is made, is that offscreen
392     * buffer drawn back to the current target of the Canvas (either the
393     * screen, it's target Bitmap, or the previous layer).
394     * <p>
395     * Attributes of the Paint - {@link Paint#getAlpha() alpha},
396     * {@link Paint#getXfermode() Xfermode}, and
397     * {@link Paint#getColorFilter() ColorFilter} are applied when the
398     * offscreen bitmap is drawn back when restore() is called.
399     *
400     * @param bounds May be null. The maximum size the offscreen bitmap
401     *               needs to be (in local coordinates)
402     * @param paint  This is copied, and is applied to the offscreen when
403     *               restore() is called.
404     * @param saveFlags see _SAVE_FLAG constants, generally {@link #ALL_SAVE_FLAG} is recommended
405     *               for performance reasons.
406     * @return       value to pass to restoreToCount() to balance this save()
407     */
408    public int saveLayer(@Nullable RectF bounds, @Nullable Paint paint, @Saveflags int saveFlags) {
409        if (bounds == null) {
410            bounds = new RectF(getClipBounds());
411        }
412        return saveLayer(bounds.left, bounds.top, bounds.right, bounds.bottom, paint, saveFlags);
413    }
414
415    /**
416     * Convenience for saveLayer(bounds, paint, {@link #ALL_SAVE_FLAG})
417     */
418    public int saveLayer(@Nullable RectF bounds, @Nullable Paint paint) {
419        return saveLayer(bounds, paint, ALL_SAVE_FLAG);
420    }
421
422    /**
423     * Helper version of saveLayer() that takes 4 values rather than a RectF.
424     */
425    public int saveLayer(float left, float top, float right, float bottom, @Nullable Paint paint,
426            @Saveflags int saveFlags) {
427        return nSaveLayer(mNativeCanvasWrapper, left, top, right, bottom,
428                paint != null ? paint.getNativeInstance() : 0,
429                saveFlags);
430    }
431
432    /**
433     * Convenience for saveLayer(left, top, right, bottom, paint, {@link #ALL_SAVE_FLAG})
434     */
435    public int saveLayer(float left, float top, float right, float bottom, @Nullable Paint paint) {
436        return saveLayer(left, top, right, bottom, paint, ALL_SAVE_FLAG);
437    }
438
439    /**
440     * This behaves the same as save(), but in addition it allocates and
441     * redirects drawing to an offscreen bitmap.
442     * <p class="note"><strong>Note:</strong> this method is very expensive,
443     * incurring more than double rendering cost for contained content. Avoid
444     * using this method, especially if the bounds provided are large, or if
445     * the {@link #CLIP_TO_LAYER_SAVE_FLAG} is omitted from the
446     * {@code saveFlags} parameter. It is recommended to use a
447     * {@link android.view.View#LAYER_TYPE_HARDWARE hardware layer} on a View
448     * to apply an xfermode, color filter, or alpha, as it will perform much
449     * better than this method.
450     * <p>
451     * All drawing calls are directed to a newly allocated offscreen bitmap.
452     * Only when the balancing call to restore() is made, is that offscreen
453     * buffer drawn back to the current target of the Canvas (either the
454     * screen, it's target Bitmap, or the previous layer).
455     * <p>
456     * The {@code alpha} parameter is applied when the offscreen bitmap is
457     * drawn back when restore() is called.
458     *
459     * @param bounds    The maximum size the offscreen bitmap needs to be
460     *                  (in local coordinates)
461     * @param alpha     The alpha to apply to the offscreen when it is
462                        drawn during restore()
463     * @param saveFlags see _SAVE_FLAG constants, generally {@link #ALL_SAVE_FLAG} is recommended
464     *                  for performance reasons.
465     * @return          value to pass to restoreToCount() to balance this call
466     */
467    public int saveLayerAlpha(@Nullable RectF bounds, int alpha, @Saveflags int saveFlags) {
468        if (bounds == null) {
469            bounds = new RectF(getClipBounds());
470        }
471        return saveLayerAlpha(bounds.left, bounds.top, bounds.right, bounds.bottom, alpha, saveFlags);
472    }
473
474    /**
475     * Convenience for saveLayerAlpha(bounds, alpha, {@link #ALL_SAVE_FLAG})
476     */
477    public int saveLayerAlpha(@Nullable RectF bounds, int alpha) {
478        return saveLayerAlpha(bounds, alpha, ALL_SAVE_FLAG);
479    }
480
481    /**
482     * Helper for saveLayerAlpha() that takes 4 values instead of a RectF.
483     */
484    public int saveLayerAlpha(float left, float top, float right, float bottom, int alpha,
485            @Saveflags int saveFlags) {
486        alpha = Math.min(255, Math.max(0, alpha));
487        return nSaveLayerAlpha(mNativeCanvasWrapper, left, top, right, bottom,
488                                     alpha, saveFlags);
489    }
490
491    /**
492     * Helper for saveLayerAlpha(left, top, right, bottom, alpha, {@link #ALL_SAVE_FLAG})
493     */
494    public int saveLayerAlpha(float left, float top, float right, float bottom, int alpha) {
495        return saveLayerAlpha(left, top, right, bottom, alpha, ALL_SAVE_FLAG);
496    }
497
498    /**
499     * This call balances a previous call to save(), and is used to remove all
500     * modifications to the matrix/clip state since the last save call. It is
501     * an error to call restore() more times than save() was called.
502     */
503    public void restore() {
504        boolean throwOnUnderflow = !sCompatibilityRestore || !isHardwareAccelerated();
505        nRestore(mNativeCanvasWrapper, throwOnUnderflow);
506    }
507
508    /**
509     * Returns the number of matrix/clip states on the Canvas' private stack.
510     * This will equal # save() calls - # restore() calls.
511     */
512    public int getSaveCount() {
513        return nGetSaveCount(mNativeCanvasWrapper);
514    }
515
516    /**
517     * Efficient way to pop any calls to save() that happened after the save
518     * count reached saveCount. It is an error for saveCount to be less than 1.
519     *
520     * Example:
521     *    int count = canvas.save();
522     *    ... // more calls potentially to save()
523     *    canvas.restoreToCount(count);
524     *    // now the canvas is back in the same state it was before the initial
525     *    // call to save().
526     *
527     * @param saveCount The save level to restore to.
528     */
529    public void restoreToCount(int saveCount) {
530        boolean throwOnUnderflow = !sCompatibilityRestore || !isHardwareAccelerated();
531        nRestoreToCount(mNativeCanvasWrapper, saveCount, throwOnUnderflow);
532    }
533
534    /**
535     * Preconcat the current matrix with the specified translation
536     *
537     * @param dx The distance to translate in X
538     * @param dy The distance to translate in Y
539    */
540    public void translate(float dx, float dy) {
541        if (dx == 0.0f && dy == 0.0f) return;
542        nTranslate(mNativeCanvasWrapper, dx, dy);
543    }
544
545    /**
546     * Preconcat the current matrix with the specified scale.
547     *
548     * @param sx The amount to scale in X
549     * @param sy The amount to scale in Y
550     */
551    public void scale(float sx, float sy) {
552        if (sx == 1.0f && sy == 1.0f) return;
553        nScale(mNativeCanvasWrapper, sx, sy);
554    }
555
556    /**
557     * Preconcat the current matrix with the specified scale.
558     *
559     * @param sx The amount to scale in X
560     * @param sy The amount to scale in Y
561     * @param px The x-coord for the pivot point (unchanged by the scale)
562     * @param py The y-coord for the pivot point (unchanged by the scale)
563     */
564    public final void scale(float sx, float sy, float px, float py) {
565        if (sx == 1.0f && sy == 1.0f) return;
566        translate(px, py);
567        scale(sx, sy);
568        translate(-px, -py);
569    }
570
571    /**
572     * Preconcat the current matrix with the specified rotation.
573     *
574     * @param degrees The amount to rotate, in degrees
575     */
576    public void rotate(float degrees) {
577        if (degrees == 0.0f) return;
578        nRotate(mNativeCanvasWrapper, degrees);
579    }
580
581    /**
582     * Preconcat the current matrix with the specified rotation.
583     *
584     * @param degrees The amount to rotate, in degrees
585     * @param px The x-coord for the pivot point (unchanged by the rotation)
586     * @param py The y-coord for the pivot point (unchanged by the rotation)
587     */
588    public final void rotate(float degrees, float px, float py) {
589        if (degrees == 0.0f) return;
590        translate(px, py);
591        rotate(degrees);
592        translate(-px, -py);
593    }
594
595    /**
596     * Preconcat the current matrix with the specified skew.
597     *
598     * @param sx The amount to skew in X
599     * @param sy The amount to skew in Y
600     */
601    public void skew(float sx, float sy) {
602        if (sx == 0.0f && sy == 0.0f) return;
603        nSkew(mNativeCanvasWrapper, sx, sy);
604    }
605
606    /**
607     * Preconcat the current matrix with the specified matrix. If the specified
608     * matrix is null, this method does nothing.
609     *
610     * @param matrix The matrix to preconcatenate with the current matrix
611     */
612    public void concat(@Nullable Matrix matrix) {
613        if (matrix != null) nConcat(mNativeCanvasWrapper, matrix.native_instance);
614    }
615
616    /**
617     * Completely replace the current matrix with the specified matrix. If the
618     * matrix parameter is null, then the current matrix is reset to identity.
619     *
620     * <strong>Note:</strong> it is recommended to use {@link #concat(Matrix)},
621     * {@link #scale(float, float)}, {@link #translate(float, float)} and
622     * {@link #rotate(float)} instead of this method.
623     *
624     * @param matrix The matrix to replace the current matrix with. If it is
625     *               null, set the current matrix to identity.
626     *
627     * @see #concat(Matrix)
628     */
629    public void setMatrix(@Nullable Matrix matrix) {
630        nSetMatrix(mNativeCanvasWrapper,
631                         matrix == null ? 0 : matrix.native_instance);
632    }
633
634    /**
635     * Return, in ctm, the current transformation matrix. This does not alter
636     * the matrix in the canvas, but just returns a copy of it.
637     *
638     * @deprecated {@link #isHardwareAccelerated() Hardware accelerated} canvases may have any
639     * matrix when passed to a View or Drawable, as it is implementation defined where in the
640     * hierarchy such canvases are created. It is recommended in such cases to either draw contents
641     * irrespective of the current matrix, or to track relevant transform state outside of the
642     * canvas.
643     */
644    @Deprecated
645    public void getMatrix(@NonNull Matrix ctm) {
646        nGetCTM(mNativeCanvasWrapper, ctm.native_instance);
647    }
648
649    /**
650     * Return a new matrix with a copy of the canvas' current transformation
651     * matrix.
652     *
653     * @deprecated {@link #isHardwareAccelerated() Hardware accelerated} canvases may have any
654     * matrix when passed to a View or Drawable, as it is implementation defined where in the
655     * hierarchy such canvases are created. It is recommended in such cases to either draw contents
656     * irrespective of the current matrix, or to track relevant transform state outside of the
657     * canvas.
658     */
659    @Deprecated
660    public final @NonNull Matrix getMatrix() {
661        Matrix m = new Matrix();
662        //noinspection deprecation
663        getMatrix(m);
664        return m;
665    }
666
667    /**
668     * Modify the current clip with the specified rectangle.
669     *
670     * @param rect The rect to intersect with the current clip
671     * @param op How the clip is modified
672     * @return true if the resulting clip is non-empty
673     */
674    public boolean clipRect(@NonNull RectF rect, @NonNull Region.Op op) {
675        return nClipRect(mNativeCanvasWrapper, rect.left, rect.top, rect.right, rect.bottom,
676                op.nativeInt);
677    }
678
679    /**
680     * Modify the current clip with the specified rectangle, which is
681     * expressed in local coordinates.
682     *
683     * @param rect The rectangle to intersect with the current clip.
684     * @param op How the clip is modified
685     * @return true if the resulting clip is non-empty
686     */
687    public boolean clipRect(@NonNull Rect rect, @NonNull Region.Op op) {
688        return nClipRect(mNativeCanvasWrapper, rect.left, rect.top, rect.right, rect.bottom,
689                op.nativeInt);
690    }
691
692    /**
693     * Intersect the current clip with the specified rectangle, which is
694     * expressed in local coordinates.
695     *
696     * @param rect The rectangle to intersect with the current clip.
697     * @return true if the resulting clip is non-empty
698     */
699    public boolean clipRect(@NonNull RectF rect) {
700        return nClipRect(mNativeCanvasWrapper, rect.left, rect.top, rect.right, rect.bottom,
701                Region.Op.INTERSECT.nativeInt);
702    }
703
704    /**
705     * Intersect the current clip with the specified rectangle, which is
706     * expressed in local coordinates.
707     *
708     * @param rect The rectangle to intersect with the current clip.
709     * @return true if the resulting clip is non-empty
710     */
711    public boolean clipRect(@NonNull Rect rect) {
712        return nClipRect(mNativeCanvasWrapper, rect.left, rect.top, rect.right, rect.bottom,
713                Region.Op.INTERSECT.nativeInt);
714    }
715
716    /**
717     * Modify the current clip with the specified rectangle, which is
718     * expressed in local coordinates.
719     *
720     * @param left   The left side of the rectangle to intersect with the
721     *               current clip
722     * @param top    The top of the rectangle to intersect with the current
723     *               clip
724     * @param right  The right side of the rectangle to intersect with the
725     *               current clip
726     * @param bottom The bottom of the rectangle to intersect with the current
727     *               clip
728     * @param op     How the clip is modified
729     * @return       true if the resulting clip is non-empty
730     */
731    public boolean clipRect(float left, float top, float right, float bottom,
732            @NonNull Region.Op op) {
733        return nClipRect(mNativeCanvasWrapper, left, top, right, bottom, op.nativeInt);
734    }
735
736    /**
737     * Intersect the current clip with the specified rectangle, which is
738     * expressed in local coordinates.
739     *
740     * @param left   The left side of the rectangle to intersect with the
741     *               current clip
742     * @param top    The top of the rectangle to intersect with the current clip
743     * @param right  The right side of the rectangle to intersect with the
744     *               current clip
745     * @param bottom The bottom of the rectangle to intersect with the current
746     *               clip
747     * @return       true if the resulting clip is non-empty
748     */
749    public boolean clipRect(float left, float top, float right, float bottom) {
750        return nClipRect(mNativeCanvasWrapper, left, top, right, bottom,
751                Region.Op.INTERSECT.nativeInt);
752    }
753
754    /**
755     * Intersect the current clip with the specified rectangle, which is
756     * expressed in local coordinates.
757     *
758     * @param left   The left side of the rectangle to intersect with the
759     *               current clip
760     * @param top    The top of the rectangle to intersect with the current clip
761     * @param right  The right side of the rectangle to intersect with the
762     *               current clip
763     * @param bottom The bottom of the rectangle to intersect with the current
764     *               clip
765     * @return       true if the resulting clip is non-empty
766     */
767    public boolean clipRect(int left, int top, int right, int bottom) {
768        return nClipRect(mNativeCanvasWrapper, left, top, right, bottom,
769                Region.Op.INTERSECT.nativeInt);
770    }
771
772    /**
773        * Modify the current clip with the specified path.
774     *
775     * @param path The path to operate on the current clip
776     * @param op   How the clip is modified
777     * @return     true if the resulting is non-empty
778     */
779    public boolean clipPath(@NonNull Path path, @NonNull Region.Op op) {
780        return nClipPath(mNativeCanvasWrapper, path.readOnlyNI(), op.nativeInt);
781    }
782
783    /**
784     * Intersect the current clip with the specified path.
785     *
786     * @param path The path to intersect with the current clip
787     * @return     true if the resulting is non-empty
788     */
789    public boolean clipPath(@NonNull Path path) {
790        return clipPath(path, Region.Op.INTERSECT);
791    }
792
793    /**
794     * Modify the current clip with the specified region. Note that unlike
795     * clipRect() and clipPath() which transform their arguments by the
796     * current matrix, clipRegion() assumes its argument is already in the
797     * coordinate system of the current layer's bitmap, and so not
798     * transformation is performed.
799     *
800     * @param region The region to operate on the current clip, based on op
801     * @param op How the clip is modified
802     * @return true if the resulting is non-empty
803     *
804     * @deprecated Unlike all other clip calls this API does not respect the
805     *             current matrix. Use {@link #clipRect(Rect)} as an alternative.
806     */
807    @Deprecated
808    public boolean clipRegion(@NonNull Region region, @NonNull Region.Op op) {
809        return nClipRegion(mNativeCanvasWrapper, region.ni(), op.nativeInt);
810    }
811
812    /**
813     * Intersect the current clip with the specified region. Note that unlike
814     * clipRect() and clipPath() which transform their arguments by the
815     * current matrix, clipRegion() assumes its argument is already in the
816     * coordinate system of the current layer's bitmap, and so not
817     * transformation is performed.
818     *
819     * @param region The region to operate on the current clip, based on op
820     * @return true if the resulting is non-empty
821     *
822     * @deprecated Unlike all other clip calls this API does not respect the
823     *             current matrix. Use {@link #clipRect(Rect)} as an alternative.
824     */
825    @Deprecated
826    public boolean clipRegion(@NonNull Region region) {
827        return clipRegion(region, Region.Op.INTERSECT);
828    }
829
830    public @Nullable DrawFilter getDrawFilter() {
831        return mDrawFilter;
832    }
833
834    public void setDrawFilter(@Nullable DrawFilter filter) {
835        long nativeFilter = 0;
836        if (filter != null) {
837            nativeFilter = filter.mNativeInt;
838        }
839        mDrawFilter = filter;
840        nSetDrawFilter(mNativeCanvasWrapper, nativeFilter);
841    }
842
843    /**
844     * Constant values used as parameters to {@code quickReject()} calls. These values
845     * specify how much space around the shape should be accounted for, depending on whether
846     * the shaped area is antialiased or not.
847     *
848     * @see #quickReject(float, float, float, float, EdgeType)
849     * @see #quickReject(Path, EdgeType)
850     * @see #quickReject(RectF, EdgeType)
851     */
852    public enum EdgeType {
853
854        /**
855         * Black-and-White: Treat edges by just rounding to nearest pixel boundary
856         */
857        BW(0),  //!< treat edges by just rounding to nearest pixel boundary
858
859        /**
860         * Antialiased: Treat edges by rounding-out, since they may be antialiased
861         */
862        AA(1);
863
864        EdgeType(int nativeInt) {
865            this.nativeInt = nativeInt;
866        }
867
868        /**
869         * @hide
870         */
871        public final int nativeInt;
872    }
873
874    /**
875     * Return true if the specified rectangle, after being transformed by the
876     * current matrix, would lie completely outside of the current clip. Call
877     * this to check if an area you intend to draw into is clipped out (and
878     * therefore you can skip making the draw calls).
879     *
880     * @param rect  the rect to compare with the current clip
881     * @param type  {@link Canvas.EdgeType#AA} if the path should be considered antialiased,
882     *              since that means it may affect a larger area (more pixels) than
883     *              non-antialiased ({@link Canvas.EdgeType#BW}).
884     * @return      true if the rect (transformed by the canvas' matrix)
885     *              does not intersect with the canvas' clip
886     */
887    public boolean quickReject(@NonNull RectF rect, @NonNull EdgeType type) {
888        return nQuickReject(mNativeCanvasWrapper,
889                rect.left, rect.top, rect.right, rect.bottom);
890    }
891
892    /**
893     * Return true if the specified path, after being transformed by the
894     * current matrix, would lie completely outside of the current clip. Call
895     * this to check if an area you intend to draw into is clipped out (and
896     * therefore you can skip making the draw calls). Note: for speed it may
897     * return false even if the path itself might not intersect the clip
898     * (i.e. the bounds of the path intersects, but the path does not).
899     *
900     * @param path        The path to compare with the current clip
901     * @param type        {@link Canvas.EdgeType#AA} if the path should be considered antialiased,
902     *                    since that means it may affect a larger area (more pixels) than
903     *                    non-antialiased ({@link Canvas.EdgeType#BW}).
904     * @return            true if the path (transformed by the canvas' matrix)
905     *                    does not intersect with the canvas' clip
906     */
907    public boolean quickReject(@NonNull Path path, @NonNull EdgeType type) {
908        return nQuickReject(mNativeCanvasWrapper, path.readOnlyNI());
909    }
910
911    /**
912     * Return true if the specified rectangle, after being transformed by the
913     * current matrix, would lie completely outside of the current clip. Call
914     * this to check if an area you intend to draw into is clipped out (and
915     * therefore you can skip making the draw calls).
916     *
917     * @param left        The left side of the rectangle to compare with the
918     *                    current clip
919     * @param top         The top of the rectangle to compare with the current
920     *                    clip
921     * @param right       The right side of the rectangle to compare with the
922     *                    current clip
923     * @param bottom      The bottom of the rectangle to compare with the
924     *                    current clip
925     * @param type        {@link Canvas.EdgeType#AA} if the path should be considered antialiased,
926     *                    since that means it may affect a larger area (more pixels) than
927     *                    non-antialiased ({@link Canvas.EdgeType#BW}).
928     * @return            true if the rect (transformed by the canvas' matrix)
929     *                    does not intersect with the canvas' clip
930     */
931    public boolean quickReject(float left, float top, float right, float bottom,
932            @NonNull EdgeType type) {
933        return nQuickReject(mNativeCanvasWrapper, left, top, right, bottom);
934    }
935
936    /**
937     * Return the bounds of the current clip (in local coordinates) in the
938     * bounds parameter, and return true if it is non-empty. This can be useful
939     * in a way similar to quickReject, in that it tells you that drawing
940     * outside of these bounds will be clipped out.
941     *
942     * @param bounds Return the clip bounds here. If it is null, ignore it but
943     *               still return true if the current clip is non-empty.
944     * @return true if the current clip is non-empty.
945     */
946    public boolean getClipBounds(@Nullable Rect bounds) {
947        return nGetClipBounds(mNativeCanvasWrapper, bounds);
948    }
949
950    /**
951     * Retrieve the bounds of the current clip (in local coordinates).
952     *
953     * @return the clip bounds, or [0, 0, 0, 0] if the clip is empty.
954     */
955    public final @NonNull Rect getClipBounds() {
956        Rect r = new Rect();
957        getClipBounds(r);
958        return r;
959    }
960
961    /**
962     * Save the canvas state, draw the picture, and restore the canvas state.
963     * This differs from picture.draw(canvas), which does not perform any
964     * save/restore.
965     *
966     * <p>
967     * <strong>Note:</strong> This forces the picture to internally call
968     * {@link Picture#endRecording} in order to prepare for playback.
969     *
970     * @param picture  The picture to be drawn
971     */
972    public void drawPicture(@NonNull Picture picture) {
973        picture.endRecording();
974        int restoreCount = save();
975        picture.draw(this);
976        restoreToCount(restoreCount);
977    }
978
979    /**
980     * Draw the picture, stretched to fit into the dst rectangle.
981     */
982    public void drawPicture(@NonNull Picture picture, @NonNull Rect dst) {
983        save();
984        translate(dst.left, dst.top);
985        if (picture.getWidth() > 0 && picture.getHeight() > 0) {
986            scale((float) dst.width() / picture.getWidth(),
987                    (float) dst.height() / picture.getHeight());
988        }
989        drawPicture(picture);
990        restore();
991    }
992
993    /**
994     * Draw the picture, stretched to fit into the dst rectangle.
995     */
996    public void drawPicture(@NonNull Picture picture, @NonNull RectF dst) {
997        save();
998        translate(dst.left, dst.top);
999        if (picture.getWidth() > 0 && picture.getHeight() > 0) {
1000            scale(dst.width() / picture.getWidth(), dst.height() / picture.getHeight());
1001        }
1002        drawPicture(picture);
1003        restore();
1004    }
1005
1006    public enum VertexMode {
1007        TRIANGLES(0),
1008        TRIANGLE_STRIP(1),
1009        TRIANGLE_FAN(2);
1010
1011        VertexMode(int nativeInt) {
1012            this.nativeInt = nativeInt;
1013        }
1014
1015        /**
1016         * @hide
1017         */
1018        public final int nativeInt;
1019    }
1020
1021    /**
1022     * Releases the resources associated with this canvas.
1023     *
1024     * @hide
1025     */
1026    public void release() {
1027        mNativeCanvasWrapper = 0;
1028        if (mFinalizer != null) {
1029            mFinalizer.run();
1030            mFinalizer = null;
1031        }
1032    }
1033
1034    /**
1035     * Free up as much memory as possible from private caches (e.g. fonts, images)
1036     *
1037     * @hide
1038     */
1039    public static void freeCaches() {
1040        nFreeCaches();
1041    }
1042
1043    /**
1044     * Free up text layout caches
1045     *
1046     * @hide
1047     */
1048    public static void freeTextLayoutCaches() {
1049        nFreeTextLayoutCaches();
1050    }
1051
1052    private static native void nFreeCaches();
1053    private static native void nFreeTextLayoutCaches();
1054    private static native long nInitRaster(Bitmap bitmap);
1055    private static native long nGetNativeFinalizer();
1056
1057    // ---------------- @FastNative -------------------
1058
1059    @FastNative
1060    private static native void nSetBitmap(long canvasHandle,
1061                                                Bitmap bitmap);
1062    @FastNative
1063    private static native boolean nIsOpaque(long canvasHandle);
1064    @FastNative
1065    private static native void nSetHighContrastText(long renderer, boolean highContrastText);
1066    @FastNative
1067    private static native int nGetWidth(long canvasHandle);
1068    @FastNative
1069    private static native int nGetHeight(long canvasHandle);
1070
1071    @FastNative
1072    private static native int nSave(long canvasHandle, int saveFlags);
1073    @FastNative
1074    private static native int nSaveLayer(long nativeCanvas, float l,
1075                                               float t, float r, float b,
1076                                               long nativePaint,
1077                                               int layerFlags);
1078    @FastNative
1079    private static native int nSaveLayerAlpha(long nativeCanvas, float l,
1080                                                    float t, float r, float b,
1081                                                    int alpha, int layerFlags);
1082    @FastNative
1083    private static native void nRestore(long canvasHandle, boolean tolerateUnderflow);
1084    @FastNative
1085    private static native void nRestoreToCount(long canvasHandle,
1086                                                     int saveCount,
1087                                                     boolean tolerateUnderflow);
1088    @FastNative
1089    private static native int nGetSaveCount(long canvasHandle);
1090
1091    @FastNative
1092    private static native void nTranslate(long canvasHandle,
1093                                                float dx, float dy);
1094    @FastNative
1095    private static native void nScale(long canvasHandle,
1096                                            float sx, float sy);
1097    @FastNative
1098    private static native void nRotate(long canvasHandle, float degrees);
1099    @FastNative
1100    private static native void nSkew(long canvasHandle,
1101                                           float sx, float sy);
1102    @FastNative
1103    private static native void nConcat(long nativeCanvas,
1104                                             long nativeMatrix);
1105    @FastNative
1106    private static native void nSetMatrix(long nativeCanvas,
1107                                                long nativeMatrix);
1108    @FastNative
1109    private static native boolean nClipRect(long nativeCanvas,
1110                                                  float left, float top,
1111                                                  float right, float bottom,
1112                                                  int regionOp);
1113    @FastNative
1114    private static native boolean nClipPath(long nativeCanvas,
1115                                                  long nativePath,
1116                                                  int regionOp);
1117    @FastNative
1118    private static native boolean nClipRegion(long nativeCanvas,
1119                                                    long nativeRegion,
1120                                                    int regionOp);
1121    @FastNative
1122    private static native void nSetDrawFilter(long nativeCanvas,
1123                                                   long nativeFilter);
1124    @FastNative
1125    private static native boolean nGetClipBounds(long nativeCanvas,
1126                                                       Rect bounds);
1127    @FastNative
1128    private static native void nGetCTM(long nativeCanvas,
1129                                             long nativeMatrix);
1130    @FastNative
1131    private static native boolean nQuickReject(long nativeCanvas,
1132                                                     long nativePath);
1133    @FastNative
1134    private static native boolean nQuickReject(long nativeCanvas,
1135                                                     float left, float top,
1136                                                     float right, float bottom);
1137
1138    /**
1139     * <p>Draw the specified arc, which will be scaled to fit inside the
1140     * specified oval.</p>
1141     *
1142     * <p>If the start angle is negative or >= 360, the start angle is treated
1143     * as start angle modulo 360.</p>
1144     *
1145     * <p>If the sweep angle is >= 360, then the oval is drawn
1146     * completely. Note that this differs slightly from SkPath::arcTo, which
1147     * treats the sweep angle modulo 360. If the sweep angle is negative,
1148     * the sweep angle is treated as sweep angle modulo 360</p>
1149     *
1150     * <p>The arc is drawn clockwise. An angle of 0 degrees correspond to the
1151     * geometric angle of 0 degrees (3 o'clock on a watch.)</p>
1152     *
1153     * @param startAngle Starting angle (in degrees) where the arc begins
1154     * @param sweepAngle Sweep angle (in degrees) measured clockwise
1155     * @param useCenter If true, include the center of the oval in the arc, and
1156                        close it if it is being stroked. This will draw a wedge
1157     * @param paint      The paint used to draw the arc
1158     */
1159    public void drawArc(float left, float top, float right, float bottom, float startAngle,
1160            float sweepAngle, boolean useCenter, @NonNull Paint paint) {
1161        super.drawArc(left, top, right, bottom, startAngle, sweepAngle, useCenter, paint);
1162    }
1163
1164    /**
1165     * <p>Draw the specified arc, which will be scaled to fit inside the
1166     * specified oval.</p>
1167     *
1168     * <p>If the start angle is negative or >= 360, the start angle is treated
1169     * as start angle modulo 360.</p>
1170     *
1171     * <p>If the sweep angle is >= 360, then the oval is drawn
1172     * completely. Note that this differs slightly from SkPath::arcTo, which
1173     * treats the sweep angle modulo 360. If the sweep angle is negative,
1174     * the sweep angle is treated as sweep angle modulo 360</p>
1175     *
1176     * <p>The arc is drawn clockwise. An angle of 0 degrees correspond to the
1177     * geometric angle of 0 degrees (3 o'clock on a watch.)</p>
1178     *
1179     * @param oval       The bounds of oval used to define the shape and size
1180     *                   of the arc
1181     * @param startAngle Starting angle (in degrees) where the arc begins
1182     * @param sweepAngle Sweep angle (in degrees) measured clockwise
1183     * @param useCenter If true, include the center of the oval in the arc, and
1184                        close it if it is being stroked. This will draw a wedge
1185     * @param paint      The paint used to draw the arc
1186     */
1187    public void drawArc(@NonNull RectF oval, float startAngle, float sweepAngle, boolean useCenter,
1188            @NonNull Paint paint) {
1189        super.drawArc(oval, startAngle, sweepAngle, useCenter, paint);
1190    }
1191
1192    /**
1193     * Fill the entire canvas' bitmap (restricted to the current clip) with the
1194     * specified ARGB color, using srcover porterduff mode.
1195     *
1196     * @param a alpha component (0..255) of the color to draw onto the canvas
1197     * @param r red component (0..255) of the color to draw onto the canvas
1198     * @param g green component (0..255) of the color to draw onto the canvas
1199     * @param b blue component (0..255) of the color to draw onto the canvas
1200     */
1201    public void drawARGB(int a, int r, int g, int b) {
1202        super.drawARGB(a, r, g, b);
1203    }
1204
1205    /**
1206     * Draw the specified bitmap, with its top/left corner at (x,y), using
1207     * the specified paint, transformed by the current matrix.
1208     *
1209     * <p>Note: if the paint contains a maskfilter that generates a mask which
1210     * extends beyond the bitmap's original width/height (e.g. BlurMaskFilter),
1211     * then the bitmap will be drawn as if it were in a Shader with CLAMP mode.
1212     * Thus the color outside of the original width/height will be the edge
1213     * color replicated.
1214     *
1215     * <p>If the bitmap and canvas have different densities, this function
1216     * will take care of automatically scaling the bitmap to draw at the
1217     * same density as the canvas.
1218     *
1219     * @param bitmap The bitmap to be drawn
1220     * @param left   The position of the left side of the bitmap being drawn
1221     * @param top    The position of the top side of the bitmap being drawn
1222     * @param paint  The paint used to draw the bitmap (may be null)
1223     */
1224    public void drawBitmap(@NonNull Bitmap bitmap, float left, float top, @Nullable Paint paint) {
1225        super.drawBitmap(bitmap, left, top, paint);
1226    }
1227
1228    /**
1229     * Draw the bitmap using the specified matrix.
1230     *
1231     * @param bitmap The bitmap to draw
1232     * @param matrix The matrix used to transform the bitmap when it is drawn
1233     * @param paint  May be null. The paint used to draw the bitmap
1234     */
1235    public void drawBitmap(@NonNull Bitmap bitmap, @NonNull Matrix matrix, @Nullable Paint paint) {
1236        super.drawBitmap(bitmap, matrix, paint);
1237    }
1238
1239    /**
1240     * Draw the specified bitmap, scaling/translating automatically to fill
1241     * the destination rectangle. If the source rectangle is not null, it
1242     * specifies the subset of the bitmap to draw.
1243     *
1244     * <p>Note: if the paint contains a maskfilter that generates a mask which
1245     * extends beyond the bitmap's original width/height (e.g. BlurMaskFilter),
1246     * then the bitmap will be drawn as if it were in a Shader with CLAMP mode.
1247     * Thus the color outside of the original width/height will be the edge
1248     * color replicated.
1249     *
1250     * <p>This function <em>ignores the density associated with the bitmap</em>.
1251     * This is because the source and destination rectangle coordinate
1252     * spaces are in their respective densities, so must already have the
1253     * appropriate scaling factor applied.
1254     *
1255     * @param bitmap The bitmap to be drawn
1256     * @param src    May be null. The subset of the bitmap to be drawn
1257     * @param dst    The rectangle that the bitmap will be scaled/translated
1258     *               to fit into
1259     * @param paint  May be null. The paint used to draw the bitmap
1260     */
1261    public void drawBitmap(@NonNull Bitmap bitmap, @Nullable Rect src, @NonNull Rect dst,
1262            @Nullable Paint paint) {
1263        super.drawBitmap(bitmap, src, dst, paint);
1264    }
1265
1266    /**
1267         * Draw the specified bitmap, scaling/translating automatically to fill
1268         * the destination rectangle. If the source rectangle is not null, it
1269         * specifies the subset of the bitmap to draw.
1270         *
1271         * <p>Note: if the paint contains a maskfilter that generates a mask which
1272         * extends beyond the bitmap's original width/height (e.g. BlurMaskFilter),
1273         * then the bitmap will be drawn as if it were in a Shader with CLAMP mode.
1274         * Thus the color outside of the original width/height will be the edge
1275         * color replicated.
1276         *
1277         * <p>This function <em>ignores the density associated with the bitmap</em>.
1278         * This is because the source and destination rectangle coordinate
1279         * spaces are in their respective densities, so must already have the
1280         * appropriate scaling factor applied.
1281         *
1282         * @param bitmap The bitmap to be drawn
1283         * @param src    May be null. The subset of the bitmap to be drawn
1284         * @param dst    The rectangle that the bitmap will be scaled/translated
1285         *               to fit into
1286         * @param paint  May be null. The paint used to draw the bitmap
1287         */
1288        public void drawBitmap(@NonNull Bitmap bitmap, @Nullable Rect src, @NonNull RectF dst,
1289                @Nullable Paint paint) {
1290          super.drawBitmap(bitmap, src, dst, paint);
1291      }
1292
1293    /**
1294     * Treat the specified array of colors as a bitmap, and draw it. This gives
1295     * the same result as first creating a bitmap from the array, and then
1296     * drawing it, but this method avoids explicitly creating a bitmap object
1297     * which can be more efficient if the colors are changing often.
1298     *
1299     * @param colors Array of colors representing the pixels of the bitmap
1300     * @param offset Offset into the array of colors for the first pixel
1301     * @param stride The number of colors in the array between rows (must be
1302     *               >= width or <= -width).
1303     * @param x The X coordinate for where to draw the bitmap
1304     * @param y The Y coordinate for where to draw the bitmap
1305     * @param width The width of the bitmap
1306     * @param height The height of the bitmap
1307     * @param hasAlpha True if the alpha channel of the colors contains valid
1308     *                 values. If false, the alpha byte is ignored (assumed to
1309     *                 be 0xFF for every pixel).
1310     * @param paint  May be null. The paint used to draw the bitmap
1311     *
1312     * @deprecated Usage with a {@link #isHardwareAccelerated() hardware accelerated} canvas
1313     * requires an internal copy of color buffer contents every time this method is called. Using a
1314     * Bitmap avoids this copy, and allows the application to more explicitly control the lifetime
1315     * and copies of pixel data.
1316     */
1317    @Deprecated
1318    public void drawBitmap(@NonNull int[] colors, int offset, int stride, float x, float y,
1319            int width, int height, boolean hasAlpha, @Nullable Paint paint) {
1320        super.drawBitmap(colors, offset, stride, x, y, width, height, hasAlpha, paint);
1321    }
1322
1323    /**
1324     * Legacy version of drawBitmap(int[] colors, ...) that took ints for x,y
1325     *
1326     * @deprecated Usage with a {@link #isHardwareAccelerated() hardware accelerated} canvas
1327     * requires an internal copy of color buffer contents every time this method is called. Using a
1328     * Bitmap avoids this copy, and allows the application to more explicitly control the lifetime
1329     * and copies of pixel data.
1330     */
1331    @Deprecated
1332    public void drawBitmap(@NonNull int[] colors, int offset, int stride, int x, int y,
1333            int width, int height, boolean hasAlpha, @Nullable Paint paint) {
1334        super.drawBitmap(colors, offset, stride, x, y, width, height, hasAlpha, paint);
1335    }
1336
1337    /**
1338     * Draw the bitmap through the mesh, where mesh vertices are evenly
1339     * distributed across the bitmap. There are meshWidth+1 vertices across, and
1340     * meshHeight+1 vertices down. The verts array is accessed in row-major
1341     * order, so that the first meshWidth+1 vertices are distributed across the
1342     * top of the bitmap from left to right. A more general version of this
1343     * method is drawVertices().
1344     *
1345     * @param bitmap The bitmap to draw using the mesh
1346     * @param meshWidth The number of columns in the mesh. Nothing is drawn if
1347     *                  this is 0
1348     * @param meshHeight The number of rows in the mesh. Nothing is drawn if
1349     *                   this is 0
1350     * @param verts Array of x,y pairs, specifying where the mesh should be
1351     *              drawn. There must be at least
1352     *              (meshWidth+1) * (meshHeight+1) * 2 + vertOffset values
1353     *              in the array
1354     * @param vertOffset Number of verts elements to skip before drawing
1355     * @param colors May be null. Specifies a color at each vertex, which is
1356     *               interpolated across the cell, and whose values are
1357     *               multiplied by the corresponding bitmap colors. If not null,
1358     *               there must be at least (meshWidth+1) * (meshHeight+1) +
1359     *               colorOffset values in the array.
1360     * @param colorOffset Number of color elements to skip before drawing
1361     * @param paint  May be null. The paint used to draw the bitmap
1362     */
1363    public void drawBitmapMesh(@NonNull Bitmap bitmap, int meshWidth, int meshHeight,
1364            @NonNull float[] verts, int vertOffset, @Nullable int[] colors, int colorOffset,
1365            @Nullable Paint paint) {
1366        super.drawBitmapMesh(bitmap, meshWidth, meshHeight, verts, vertOffset, colors, colorOffset,
1367                paint);
1368    }
1369
1370    /**
1371     * Draw the specified circle using the specified paint. If radius is <= 0,
1372     * then nothing will be drawn. The circle will be filled or framed based
1373     * on the Style in the paint.
1374     *
1375     * @param cx     The x-coordinate of the center of the cirle to be drawn
1376     * @param cy     The y-coordinate of the center of the cirle to be drawn
1377     * @param radius The radius of the cirle to be drawn
1378     * @param paint  The paint used to draw the circle
1379     */
1380    public void drawCircle(float cx, float cy, float radius, @NonNull Paint paint) {
1381        super.drawCircle(cx, cy, radius, paint);
1382    }
1383
1384    /**
1385     * Fill the entire canvas' bitmap (restricted to the current clip) with the
1386     * specified color, using srcover porterduff mode.
1387     *
1388     * @param color the color to draw onto the canvas
1389     */
1390    public void drawColor(@ColorInt int color) {
1391        super.drawColor(color);
1392    }
1393
1394    /**
1395     * Fill the entire canvas' bitmap (restricted to the current clip) with the
1396     * specified color and porter-duff xfermode.
1397     *
1398     * @param color the color to draw with
1399     * @param mode  the porter-duff mode to apply to the color
1400     */
1401    public void drawColor(@ColorInt int color, @NonNull PorterDuff.Mode mode) {
1402        super.drawColor(color, mode);
1403    }
1404
1405    /**
1406     * Draw a line segment with the specified start and stop x,y coordinates,
1407     * using the specified paint.
1408     *
1409     * <p>Note that since a line is always "framed", the Style is ignored in the paint.</p>
1410     *
1411     * <p>Degenerate lines (length is 0) will not be drawn.</p>
1412     *
1413     * @param startX The x-coordinate of the start point of the line
1414     * @param startY The y-coordinate of the start point of the line
1415     * @param paint  The paint used to draw the line
1416     */
1417    public void drawLine(float startX, float startY, float stopX, float stopY,
1418            @NonNull Paint paint) {
1419        super.drawLine(startX, startY, stopX, stopY, paint);
1420    }
1421
1422    /**
1423     * Draw a series of lines. Each line is taken from 4 consecutive values
1424     * in the pts array. Thus to draw 1 line, the array must contain at least 4
1425     * values. This is logically the same as drawing the array as follows:
1426     * drawLine(pts[0], pts[1], pts[2], pts[3]) followed by
1427     * drawLine(pts[4], pts[5], pts[6], pts[7]) and so on.
1428     *
1429     * @param pts      Array of points to draw [x0 y0 x1 y1 x2 y2 ...]
1430     * @param offset   Number of values in the array to skip before drawing.
1431     * @param count    The number of values in the array to process, after
1432     *                 skipping "offset" of them. Since each line uses 4 values,
1433     *                 the number of "lines" that are drawn is really
1434     *                 (count >> 2).
1435     * @param paint    The paint used to draw the points
1436     */
1437    public void drawLines(@Size(multiple=4) @NonNull float[] pts, int offset, int count,
1438            @NonNull Paint paint) {
1439        super.drawLines(pts, offset, count, paint);
1440    }
1441
1442    public void drawLines(@Size(multiple=4) @NonNull float[] pts, @NonNull Paint paint) {
1443        super.drawLines(pts, paint);
1444    }
1445
1446    /**
1447     * Draw the specified oval using the specified paint. The oval will be
1448     * filled or framed based on the Style in the paint.
1449     */
1450    public void drawOval(float left, float top, float right, float bottom, @NonNull Paint paint) {
1451        super.drawOval(left, top, right, bottom, paint);
1452    }
1453
1454    /**
1455     * Draw the specified oval using the specified paint. The oval will be
1456     * filled or framed based on the Style in the paint.
1457     *
1458     * @param oval The rectangle bounds of the oval to be drawn
1459     */
1460    public void drawOval(@NonNull RectF oval, @NonNull Paint paint) {
1461        super.drawOval(oval, paint);
1462    }
1463
1464    /**
1465     * Fill the entire canvas' bitmap (restricted to the current clip) with
1466     * the specified paint. This is equivalent (but faster) to drawing an
1467     * infinitely large rectangle with the specified paint.
1468     *
1469     * @param paint The paint used to draw onto the canvas
1470     */
1471    public void drawPaint(@NonNull Paint paint) {
1472        super.drawPaint(paint);
1473    }
1474
1475    /**
1476     * Draws the specified bitmap as an N-patch (most often, a 9-patches.)
1477     *
1478     * @param patch The ninepatch object to render
1479     * @param dst The destination rectangle.
1480     * @param paint The paint to draw the bitmap with. may be null
1481     *
1482     * @hide
1483     */
1484    public void drawPatch(@NonNull NinePatch patch, @NonNull Rect dst, @Nullable Paint paint) {
1485        super.drawPatch(patch, dst, paint);
1486    }
1487
1488    /**
1489     * Draws the specified bitmap as an N-patch (most often, a 9-patches.)
1490     *
1491     * @param patch The ninepatch object to render
1492     * @param dst The destination rectangle.
1493     * @param paint The paint to draw the bitmap with. may be null
1494     *
1495     * @hide
1496     */
1497    public void drawPatch(@NonNull NinePatch patch, @NonNull RectF dst, @Nullable Paint paint) {
1498        super.drawPatch(patch, dst, paint);
1499    }
1500
1501    /**
1502     * Draw the specified path using the specified paint. The path will be
1503     * filled or framed based on the Style in the paint.
1504     *
1505     * @param path  The path to be drawn
1506     * @param paint The paint used to draw the path
1507     */
1508    public void drawPath(@NonNull Path path, @NonNull Paint paint) {
1509        super.drawPath(path, paint);
1510    }
1511
1512    /**
1513     * Helper for drawPoints() for drawing a single point.
1514     */
1515    public void drawPoint(float x, float y, @NonNull Paint paint) {
1516        super.drawPoint(x, y, paint);
1517    }
1518
1519    /**
1520     * Draw a series of points. Each point is centered at the coordinate
1521     * specified by pts[], and its diameter is specified by the paint's stroke
1522     * width (as transformed by the canvas' CTM), with special treatment for
1523     * a stroke width of 0, which always draws exactly 1 pixel (or at most 4
1524     * if antialiasing is enabled). The shape of the point is controlled by
1525     * the paint's Cap type. The shape is a square, unless the cap type is
1526     * Round, in which case the shape is a circle.
1527     *
1528     * @param pts      Array of points to draw [x0 y0 x1 y1 x2 y2 ...]
1529     * @param offset   Number of values to skip before starting to draw.
1530     * @param count    The number of values to process, after skipping offset
1531     *                 of them. Since one point uses two values, the number of
1532     *                 "points" that are drawn is really (count >> 1).
1533     * @param paint    The paint used to draw the points
1534     */
1535    public void drawPoints(@Size(multiple=2) float[] pts, int offset, int count,
1536            @NonNull Paint paint) {
1537        super.drawPoints(pts, offset, count, paint);
1538    }
1539
1540    /**
1541     * Helper for drawPoints() that assumes you want to draw the entire array
1542     */
1543    public void drawPoints(@Size(multiple=2) @NonNull float[] pts, @NonNull Paint paint) {
1544        super.drawPoints(pts, paint);
1545    }
1546
1547    /**
1548     * Draw the text in the array, with each character's origin specified by
1549     * the pos array.
1550     *
1551     * @param text     The text to be drawn
1552     * @param index    The index of the first character to draw
1553     * @param count    The number of characters to draw, starting from index.
1554     * @param pos      Array of [x,y] positions, used to position each
1555     *                 character
1556     * @param paint    The paint used for the text (e.g. color, size, style)
1557     *
1558     * @deprecated This method does not support glyph composition and decomposition and
1559     * should therefore not be used to render complex scripts. It also doesn't
1560     * handle supplementary characters (eg emoji).
1561     */
1562    @Deprecated
1563    public void drawPosText(@NonNull char[] text, int index, int count,
1564            @NonNull @Size(multiple=2) float[] pos,
1565            @NonNull Paint paint) {
1566        super.drawPosText(text, index, count, pos, paint);
1567    }
1568
1569    /**
1570     * Draw the text in the array, with each character's origin specified by
1571     * the pos array.
1572     *
1573     * @param text  The text to be drawn
1574     * @param pos   Array of [x,y] positions, used to position each character
1575     * @param paint The paint used for the text (e.g. color, size, style)
1576     *
1577     * @deprecated This method does not support glyph composition and decomposition and
1578     * should therefore not be used to render complex scripts. It also doesn't
1579     * handle supplementary characters (eg emoji).
1580     */
1581    @Deprecated
1582    public void drawPosText(@NonNull String text, @NonNull @Size(multiple=2) float[] pos,
1583            @NonNull Paint paint) {
1584        super.drawPosText(text, pos, paint);
1585    }
1586
1587    /**
1588     * Draw the specified Rect using the specified paint. The rectangle will
1589     * be filled or framed based on the Style in the paint.
1590     *
1591     * @param left   The left side of the rectangle to be drawn
1592     * @param top    The top side of the rectangle to be drawn
1593     * @param right  The right side of the rectangle to be drawn
1594     * @param bottom The bottom side of the rectangle to be drawn
1595     * @param paint  The paint used to draw the rect
1596     */
1597    public void drawRect(float left, float top, float right, float bottom, @NonNull Paint paint) {
1598        super.drawRect(left, top, right, bottom, paint);
1599    }
1600
1601    /**
1602     * Draw the specified Rect using the specified Paint. The rectangle
1603     * will be filled or framed based on the Style in the paint.
1604     *
1605     * @param r        The rectangle to be drawn.
1606     * @param paint    The paint used to draw the rectangle
1607     */
1608    public void drawRect(@NonNull Rect r, @NonNull Paint paint) {
1609        super.drawRect(r, paint);
1610    }
1611
1612    /**
1613     * Draw the specified Rect using the specified paint. The rectangle will
1614     * be filled or framed based on the Style in the paint.
1615     *
1616     * @param rect  The rect to be drawn
1617     * @param paint The paint used to draw the rect
1618     */
1619    public void drawRect(@NonNull RectF rect, @NonNull Paint paint) {
1620        super.drawRect(rect, paint);
1621    }
1622
1623    /**
1624     * Fill the entire canvas' bitmap (restricted to the current clip) with the
1625     * specified RGB color, using srcover porterduff mode.
1626     *
1627     * @param r red component (0..255) of the color to draw onto the canvas
1628     * @param g green component (0..255) of the color to draw onto the canvas
1629     * @param b blue component (0..255) of the color to draw onto the canvas
1630     */
1631    public void drawRGB(int r, int g, int b) {
1632        super.drawRGB(r, g, b);
1633    }
1634
1635    /**
1636     * Draw the specified round-rect using the specified paint. The roundrect
1637     * will be filled or framed based on the Style in the paint.
1638     *
1639     * @param rx    The x-radius of the oval used to round the corners
1640     * @param ry    The y-radius of the oval used to round the corners
1641     * @param paint The paint used to draw the roundRect
1642     */
1643    public void drawRoundRect(float left, float top, float right, float bottom, float rx, float ry,
1644            @NonNull Paint paint) {
1645        super.drawRoundRect(left, top, right, bottom, rx, ry, paint);
1646    }
1647
1648    /**
1649     * Draw the specified round-rect using the specified paint. The roundrect
1650     * will be filled or framed based on the Style in the paint.
1651     *
1652     * @param rect  The rectangular bounds of the roundRect to be drawn
1653     * @param rx    The x-radius of the oval used to round the corners
1654     * @param ry    The y-radius of the oval used to round the corners
1655     * @param paint The paint used to draw the roundRect
1656     */
1657    public void drawRoundRect(@NonNull RectF rect, float rx, float ry, @NonNull Paint paint) {
1658        super.drawRoundRect(rect, rx, ry, paint);
1659    }
1660
1661    /**
1662     * Draw the text, with origin at (x,y), using the specified paint. The
1663     * origin is interpreted based on the Align setting in the paint.
1664     *
1665     * @param text  The text to be drawn
1666     * @param x     The x-coordinate of the origin of the text being drawn
1667     * @param y     The y-coordinate of the baseline of the text being drawn
1668     * @param paint The paint used for the text (e.g. color, size, style)
1669     */
1670    public void drawText(@NonNull char[] text, int index, int count, float x, float y,
1671            @NonNull Paint paint) {
1672        super.drawText(text, index, count, x, y, paint);
1673    }
1674
1675    /**
1676     * Draw the specified range of text, specified by start/end, with its
1677     * origin at (x,y), in the specified Paint. The origin is interpreted
1678     * based on the Align setting in the Paint.
1679     *
1680     * @param text     The text to be drawn
1681     * @param start    The index of the first character in text to draw
1682     * @param end      (end - 1) is the index of the last character in text
1683     *                 to draw
1684     * @param x        The x-coordinate of origin for where to draw the text
1685     * @param y        The y-coordinate of origin for where to draw the text
1686     * @param paint The paint used for the text (e.g. color, size, style)
1687     */
1688    public void drawText(@NonNull CharSequence text, int start, int end, float x, float y,
1689            @NonNull Paint paint) {
1690        super.drawText(text, start, end, x, y, paint);
1691    }
1692
1693    /**
1694     * Draw the text, with origin at (x,y), using the specified paint. The
1695     * origin is interpreted based on the Align setting in the paint.
1696     *
1697     * @param text  The text to be drawn
1698     * @param x     The x-coordinate of the origin of the text being drawn
1699     * @param y     The y-coordinate of the baseline of the text being drawn
1700     * @param paint The paint used for the text (e.g. color, size, style)
1701     */
1702    public void drawText(@NonNull String text, float x, float y, @NonNull Paint paint) {
1703        super.drawText(text, x, y, paint);
1704    }
1705
1706    /**
1707     * Draw the text, with origin at (x,y), using the specified paint.
1708     * The origin is interpreted based on the Align setting in the paint.
1709     *
1710     * @param text  The text to be drawn
1711     * @param start The index of the first character in text to draw
1712     * @param end   (end - 1) is the index of the last character in text to draw
1713     * @param x     The x-coordinate of the origin of the text being drawn
1714     * @param y     The y-coordinate of the baseline of the text being drawn
1715     * @param paint The paint used for the text (e.g. color, size, style)
1716     */
1717    public void drawText(@NonNull String text, int start, int end, float x, float y,
1718            @NonNull Paint paint) {
1719        super.drawText(text, start, end, x, y, paint);
1720    }
1721
1722    /**
1723     * Draw the text, with origin at (x,y), using the specified paint, along
1724     * the specified path. The paint's Align setting determins where along the
1725     * path to start the text.
1726     *
1727     * @param text     The text to be drawn
1728     * @param path     The path the text should follow for its baseline
1729     * @param hOffset  The distance along the path to add to the text's
1730     *                 starting position
1731     * @param vOffset  The distance above(-) or below(+) the path to position
1732     *                 the text
1733     * @param paint    The paint used for the text (e.g. color, size, style)
1734     */
1735    public void drawTextOnPath(@NonNull char[] text, int index, int count, @NonNull Path path,
1736            float hOffset, float vOffset, @NonNull Paint paint) {
1737        super.drawTextOnPath(text, index, count, path, hOffset, vOffset, paint);
1738    }
1739
1740    /**
1741     * Draw the text, with origin at (x,y), using the specified paint, along
1742     * the specified path. The paint's Align setting determins where along the
1743     * path to start the text.
1744     *
1745     * @param text     The text to be drawn
1746     * @param path     The path the text should follow for its baseline
1747     * @param hOffset  The distance along the path to add to the text's
1748     *                 starting position
1749     * @param vOffset  The distance above(-) or below(+) the path to position
1750     *                 the text
1751     * @param paint    The paint used for the text (e.g. color, size, style)
1752     */
1753    public void drawTextOnPath(@NonNull String text, @NonNull Path path, float hOffset,
1754            float vOffset, @NonNull Paint paint) {
1755        super.drawTextOnPath(text, path, hOffset, vOffset, paint);
1756    }
1757
1758    /**
1759     * Draw a run of text, all in a single direction, with optional context for complex text
1760     * shaping.
1761     *
1762     * <p>See {@link #drawTextRun(CharSequence, int, int, int, int, float, float, boolean, Paint)}
1763     * for more details. This method uses a character array rather than CharSequence to
1764     * represent the string. Also, to be consistent with the pattern established in
1765     * {@link #drawText}, in this method {@code count} and {@code contextCount} are used rather
1766     * than offsets of the end position; {@code count = end - start, contextCount = contextEnd -
1767     * contextStart}.
1768     *
1769     * @param text the text to render
1770     * @param index the start of the text to render
1771     * @param count the count of chars to render
1772     * @param contextIndex the start of the context for shaping.  Must be
1773     *         no greater than index.
1774     * @param contextCount the number of characters in the context for shaping.
1775     *         contexIndex + contextCount must be no less than index + count.
1776     * @param x the x position at which to draw the text
1777     * @param y the y position at which to draw the text
1778     * @param isRtl whether the run is in RTL direction
1779     * @param paint the paint
1780     */
1781    public void drawTextRun(@NonNull char[] text, int index, int count, int contextIndex,
1782            int contextCount, float x, float y, boolean isRtl, @NonNull Paint paint) {
1783        super.drawTextRun(text, index, count, contextIndex, contextCount, x, y, isRtl, paint);
1784    }
1785
1786    /**
1787     * Draw a run of text, all in a single direction, with optional context for complex text
1788     * shaping.
1789     *
1790     * <p>The run of text includes the characters from {@code start} to {@code end} in the text. In
1791     * addition, the range {@code contextStart} to {@code contextEnd} is used as context for the
1792     * purpose of complex text shaping, such as Arabic text potentially shaped differently based on
1793     * the text next to it.
1794     *
1795     * <p>All text outside the range {@code contextStart..contextEnd} is ignored. The text between
1796     * {@code start} and {@code end} will be laid out and drawn.
1797     *
1798     * <p>The direction of the run is explicitly specified by {@code isRtl}. Thus, this method is
1799     * suitable only for runs of a single direction. Alignment of the text is as determined by the
1800     * Paint's TextAlign value. Further, {@code 0 <= contextStart <= start <= end <= contextEnd
1801     * <= text.length} must hold on entry.
1802     *
1803     * <p>Also see {@link android.graphics.Paint#getRunAdvance} for a corresponding method to
1804     * measure the text; the advance width of the text drawn matches the value obtained from that
1805     * method.
1806     *
1807     * @param text the text to render
1808     * @param start the start of the text to render. Data before this position
1809     *            can be used for shaping context.
1810     * @param end the end of the text to render. Data at or after this
1811     *            position can be used for shaping context.
1812     * @param contextStart the index of the start of the shaping context
1813     * @param contextEnd the index of the end of the shaping context
1814     * @param x the x position at which to draw the text
1815     * @param y the y position at which to draw the text
1816     * @param isRtl whether the run is in RTL direction
1817     * @param paint the paint
1818     *
1819     * @see #drawTextRun(char[], int, int, int, int, float, float, boolean, Paint)
1820     */
1821    public void drawTextRun(@NonNull CharSequence text, int start, int end, int contextStart,
1822            int contextEnd, float x, float y, boolean isRtl, @NonNull Paint paint) {
1823        super.drawTextRun(text, start, end, contextStart, contextEnd, x, y, isRtl, paint);
1824    }
1825
1826    /**
1827     * Draw the array of vertices, interpreted as triangles (based on mode). The
1828     * verts array is required, and specifies the x,y pairs for each vertex. If
1829     * texs is non-null, then it is used to specify the coordinate in shader
1830     * coordinates to use at each vertex (the paint must have a shader in this
1831     * case). If there is no texs array, but there is a color array, then each
1832     * color is interpolated across its corresponding triangle in a gradient. If
1833     * both texs and colors arrays are present, then they behave as before, but
1834     * the resulting color at each pixels is the result of multiplying the
1835     * colors from the shader and the color-gradient together. The indices array
1836     * is optional, but if it is present, then it is used to specify the index
1837     * of each triangle, rather than just walking through the arrays in order.
1838     *
1839     * @param mode How to interpret the array of vertices
1840     * @param vertexCount The number of values in the vertices array (and
1841     *      corresponding texs and colors arrays if non-null). Each logical
1842     *      vertex is two values (x, y), vertexCount must be a multiple of 2.
1843     * @param verts Array of vertices for the mesh
1844     * @param vertOffset Number of values in the verts to skip before drawing.
1845     * @param texs May be null. If not null, specifies the coordinates to sample
1846     *      into the current shader (e.g. bitmap tile or gradient)
1847     * @param texOffset Number of values in texs to skip before drawing.
1848     * @param colors May be null. If not null, specifies a color for each
1849     *      vertex, to be interpolated across the triangle.
1850     * @param colorOffset Number of values in colors to skip before drawing.
1851     * @param indices If not null, array of indices to reference into the
1852     *      vertex (texs, colors) array.
1853     * @param indexCount number of entries in the indices array (if not null).
1854     * @param paint Specifies the shader to use if the texs array is non-null.
1855     */
1856    public void drawVertices(@NonNull VertexMode mode, int vertexCount, @NonNull float[] verts,
1857            int vertOffset, @Nullable float[] texs, int texOffset, @Nullable int[] colors,
1858            int colorOffset, @Nullable short[] indices, int indexOffset, int indexCount,
1859            @NonNull Paint paint) {
1860        super.drawVertices(mode, vertexCount, verts, vertOffset, texs, texOffset,
1861                colors, colorOffset, indices, indexOffset, indexCount, paint);
1862    }
1863}
1864