GLES20Canvas.java revision 302a9df1d50373c82923bb84ff665dfce584fb22
1e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy/* 2e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy * Copyright (C) 2010 The Android Open Source Project 3e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy * 4e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy * Licensed under the Apache License, Version 2.0 (the "License"); 5e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy * you may not use this file except in compliance with the License. 6e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy * You may obtain a copy of the License at 7e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy * 8e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy * http://www.apache.org/licenses/LICENSE-2.0 9e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy * 10e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy * Unless required by applicable law or agreed to in writing, software 11e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy * distributed under the License is distributed on an "AS IS" BASIS, 12e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy * See the License for the specific language governing permissions and 14e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy * limitations under the License. 15e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy */ 16e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy 17e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guypackage android.view; 18e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy 19e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guyimport android.graphics.Bitmap; 20e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guyimport android.graphics.Canvas; 21db1938e0e6ef816e228c815adccebd5cb05f2aa8Romain Guyimport android.graphics.ColorFilter; 22e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guyimport android.graphics.DrawFilter; 23e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guyimport android.graphics.Matrix; 24e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guyimport android.graphics.Paint; 25e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guyimport android.graphics.Path; 26e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guyimport android.graphics.Picture; 27e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guyimport android.graphics.PorterDuff; 28e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guyimport android.graphics.Rect; 29e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guyimport android.graphics.RectF; 30e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guyimport android.graphics.Region; 31d27977d1a91d5a6b3cc9fa7664ac7e835e7bd895Romain Guyimport android.graphics.Shader; 32e5e0c50f7dfaccc220725c5595080e921ffda1e4Romain Guyimport android.graphics.SurfaceTexture; 33a1db574036c9bc2d397b69f8200594027e1fff16Romain Guyimport android.graphics.TemporaryBuffer; 34a1db574036c9bc2d397b69f8200594027e1fff16Romain Guyimport android.text.GraphicsOperations; 35a1db574036c9bc2d397b69f8200594027e1fff16Romain Guyimport android.text.SpannableString; 36a1db574036c9bc2d397b69f8200594027e1fff16Romain Guyimport android.text.SpannedString; 37a1db574036c9bc2d397b69f8200594027e1fff16Romain Guyimport android.text.TextUtils; 38e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy 39e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy/** 40e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy * An implementation of Canvas on top of OpenGL ES 2.0. 41e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy */ 42b051e895ccb696604349c6c5efe7c4747e1d1ab6Romain Guyclass GLES20Canvas extends HardwareCanvas { 43a168d7372132d6c87835878794b6ed43d0d282fdRomain Guy // Must match modifiers used in the JNI layer 44a168d7372132d6c87835878794b6ed43d0d282fdRomain Guy private static final int MODIFIER_NONE = 0; 45a168d7372132d6c87835878794b6ed43d0d282fdRomain Guy private static final int MODIFIER_SHADOW = 1; 46a168d7372132d6c87835878794b6ed43d0d282fdRomain Guy private static final int MODIFIER_SHADER = 2; 47a168d7372132d6c87835878794b6ed43d0d282fdRomain Guy private static final int MODIFIER_COLOR_FILTER = 4; 48a168d7372132d6c87835878794b6ed43d0d282fdRomain Guy 49e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy private final boolean mOpaque; 50fb8b763f762ae21923c58d64caa729b012f40e05Romain Guy private int mRenderer; 51f890fab5a6715548e520a6f010a3bfe7607ce56ePatrick Dubroy 52f890fab5a6715548e520a6f010a3bfe7607ce56ePatrick Dubroy // The native renderer will be destroyed when this object dies. 53f890fab5a6715548e520a6f010a3bfe7607ce56ePatrick Dubroy // DO NOT overwrite this reference once it is set. 54eea60692b060737faeaa02bb30f5b79e2202b482Romain Guy @SuppressWarnings({"unused", "FieldCanBeLocal"}) 55f890fab5a6715548e520a6f010a3bfe7607ce56ePatrick Dubroy private CanvasFinalizer mFinalizer; 56f890fab5a6715548e520a6f010a3bfe7607ce56ePatrick Dubroy 57e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy private int mWidth; 58e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy private int mHeight; 59ce0537b80087a6225273040a987414b1dd081aa0Romain Guy 60ce0537b80087a6225273040a987414b1dd081aa0Romain Guy private final float[] mPoint = new float[2]; 61ce0537b80087a6225273040a987414b1dd081aa0Romain Guy private final float[] mLine = new float[4]; 626926c72e25b8dec3dd4b84af0819fa1937ae7296Romain Guy 636926c72e25b8dec3dd4b84af0819fa1937ae7296Romain Guy private final Rect mClipBounds = new Rect(); 646926c72e25b8dec3dd4b84af0819fa1937ae7296Romain Guy 656926c72e25b8dec3dd4b84af0819fa1937ae7296Romain Guy private DrawFilter mFilter; 66da8532c6f48b4c10b5e2ccb9e08690341efa1616Romain Guy 67163935113919a184122b8b3bd672ef08c8df65dcRomain Guy /////////////////////////////////////////////////////////////////////////// 68163935113919a184122b8b3bd672ef08c8df65dcRomain Guy // JNI 69163935113919a184122b8b3bd672ef08c8df65dcRomain Guy /////////////////////////////////////////////////////////////////////////// 70163935113919a184122b8b3bd672ef08c8df65dcRomain Guy 71163935113919a184122b8b3bd672ef08c8df65dcRomain Guy private static native boolean nIsAvailable(); 72163935113919a184122b8b3bd672ef08c8df65dcRomain Guy private static boolean sIsAvailable = nIsAvailable(); 73163935113919a184122b8b3bd672ef08c8df65dcRomain Guy 74163935113919a184122b8b3bd672ef08c8df65dcRomain Guy static boolean isAvailable() { 75163935113919a184122b8b3bd672ef08c8df65dcRomain Guy return sIsAvailable; 76163935113919a184122b8b3bd672ef08c8df65dcRomain Guy } 77e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy 78e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy /////////////////////////////////////////////////////////////////////////// 79e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy // Constructors 80e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy /////////////////////////////////////////////////////////////////////////// 81b051e895ccb696604349c6c5efe7c4747e1d1ab6Romain Guy 826c319ca1275c8db892c39b48fc54864c949f9171Romain Guy /** 836c319ca1275c8db892c39b48fc54864c949f9171Romain Guy * Creates a canvas to render directly on screen. 846c319ca1275c8db892c39b48fc54864c949f9171Romain Guy */ 85b051e895ccb696604349c6c5efe7c4747e1d1ab6Romain Guy GLES20Canvas(boolean translucent) { 86b051e895ccb696604349c6c5efe7c4747e1d1ab6Romain Guy this(false, translucent); 87b051e895ccb696604349c6c5efe7c4747e1d1ab6Romain Guy } 886c319ca1275c8db892c39b48fc54864c949f9171Romain Guy 896c319ca1275c8db892c39b48fc54864c949f9171Romain Guy /** 906c319ca1275c8db892c39b48fc54864c949f9171Romain Guy * Creates a canvas to render into an FBO. 916c319ca1275c8db892c39b48fc54864c949f9171Romain Guy */ 92ada830f639591b99c3e40de22b07296c7932a33fRomain Guy GLES20Canvas(int layer, boolean translucent) { 936c319ca1275c8db892c39b48fc54864c949f9171Romain Guy mOpaque = !translucent; 94ada830f639591b99c3e40de22b07296c7932a33fRomain Guy mRenderer = nCreateLayerRenderer(layer); 956c319ca1275c8db892c39b48fc54864c949f9171Romain Guy setupFinalizer(); 966c319ca1275c8db892c39b48fc54864c949f9171Romain Guy } 97e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy 98f890fab5a6715548e520a6f010a3bfe7607ce56ePatrick Dubroy protected GLES20Canvas(boolean record, boolean translucent) { 99e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy mOpaque = !translucent; 100e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy 101b051e895ccb696604349c6c5efe7c4747e1d1ab6Romain Guy if (record) { 102162a0217563f4665da6eb183dfce0fef740f641fJeff Brown mRenderer = nCreateDisplayListRenderer(); 103b051e895ccb696604349c6c5efe7c4747e1d1ab6Romain Guy } else { 104b051e895ccb696604349c6c5efe7c4747e1d1ab6Romain Guy mRenderer = nCreateRenderer(); 105b051e895ccb696604349c6c5efe7c4747e1d1ab6Romain Guy } 1066c319ca1275c8db892c39b48fc54864c949f9171Romain Guy 1076c319ca1275c8db892c39b48fc54864c949f9171Romain Guy setupFinalizer(); 1086c319ca1275c8db892c39b48fc54864c949f9171Romain Guy } 1096c319ca1275c8db892c39b48fc54864c949f9171Romain Guy 1106c319ca1275c8db892c39b48fc54864c949f9171Romain Guy private void setupFinalizer() { 111fb8b763f762ae21923c58d64caa729b012f40e05Romain Guy if (mRenderer == 0) { 112fb8b763f762ae21923c58d64caa729b012f40e05Romain Guy throw new IllegalStateException("Could not create GLES20Canvas renderer"); 1135c13d89c1332fcc499379b9064b891187b75ca32Chet Haase } else { 114162a0217563f4665da6eb183dfce0fef740f641fJeff Brown mFinalizer = new CanvasFinalizer(mRenderer); 115fb8b763f762ae21923c58d64caa729b012f40e05Romain Guy } 116e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy } 117b051e895ccb696604349c6c5efe7c4747e1d1ab6Romain Guy 118162a0217563f4665da6eb183dfce0fef740f641fJeff Brown protected void resetDisplayListRenderer() { 119162a0217563f4665da6eb183dfce0fef740f641fJeff Brown nResetDisplayListRenderer(mRenderer); 120162a0217563f4665da6eb183dfce0fef740f641fJeff Brown } 121162a0217563f4665da6eb183dfce0fef740f641fJeff Brown 1226c319ca1275c8db892c39b48fc54864c949f9171Romain Guy private static native int nCreateRenderer(); 123ada830f639591b99c3e40de22b07296c7932a33fRomain Guy private static native int nCreateLayerRenderer(int layer); 124162a0217563f4665da6eb183dfce0fef740f641fJeff Brown private static native int nCreateDisplayListRenderer(); 125162a0217563f4665da6eb183dfce0fef740f641fJeff Brown private static native void nResetDisplayListRenderer(int renderer); 1265c13d89c1332fcc499379b9064b891187b75ca32Chet Haase private static native void nDestroyRenderer(int renderer); 1275c13d89c1332fcc499379b9064b891187b75ca32Chet Haase 128162a0217563f4665da6eb183dfce0fef740f641fJeff Brown private static final class CanvasFinalizer { 129162a0217563f4665da6eb183dfce0fef740f641fJeff Brown private final int mRenderer; 1305977baa1fa24125c148a72699b53e62abaf08960Chet Haase 131162a0217563f4665da6eb183dfce0fef740f641fJeff Brown public CanvasFinalizer(int renderer) { 132f890fab5a6715548e520a6f010a3bfe7607ce56ePatrick Dubroy mRenderer = renderer; 1335c13d89c1332fcc499379b9064b891187b75ca32Chet Haase } 1345c13d89c1332fcc499379b9064b891187b75ca32Chet Haase 1355c13d89c1332fcc499379b9064b891187b75ca32Chet Haase @Override 136f890fab5a6715548e520a6f010a3bfe7607ce56ePatrick Dubroy protected void finalize() throws Throwable { 137171c592f0b7066acf279863c8a52ddabea49d3dbRomain Guy try { 138162a0217563f4665da6eb183dfce0fef740f641fJeff Brown nDestroyRenderer(mRenderer); 139171c592f0b7066acf279863c8a52ddabea49d3dbRomain Guy } finally { 140171c592f0b7066acf279863c8a52ddabea49d3dbRomain Guy super.finalize(); 141171c592f0b7066acf279863c8a52ddabea49d3dbRomain Guy } 142e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy } 143e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy } 144ce0537b80087a6225273040a987414b1dd081aa0Romain Guy 145e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy /////////////////////////////////////////////////////////////////////////// 1466c319ca1275c8db892c39b48fc54864c949f9171Romain Guy // Hardware layers 1476c319ca1275c8db892c39b48fc54864c949f9171Romain Guy /////////////////////////////////////////////////////////////////////////// 1486c319ca1275c8db892c39b48fc54864c949f9171Romain Guy 149a9489274d67b540804aafb587a226f7c2ae4464dRomain Guy static native int nCreateTextureLayer(boolean opaque, int[] layerInfo); 150ada830f639591b99c3e40de22b07296c7932a33fRomain Guy static native int nCreateLayer(int width, int height, boolean isOpaque, int[] layerInfo); 151ada830f639591b99c3e40de22b07296c7932a33fRomain Guy static native void nResizeLayer(int layerId, int width, int height, int[] layerInfo); 152a9489274d67b540804aafb587a226f7c2ae4464dRomain Guy static native void nUpdateTextureLayer(int layerId, int width, int height, boolean opaque, 153a9489274d67b540804aafb587a226f7c2ae4464dRomain Guy SurfaceTexture surface); 154302a9df1d50373c82923bb84ff665dfce584fb22Romain Guy static native void nSetTextureLayerTransform(int layerId, int matrix); 155ada830f639591b99c3e40de22b07296c7932a33fRomain Guy static native void nDestroyLayer(int layerId); 156ada830f639591b99c3e40de22b07296c7932a33fRomain Guy static native void nDestroyLayerDeferred(int layerId); 15777a811610f99e21da7f88dafef60d09f345d0506Romain Guy static native boolean nCopyLayer(int layerId, int bitmap); 15857066eb64c9a190d1afc87bb060bbb2d31e5b86cRomain Guy 1596c319ca1275c8db892c39b48fc54864c949f9171Romain Guy /////////////////////////////////////////////////////////////////////////// 160e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy // Canvas management 161e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy /////////////////////////////////////////////////////////////////////////// 162e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy 163e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy @Override 164e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy public boolean isOpaque() { 165e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy return mOpaque; 166e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy } 167e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy 168e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy @Override 169e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy public int getWidth() { 170e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy return mWidth; 171e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy } 172e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy 173e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy @Override 174e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy public int getHeight() { 175e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy return mHeight; 176e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy } 177e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy 178f61970fc79e9c5cf340fa942597628242361864aRomain Guy @Override 179f61970fc79e9c5cf340fa942597628242361864aRomain Guy public int getMaximumBitmapWidth() { 180f61970fc79e9c5cf340fa942597628242361864aRomain Guy return nGetMaximumTextureWidth(); 181f61970fc79e9c5cf340fa942597628242361864aRomain Guy } 182f61970fc79e9c5cf340fa942597628242361864aRomain Guy 183f61970fc79e9c5cf340fa942597628242361864aRomain Guy @Override 184f61970fc79e9c5cf340fa942597628242361864aRomain Guy public int getMaximumBitmapHeight() { 185f61970fc79e9c5cf340fa942597628242361864aRomain Guy return nGetMaximumTextureHeight(); 186f61970fc79e9c5cf340fa942597628242361864aRomain Guy } 187f61970fc79e9c5cf340fa942597628242361864aRomain Guy 188f61970fc79e9c5cf340fa942597628242361864aRomain Guy private static native int nGetMaximumTextureWidth(); 189f61970fc79e9c5cf340fa942597628242361864aRomain Guy private static native int nGetMaximumTextureHeight(); 190f61970fc79e9c5cf340fa942597628242361864aRomain Guy 191e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy /////////////////////////////////////////////////////////////////////////// 192e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy // Setup 193e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy /////////////////////////////////////////////////////////////////////////// 194e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy 195e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy @Override 196e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy public void setViewport(int width, int height) { 197e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy mWidth = width; 198e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy mHeight = height; 199e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy 200e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy nSetViewport(mRenderer, width, height); 201e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy } 202e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy 2037d7b5490a0b0763e831b31bc11f17d8159b5914aRomain Guy private static native void nSetViewport(int renderer, int width, int height); 204e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy 2057d7b5490a0b0763e831b31bc11f17d8159b5914aRomain Guy /** 2066f7d9394ec69e9fb38ca5fc2caf6d2aef6f7442dRomain Guy * Preserves the back buffer of the current surface after a buffer swap. 2076f7d9394ec69e9fb38ca5fc2caf6d2aef6f7442dRomain Guy * Calling this method sets the EGL_SWAP_BEHAVIOR attribute of the current 2086f7d9394ec69e9fb38ca5fc2caf6d2aef6f7442dRomain Guy * surface to EGL_BUFFER_PRESERVED. Calling this method requires an EGL 2096f7d9394ec69e9fb38ca5fc2caf6d2aef6f7442dRomain Guy * config that supports EGL_SWAP_BEHAVIOR_PRESERVED_BIT. 2106f7d9394ec69e9fb38ca5fc2caf6d2aef6f7442dRomain Guy * 2116f7d9394ec69e9fb38ca5fc2caf6d2aef6f7442dRomain Guy * @return True if the swap behavior was successfully changed, 2126f7d9394ec69e9fb38ca5fc2caf6d2aef6f7442dRomain Guy * false otherwise. 2136f7d9394ec69e9fb38ca5fc2caf6d2aef6f7442dRomain Guy * 2147d7b5490a0b0763e831b31bc11f17d8159b5914aRomain Guy * @hide 2157d7b5490a0b0763e831b31bc11f17d8159b5914aRomain Guy */ 2167d7b5490a0b0763e831b31bc11f17d8159b5914aRomain Guy public static boolean preserveBackBuffer() { 2177d7b5490a0b0763e831b31bc11f17d8159b5914aRomain Guy return nPreserveBackBuffer(); 2187d7b5490a0b0763e831b31bc11f17d8159b5914aRomain Guy } 2197d7b5490a0b0763e831b31bc11f17d8159b5914aRomain Guy 2207d7b5490a0b0763e831b31bc11f17d8159b5914aRomain Guy private static native boolean nPreserveBackBuffer(); 2216f7d9394ec69e9fb38ca5fc2caf6d2aef6f7442dRomain Guy 2226f7d9394ec69e9fb38ca5fc2caf6d2aef6f7442dRomain Guy /** 2236f7d9394ec69e9fb38ca5fc2caf6d2aef6f7442dRomain Guy * Indicates whether the current surface preserves its back buffer 2246f7d9394ec69e9fb38ca5fc2caf6d2aef6f7442dRomain Guy * after a buffer swap. 2256f7d9394ec69e9fb38ca5fc2caf6d2aef6f7442dRomain Guy * 2266f7d9394ec69e9fb38ca5fc2caf6d2aef6f7442dRomain Guy * @return True, if the surface's EGL_SWAP_BEHAVIOR is EGL_BUFFER_PRESERVED, 2276f7d9394ec69e9fb38ca5fc2caf6d2aef6f7442dRomain Guy * false otherwise 2286f7d9394ec69e9fb38ca5fc2caf6d2aef6f7442dRomain Guy * 2296f7d9394ec69e9fb38ca5fc2caf6d2aef6f7442dRomain Guy * @hide 2306f7d9394ec69e9fb38ca5fc2caf6d2aef6f7442dRomain Guy */ 2316f7d9394ec69e9fb38ca5fc2caf6d2aef6f7442dRomain Guy public static boolean isBackBufferPreserved() { 2326f7d9394ec69e9fb38ca5fc2caf6d2aef6f7442dRomain Guy return nIsBackBufferPreserved(); 2336f7d9394ec69e9fb38ca5fc2caf6d2aef6f7442dRomain Guy } 2346f7d9394ec69e9fb38ca5fc2caf6d2aef6f7442dRomain Guy 2359ace8f5e79e76893fe4ca9e4d10f6c4056330485Romain Guy private static native boolean nIsBackBufferPreserved(); 2369ace8f5e79e76893fe4ca9e4d10f6c4056330485Romain Guy 2379ace8f5e79e76893fe4ca9e4d10f6c4056330485Romain Guy /** 2389ace8f5e79e76893fe4ca9e4d10f6c4056330485Romain Guy * Disables v-sync. For performance testing only. 2399ace8f5e79e76893fe4ca9e4d10f6c4056330485Romain Guy * 2409ace8f5e79e76893fe4ca9e4d10f6c4056330485Romain Guy * @hide 2419ace8f5e79e76893fe4ca9e4d10f6c4056330485Romain Guy */ 2429ace8f5e79e76893fe4ca9e4d10f6c4056330485Romain Guy public static void disableVsync() { 2439ace8f5e79e76893fe4ca9e4d10f6c4056330485Romain Guy nDisableVsync(); 2449ace8f5e79e76893fe4ca9e4d10f6c4056330485Romain Guy } 2459ace8f5e79e76893fe4ca9e4d10f6c4056330485Romain Guy 2469ace8f5e79e76893fe4ca9e4d10f6c4056330485Romain Guy private static native void nDisableVsync(); 2479ace8f5e79e76893fe4ca9e4d10f6c4056330485Romain Guy 248b051e895ccb696604349c6c5efe7c4747e1d1ab6Romain Guy @Override 2497d7b5490a0b0763e831b31bc11f17d8159b5914aRomain Guy void onPreDraw(Rect dirty) { 2507d7b5490a0b0763e831b31bc11f17d8159b5914aRomain Guy if (dirty != null) { 2517d7b5490a0b0763e831b31bc11f17d8159b5914aRomain Guy nPrepareDirty(mRenderer, dirty.left, dirty.top, dirty.right, dirty.bottom, mOpaque); 2527d7b5490a0b0763e831b31bc11f17d8159b5914aRomain Guy } else { 2537d7b5490a0b0763e831b31bc11f17d8159b5914aRomain Guy nPrepare(mRenderer, mOpaque); 2547d7b5490a0b0763e831b31bc11f17d8159b5914aRomain Guy } 255e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy } 256b025b9c8b4efefadb01937db61a1f8ee7d2452bfRomain Guy 2577d7b5490a0b0763e831b31bc11f17d8159b5914aRomain Guy private static native void nPrepare(int renderer, boolean opaque); 2587d7b5490a0b0763e831b31bc11f17d8159b5914aRomain Guy private static native void nPrepareDirty(int renderer, int left, int top, int right, int bottom, 2597d7b5490a0b0763e831b31bc11f17d8159b5914aRomain Guy boolean opaque); 260e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy 261b051e895ccb696604349c6c5efe7c4747e1d1ab6Romain Guy @Override 262b025b9c8b4efefadb01937db61a1f8ee7d2452bfRomain Guy void onPostDraw() { 263b025b9c8b4efefadb01937db61a1f8ee7d2452bfRomain Guy nFinish(mRenderer); 264b025b9c8b4efefadb01937db61a1f8ee7d2452bfRomain Guy } 2659ace8f5e79e76893fe4ca9e4d10f6c4056330485Romain Guy 2667d7b5490a0b0763e831b31bc11f17d8159b5914aRomain Guy private static native void nFinish(int renderer); 267b025b9c8b4efefadb01937db61a1f8ee7d2452bfRomain Guy 268da8532c6f48b4c10b5e2ccb9e08690341efa1616Romain Guy @Override 269daf98e941e140e8739458126640183b9f296a2abChet Haase public boolean callDrawGLFunction(int drawGLFunction) { 270daf98e941e140e8739458126640183b9f296a2abChet Haase return nCallDrawGLFunction(mRenderer, drawGLFunction); 271daf98e941e140e8739458126640183b9f296a2abChet Haase } 272daf98e941e140e8739458126640183b9f296a2abChet Haase 2737d7b5490a0b0763e831b31bc11f17d8159b5914aRomain Guy private static native boolean nCallDrawGLFunction(int renderer, int drawGLFunction); 274daf98e941e140e8739458126640183b9f296a2abChet Haase 275bdf7609867a3f886455c51dba91623a86cceb6e2Romain Guy 276bdf7609867a3f886455c51dba91623a86cceb6e2Romain Guy /////////////////////////////////////////////////////////////////////////// 277bdf7609867a3f886455c51dba91623a86cceb6e2Romain Guy // Memory 278bdf7609867a3f886455c51dba91623a86cceb6e2Romain Guy /////////////////////////////////////////////////////////////////////////// 279bdf7609867a3f886455c51dba91623a86cceb6e2Romain Guy 280bdf7609867a3f886455c51dba91623a86cceb6e2Romain Guy /** 2816d7475d666baefaa3ba9f0dcee25238739454241Romain Guy * Must match Caches::FlushMode values 2826d7475d666baefaa3ba9f0dcee25238739454241Romain Guy * 283bdf7609867a3f886455c51dba91623a86cceb6e2Romain Guy * @see #flushCaches(int) 284bdf7609867a3f886455c51dba91623a86cceb6e2Romain Guy */ 2856d7475d666baefaa3ba9f0dcee25238739454241Romain Guy public static final int FLUSH_CACHES_LAYERS = 0; 2866d7475d666baefaa3ba9f0dcee25238739454241Romain Guy 2876d7475d666baefaa3ba9f0dcee25238739454241Romain Guy /** 2886d7475d666baefaa3ba9f0dcee25238739454241Romain Guy * Must match Caches::FlushMode values 2896d7475d666baefaa3ba9f0dcee25238739454241Romain Guy * 2906d7475d666baefaa3ba9f0dcee25238739454241Romain Guy * @see #flushCaches(int) 2916d7475d666baefaa3ba9f0dcee25238739454241Romain Guy */ 2926d7475d666baefaa3ba9f0dcee25238739454241Romain Guy public static final int FLUSH_CACHES_MODERATE = 1; 293bdf7609867a3f886455c51dba91623a86cceb6e2Romain Guy 294bdf7609867a3f886455c51dba91623a86cceb6e2Romain Guy /** 2956d7475d666baefaa3ba9f0dcee25238739454241Romain Guy * Must match Caches::FlushMode values 2966d7475d666baefaa3ba9f0dcee25238739454241Romain Guy * 297bdf7609867a3f886455c51dba91623a86cceb6e2Romain Guy * @see #flushCaches(int) 298bdf7609867a3f886455c51dba91623a86cceb6e2Romain Guy */ 2996d7475d666baefaa3ba9f0dcee25238739454241Romain Guy public static final int FLUSH_CACHES_FULL = 2; 300bdf7609867a3f886455c51dba91623a86cceb6e2Romain Guy 301bdf7609867a3f886455c51dba91623a86cceb6e2Romain Guy /** 302bdf7609867a3f886455c51dba91623a86cceb6e2Romain Guy * Flush caches to reclaim as much memory as possible. The amount of memory 303bdf7609867a3f886455c51dba91623a86cceb6e2Romain Guy * to reclaim is indicate by the level parameter. 304bdf7609867a3f886455c51dba91623a86cceb6e2Romain Guy * 305bdf7609867a3f886455c51dba91623a86cceb6e2Romain Guy * The level can be one of {@link #FLUSH_CACHES_MODERATE} or 306bdf7609867a3f886455c51dba91623a86cceb6e2Romain Guy * {@link #FLUSH_CACHES_FULL}. 307bdf7609867a3f886455c51dba91623a86cceb6e2Romain Guy * 308bdf7609867a3f886455c51dba91623a86cceb6e2Romain Guy * @param level Hint about the amount of memory to reclaim 309bdf7609867a3f886455c51dba91623a86cceb6e2Romain Guy * 310bdf7609867a3f886455c51dba91623a86cceb6e2Romain Guy * @hide 311bdf7609867a3f886455c51dba91623a86cceb6e2Romain Guy */ 312bdf7609867a3f886455c51dba91623a86cceb6e2Romain Guy public static void flushCaches(int level) { 313bdf7609867a3f886455c51dba91623a86cceb6e2Romain Guy nFlushCaches(level); 314bdf7609867a3f886455c51dba91623a86cceb6e2Romain Guy } 315bdf7609867a3f886455c51dba91623a86cceb6e2Romain Guy 316bdf7609867a3f886455c51dba91623a86cceb6e2Romain Guy private static native void nFlushCaches(int level); 317bdf7609867a3f886455c51dba91623a86cceb6e2Romain Guy 318b051e895ccb696604349c6c5efe7c4747e1d1ab6Romain Guy /////////////////////////////////////////////////////////////////////////// 319b051e895ccb696604349c6c5efe7c4747e1d1ab6Romain Guy // Display list 320b051e895ccb696604349c6c5efe7c4747e1d1ab6Romain Guy /////////////////////////////////////////////////////////////////////////// 321b051e895ccb696604349c6c5efe7c4747e1d1ab6Romain Guy 322162a0217563f4665da6eb183dfce0fef740f641fJeff Brown int getDisplayList(int displayList) { 323162a0217563f4665da6eb183dfce0fef740f641fJeff Brown return nGetDisplayList(mRenderer, displayList); 324b051e895ccb696604349c6c5efe7c4747e1d1ab6Romain Guy } 325b051e895ccb696604349c6c5efe7c4747e1d1ab6Romain Guy 326162a0217563f4665da6eb183dfce0fef740f641fJeff Brown private static native int nGetDisplayList(int renderer, int displayList); 327b051e895ccb696604349c6c5efe7c4747e1d1ab6Romain Guy 3285c13d89c1332fcc499379b9064b891187b75ca32Chet Haase static void destroyDisplayList(int displayList) { 329b051e895ccb696604349c6c5efe7c4747e1d1ab6Romain Guy nDestroyDisplayList(displayList); 330b051e895ccb696604349c6c5efe7c4747e1d1ab6Romain Guy } 331b051e895ccb696604349c6c5efe7c4747e1d1ab6Romain Guy 3325c13d89c1332fcc499379b9064b891187b75ca32Chet Haase private static native void nDestroyDisplayList(int displayList); 333b051e895ccb696604349c6c5efe7c4747e1d1ab6Romain Guy 33465b345fa22b878e141b8fd8ece9c208df00fa40fRomain Guy static int getDisplayListSize(int displayList) { 33565b345fa22b878e141b8fd8ece9c208df00fa40fRomain Guy return nGetDisplayListSize(displayList); 33665b345fa22b878e141b8fd8ece9c208df00fa40fRomain Guy } 33765b345fa22b878e141b8fd8ece9c208df00fa40fRomain Guy 33865b345fa22b878e141b8fd8ece9c208df00fa40fRomain Guy private static native int nGetDisplayListSize(int displayList); 33965b345fa22b878e141b8fd8ece9c208df00fa40fRomain Guy 340b051e895ccb696604349c6c5efe7c4747e1d1ab6Romain Guy @Override 3417b5b6abf852c039983eded25ebe43a70fef5a4abRomain Guy public boolean drawDisplayList(DisplayList displayList, int width, int height, Rect dirty) { 342cabfcc1364eb7e4de0b15b3574fba45027b45cfcRomain Guy return nDrawDisplayList(mRenderer, 343162a0217563f4665da6eb183dfce0fef740f641fJeff Brown ((GLES20DisplayList) displayList).getNativeDisplayList(), width, height, dirty); 344b051e895ccb696604349c6c5efe7c4747e1d1ab6Romain Guy } 345b051e895ccb696604349c6c5efe7c4747e1d1ab6Romain Guy 3467b5b6abf852c039983eded25ebe43a70fef5a4abRomain Guy private static native boolean nDrawDisplayList(int renderer, int displayList, 3477b5b6abf852c039983eded25ebe43a70fef5a4abRomain Guy int width, int height, Rect dirty); 348da8532c6f48b4c10b5e2ccb9e08690341efa1616Romain Guy 349ed30fd8e9a2d65ee5c8520de55b0089c219f390cChet Haase @Override 350ed30fd8e9a2d65ee5c8520de55b0089c219f390cChet Haase void outputDisplayList(DisplayList displayList) { 351162a0217563f4665da6eb183dfce0fef740f641fJeff Brown nOutputDisplayList(mRenderer, ((GLES20DisplayList) displayList).getNativeDisplayList()); 352ed30fd8e9a2d65ee5c8520de55b0089c219f390cChet Haase } 353ed30fd8e9a2d65ee5c8520de55b0089c219f390cChet Haase 354ed30fd8e9a2d65ee5c8520de55b0089c219f390cChet Haase private static native void nOutputDisplayList(int renderer, int displayList); 355ed30fd8e9a2d65ee5c8520de55b0089c219f390cChet Haase 356e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy /////////////////////////////////////////////////////////////////////////// 3576c319ca1275c8db892c39b48fc54864c949f9171Romain Guy // Hardware layer 3586c319ca1275c8db892c39b48fc54864c949f9171Romain Guy /////////////////////////////////////////////////////////////////////////// 3596c319ca1275c8db892c39b48fc54864c949f9171Romain Guy 360ada830f639591b99c3e40de22b07296c7932a33fRomain Guy void drawHardwareLayer(HardwareLayer layer, float x, float y, Paint paint) { 3616c319ca1275c8db892c39b48fc54864c949f9171Romain Guy final GLES20Layer glLayer = (GLES20Layer) layer; 362a168d7372132d6c87835878794b6ed43d0d282fdRomain Guy int modifier = paint != null ? setupColorFilter(paint) : MODIFIER_NONE; 3636c319ca1275c8db892c39b48fc54864c949f9171Romain Guy final int nativePaint = paint == null ? 0 : paint.mNativePaint; 364ada830f639591b99c3e40de22b07296c7932a33fRomain Guy nDrawLayer(mRenderer, glLayer.getLayer(), x, y, nativePaint); 365a168d7372132d6c87835878794b6ed43d0d282fdRomain Guy if (modifier != MODIFIER_NONE) nResetModifiers(mRenderer, modifier); 3666c319ca1275c8db892c39b48fc54864c949f9171Romain Guy } 3676c319ca1275c8db892c39b48fc54864c949f9171Romain Guy 3687d7b5490a0b0763e831b31bc11f17d8159b5914aRomain Guy private static native void nDrawLayer(int renderer, int layer, float x, float y, int paint); 369aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy 3706c319ca1275c8db892c39b48fc54864c949f9171Romain Guy void interrupt() { 3716c319ca1275c8db892c39b48fc54864c949f9171Romain Guy nInterrupt(mRenderer); 3726c319ca1275c8db892c39b48fc54864c949f9171Romain Guy } 3736c319ca1275c8db892c39b48fc54864c949f9171Romain Guy 3746c319ca1275c8db892c39b48fc54864c949f9171Romain Guy void resume() { 3756c319ca1275c8db892c39b48fc54864c949f9171Romain Guy nResume(mRenderer); 3766c319ca1275c8db892c39b48fc54864c949f9171Romain Guy } 3776c319ca1275c8db892c39b48fc54864c949f9171Romain Guy 3787d7b5490a0b0763e831b31bc11f17d8159b5914aRomain Guy private static native void nInterrupt(int renderer); 3797d7b5490a0b0763e831b31bc11f17d8159b5914aRomain Guy private static native void nResume(int renderer); 3806c319ca1275c8db892c39b48fc54864c949f9171Romain Guy 3816c319ca1275c8db892c39b48fc54864c949f9171Romain Guy /////////////////////////////////////////////////////////////////////////// 382e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy // Clipping 383e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy /////////////////////////////////////////////////////////////////////////// 384e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy 385e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy @Override 386e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy public boolean clipPath(Path path) { 387e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy throw new UnsupportedOperationException(); 388e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy } 389e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy 390e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy @Override 391e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy public boolean clipPath(Path path, Region.Op op) { 392e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy throw new UnsupportedOperationException(); 393e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy } 394e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy 395e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy @Override 396e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy public boolean clipRect(float left, float top, float right, float bottom) { 397079ba2c85b15e882629b8d188f5fbdb42f7f8eeaRomain Guy return nClipRect(mRenderer, left, top, right, bottom, Region.Op.INTERSECT.nativeInt); 398e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy } 399bb9524b6bdddc7ac77d8628daa8b366b8a7be4a4Romain Guy 4007d7b5490a0b0763e831b31bc11f17d8159b5914aRomain Guy private static native boolean nClipRect(int renderer, float left, float top, 401079ba2c85b15e882629b8d188f5fbdb42f7f8eeaRomain Guy float right, float bottom, int op); 402e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy 403e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy @Override 404e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy public boolean clipRect(float left, float top, float right, float bottom, Region.Op op) { 405079ba2c85b15e882629b8d188f5fbdb42f7f8eeaRomain Guy return nClipRect(mRenderer, left, top, right, bottom, op.nativeInt); 406e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy } 407e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy 408e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy @Override 409e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy public boolean clipRect(int left, int top, int right, int bottom) { 410daf98e941e140e8739458126640183b9f296a2abChet Haase return nClipRect(mRenderer, left, top, right, bottom, Region.Op.INTERSECT.nativeInt); 411e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy } 412bb9524b6bdddc7ac77d8628daa8b366b8a7be4a4Romain Guy 4137d7b5490a0b0763e831b31bc11f17d8159b5914aRomain Guy private static native boolean nClipRect(int renderer, int left, int top, int right, int bottom, 4147d7b5490a0b0763e831b31bc11f17d8159b5914aRomain Guy int op); 415e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy 416e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy @Override 417e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy public boolean clipRect(Rect rect) { 418079ba2c85b15e882629b8d188f5fbdb42f7f8eeaRomain Guy return nClipRect(mRenderer, rect.left, rect.top, rect.right, rect.bottom, 419079ba2c85b15e882629b8d188f5fbdb42f7f8eeaRomain Guy Region.Op.INTERSECT.nativeInt); 420e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy } 421e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy 422e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy @Override 423e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy public boolean clipRect(Rect rect, Region.Op op) { 424079ba2c85b15e882629b8d188f5fbdb42f7f8eeaRomain Guy return nClipRect(mRenderer, rect.left, rect.top, rect.right, rect.bottom, op.nativeInt); 425e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy } 426e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy 427e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy @Override 428e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy public boolean clipRect(RectF rect) { 429079ba2c85b15e882629b8d188f5fbdb42f7f8eeaRomain Guy return nClipRect(mRenderer, rect.left, rect.top, rect.right, rect.bottom, 430079ba2c85b15e882629b8d188f5fbdb42f7f8eeaRomain Guy Region.Op.INTERSECT.nativeInt); 431e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy } 432e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy 433e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy @Override 434e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy public boolean clipRect(RectF rect, Region.Op op) { 435079ba2c85b15e882629b8d188f5fbdb42f7f8eeaRomain Guy return nClipRect(mRenderer, rect.left, rect.top, rect.right, rect.bottom, op.nativeInt); 436e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy } 437e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy 438e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy @Override 439e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy public boolean clipRegion(Region region) { 440e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy throw new UnsupportedOperationException(); 441e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy } 442e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy 443e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy @Override 444e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy public boolean clipRegion(Region region, Region.Op op) { 445e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy throw new UnsupportedOperationException(); 446e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy } 447e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy 448e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy @Override 449e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy public boolean getClipBounds(Rect bounds) { 4509d5316e3f56d138504565ff311145ac01621dff4Romain Guy return nGetClipBounds(mRenderer, bounds); 451e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy } 452e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy 4537d7b5490a0b0763e831b31bc11f17d8159b5914aRomain Guy private static native boolean nGetClipBounds(int renderer, Rect bounds); 4549d5316e3f56d138504565ff311145ac01621dff4Romain Guy 455e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy @Override 456e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy public boolean quickReject(float left, float top, float right, float bottom, EdgeType type) { 457c7d53494f1fbd9f9d74af89053ff9fdb1ccbac6cRomain Guy return nQuickReject(mRenderer, left, top, right, bottom, type.nativeInt); 458e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy } 459c7d53494f1fbd9f9d74af89053ff9fdb1ccbac6cRomain Guy 4607d7b5490a0b0763e831b31bc11f17d8159b5914aRomain Guy private static native boolean nQuickReject(int renderer, float left, float top, 461c7d53494f1fbd9f9d74af89053ff9fdb1ccbac6cRomain Guy float right, float bottom, int edge); 462e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy 463e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy @Override 464e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy public boolean quickReject(Path path, EdgeType type) { 465bb9524b6bdddc7ac77d8628daa8b366b8a7be4a4Romain Guy throw new UnsupportedOperationException(); 466e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy } 467e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy 468e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy @Override 469e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy public boolean quickReject(RectF rect, EdgeType type) { 470bb9524b6bdddc7ac77d8628daa8b366b8a7be4a4Romain Guy return quickReject(rect.left, rect.top, rect.right, rect.bottom, type); 471e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy } 472e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy 473e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy /////////////////////////////////////////////////////////////////////////// 474e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy // Transformations 475e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy /////////////////////////////////////////////////////////////////////////// 476e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy 477e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy @Override 478e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy public void translate(float dx, float dy) { 479807daf7df615b60ce6fc41355aabe3aa353cebabRomain Guy if (dx != 0.0f || dy != 0.0f) nTranslate(mRenderer, dx, dy); 480e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy } 481f6a11b8a9e25ff9861bbba19251bea84d8a5daf2Romain Guy 4827d7b5490a0b0763e831b31bc11f17d8159b5914aRomain Guy private static native void nTranslate(int renderer, float dx, float dy); 483e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy 484e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy @Override 485e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy public void skew(float sx, float sy) { 486807daf7df615b60ce6fc41355aabe3aa353cebabRomain Guy nSkew(mRenderer, sx, sy); 487e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy } 488e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy 4897d7b5490a0b0763e831b31bc11f17d8159b5914aRomain Guy private static native void nSkew(int renderer, float sx, float sy); 490807daf7df615b60ce6fc41355aabe3aa353cebabRomain Guy 491e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy @Override 492e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy public void rotate(float degrees) { 493f6a11b8a9e25ff9861bbba19251bea84d8a5daf2Romain Guy nRotate(mRenderer, degrees); 494e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy } 495f6a11b8a9e25ff9861bbba19251bea84d8a5daf2Romain Guy 4967d7b5490a0b0763e831b31bc11f17d8159b5914aRomain Guy private static native void nRotate(int renderer, float degrees); 497e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy 498e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy @Override 499e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy public void scale(float sx, float sy) { 500f6a11b8a9e25ff9861bbba19251bea84d8a5daf2Romain Guy nScale(mRenderer, sx, sy); 501e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy } 502e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy 5037d7b5490a0b0763e831b31bc11f17d8159b5914aRomain Guy private static native void nScale(int renderer, float sx, float sy); 504f6a11b8a9e25ff9861bbba19251bea84d8a5daf2Romain Guy 505e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy @Override 506e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy public void setMatrix(Matrix matrix) { 507f6a11b8a9e25ff9861bbba19251bea84d8a5daf2Romain Guy nSetMatrix(mRenderer, matrix.native_instance); 508e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy } 509f6a11b8a9e25ff9861bbba19251bea84d8a5daf2Romain Guy 5107d7b5490a0b0763e831b31bc11f17d8159b5914aRomain Guy private static native void nSetMatrix(int renderer, int matrix); 511e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy 512e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy @Override 513f6a11b8a9e25ff9861bbba19251bea84d8a5daf2Romain Guy public void getMatrix(Matrix matrix) { 514f6a11b8a9e25ff9861bbba19251bea84d8a5daf2Romain Guy nGetMatrix(mRenderer, matrix.native_instance); 515e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy } 516f6a11b8a9e25ff9861bbba19251bea84d8a5daf2Romain Guy 5177d7b5490a0b0763e831b31bc11f17d8159b5914aRomain Guy private static native void nGetMatrix(int renderer, int matrix); 518e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy 519e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy @Override 520e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy public void concat(Matrix matrix) { 521f6a11b8a9e25ff9861bbba19251bea84d8a5daf2Romain Guy nConcatMatrix(mRenderer, matrix.native_instance); 522e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy } 523e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy 5247d7b5490a0b0763e831b31bc11f17d8159b5914aRomain Guy private static native void nConcatMatrix(int renderer, int matrix); 525f6a11b8a9e25ff9861bbba19251bea84d8a5daf2Romain Guy 526e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy /////////////////////////////////////////////////////////////////////////// 527e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy // State management 528e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy /////////////////////////////////////////////////////////////////////////// 529e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy 530e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy @Override 531e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy public int save() { 5328aef54fa17f2a3753d9a8f2027629bc480088f69Romain Guy return nSave(mRenderer, Canvas.CLIP_SAVE_FLAG | Canvas.MATRIX_SAVE_FLAG); 533e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy } 534bb9524b6bdddc7ac77d8628daa8b366b8a7be4a4Romain Guy 535e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy @Override 536e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy public int save(int saveFlags) { 537bb9524b6bdddc7ac77d8628daa8b366b8a7be4a4Romain Guy return nSave(mRenderer, saveFlags); 538e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy } 539e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy 5407d7b5490a0b0763e831b31bc11f17d8159b5914aRomain Guy private static native int nSave(int renderer, int flags); 541bb9524b6bdddc7ac77d8628daa8b366b8a7be4a4Romain Guy 542e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy @Override 543e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy public int saveLayer(RectF bounds, Paint paint, int saveFlags) { 544bd6b79b40247aea7bfe13d0831c6c0472df6c636Romain Guy return saveLayer(bounds.left, bounds.top, bounds.right, bounds.bottom, paint, saveFlags); 545e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy } 546e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy 547e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy @Override 548e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy public int saveLayer(float left, float top, float right, float bottom, Paint paint, 549e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy int saveFlags) { 55001d58e43ede5ca98cbebdd166f9b0c545032c01bRomain Guy if (left < right && top < bottom) { 551a168d7372132d6c87835878794b6ed43d0d282fdRomain Guy int modifier = paint != null ? setupColorFilter(paint) : MODIFIER_NONE; 55201d58e43ede5ca98cbebdd166f9b0c545032c01bRomain Guy final int nativePaint = paint == null ? 0 : paint.mNativePaint; 55301d58e43ede5ca98cbebdd166f9b0c545032c01bRomain Guy int count = nSaveLayer(mRenderer, left, top, right, bottom, nativePaint, saveFlags); 554a168d7372132d6c87835878794b6ed43d0d282fdRomain Guy if (modifier != MODIFIER_NONE) nResetModifiers(mRenderer, modifier); 55501d58e43ede5ca98cbebdd166f9b0c545032c01bRomain Guy return count; 55601d58e43ede5ca98cbebdd166f9b0c545032c01bRomain Guy } 55701d58e43ede5ca98cbebdd166f9b0c545032c01bRomain Guy return save(saveFlags); 558e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy } 559e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy 5607d7b5490a0b0763e831b31bc11f17d8159b5914aRomain Guy private static native int nSaveLayer(int renderer, float left, float top, 5617d7b5490a0b0763e831b31bc11f17d8159b5914aRomain Guy float right, float bottom, int paint, int saveFlags); 562bd6b79b40247aea7bfe13d0831c6c0472df6c636Romain Guy 563e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy @Override 564e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy public int saveLayerAlpha(RectF bounds, int alpha, int saveFlags) { 565bd6b79b40247aea7bfe13d0831c6c0472df6c636Romain Guy return saveLayerAlpha(bounds.left, bounds.top, bounds.right, bounds.bottom, 566bd6b79b40247aea7bfe13d0831c6c0472df6c636Romain Guy alpha, saveFlags); 567e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy } 568e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy 569e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy @Override 570e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy public int saveLayerAlpha(float left, float top, float right, float bottom, int alpha, 571e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy int saveFlags) { 57201d58e43ede5ca98cbebdd166f9b0c545032c01bRomain Guy if (left < right && top < bottom) { 57301d58e43ede5ca98cbebdd166f9b0c545032c01bRomain Guy return nSaveLayerAlpha(mRenderer, left, top, right, bottom, alpha, saveFlags); 57401d58e43ede5ca98cbebdd166f9b0c545032c01bRomain Guy } 57501d58e43ede5ca98cbebdd166f9b0c545032c01bRomain Guy return save(saveFlags); 576e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy } 577e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy 5787d7b5490a0b0763e831b31bc11f17d8159b5914aRomain Guy private static native int nSaveLayerAlpha(int renderer, float left, float top, float right, 579bd6b79b40247aea7bfe13d0831c6c0472df6c636Romain Guy float bottom, int alpha, int saveFlags); 580bd6b79b40247aea7bfe13d0831c6c0472df6c636Romain Guy 581e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy @Override 582e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy public void restore() { 583bb9524b6bdddc7ac77d8628daa8b366b8a7be4a4Romain Guy nRestore(mRenderer); 584e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy } 585bb9524b6bdddc7ac77d8628daa8b366b8a7be4a4Romain Guy 5867d7b5490a0b0763e831b31bc11f17d8159b5914aRomain Guy private static native void nRestore(int renderer); 587e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy 588e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy @Override 589e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy public void restoreToCount(int saveCount) { 590bb9524b6bdddc7ac77d8628daa8b366b8a7be4a4Romain Guy nRestoreToCount(mRenderer, saveCount); 591e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy } 592e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy 5937d7b5490a0b0763e831b31bc11f17d8159b5914aRomain Guy private static native void nRestoreToCount(int renderer, int saveCount); 594bb9524b6bdddc7ac77d8628daa8b366b8a7be4a4Romain Guy 595e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy @Override 596e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy public int getSaveCount() { 597bb9524b6bdddc7ac77d8628daa8b366b8a7be4a4Romain Guy return nGetSaveCount(mRenderer); 598e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy } 599bb9524b6bdddc7ac77d8628daa8b366b8a7be4a4Romain Guy 6007d7b5490a0b0763e831b31bc11f17d8159b5914aRomain Guy private static native int nGetSaveCount(int renderer); 601e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy 602e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy /////////////////////////////////////////////////////////////////////////// 603e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy // Filtering 604e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy /////////////////////////////////////////////////////////////////////////// 605e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy 606e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy @Override 607e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy public void setDrawFilter(DrawFilter filter) { 6086926c72e25b8dec3dd4b84af0819fa1937ae7296Romain Guy mFilter = filter; 609e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy } 610e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy 611e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy @Override 612e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy public DrawFilter getDrawFilter() { 6136926c72e25b8dec3dd4b84af0819fa1937ae7296Romain Guy return mFilter; 614e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy } 615e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy 616e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy /////////////////////////////////////////////////////////////////////////// 617e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy // Drawing 618e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy /////////////////////////////////////////////////////////////////////////// 619e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy 620e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy @Override 621e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy public void drawArc(RectF oval, float startAngle, float sweepAngle, boolean useCenter, 622e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy Paint paint) { 623a168d7372132d6c87835878794b6ed43d0d282fdRomain Guy int modifiers = setupModifiers(paint); 6248b2f5267f16c295f12faab810527cd6311997e34Romain Guy nDrawArc(mRenderer, oval.left, oval.top, oval.right, oval.bottom, startAngle, sweepAngle, 6258b2f5267f16c295f12faab810527cd6311997e34Romain Guy useCenter, paint.mNativePaint); 626a168d7372132d6c87835878794b6ed43d0d282fdRomain Guy if (modifiers != MODIFIER_NONE) nResetModifiers(mRenderer, modifiers); 627e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy } 628e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy 6297d7b5490a0b0763e831b31bc11f17d8159b5914aRomain Guy private static native void nDrawArc(int renderer, float left, float top, 6307d7b5490a0b0763e831b31bc11f17d8159b5914aRomain Guy float right, float bottom, float startAngle, float sweepAngle, 6317d7b5490a0b0763e831b31bc11f17d8159b5914aRomain Guy boolean useCenter, int paint); 6328b2f5267f16c295f12faab810527cd6311997e34Romain Guy 633e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy @Override 634e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy public void drawARGB(int a, int r, int g, int b) { 63585bf02fc16784d935fb9eebfa9cb20fe46ff7951Romain Guy drawColor((a & 0xFF) << 24 | (r & 0xFF) << 16 | (g & 0xFF) << 8 | (b & 0xFF)); 636e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy } 637e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy 638e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy @Override 639deba785f122a47915756ffd991f5540d952cf937Romain Guy public void drawPatch(Bitmap bitmap, byte[] chunks, RectF dst, Paint paint) { 640d27977d1a91d5a6b3cc9fa7664ac7e835e7bd895Romain Guy // Shaders are ignored when drawing patches 641a168d7372132d6c87835878794b6ed43d0d282fdRomain Guy int modifier = paint != null ? setupColorFilter(paint) : MODIFIER_NONE; 642deba785f122a47915756ffd991f5540d952cf937Romain Guy final int nativePaint = paint == null ? 0 : paint.mNativePaint; 643e4ac2d6b5723c95e648c489b187ddde449452c13Patrick Dubroy nDrawPatch(mRenderer, bitmap.mNativeBitmap, bitmap.mBuffer, chunks, 644e4ac2d6b5723c95e648c489b187ddde449452c13Patrick Dubroy dst.left, dst.top, dst.right, dst.bottom, nativePaint); 645a168d7372132d6c87835878794b6ed43d0d282fdRomain Guy if (modifier != MODIFIER_NONE) nResetModifiers(mRenderer, modifier); 646deba785f122a47915756ffd991f5540d952cf937Romain Guy } 647deba785f122a47915756ffd991f5540d952cf937Romain Guy 6487d7b5490a0b0763e831b31bc11f17d8159b5914aRomain Guy private static native void nDrawPatch(int renderer, int bitmap, byte[] buffer, byte[] chunks, 649e4ac2d6b5723c95e648c489b187ddde449452c13Patrick Dubroy float left, float top, float right, float bottom, int paint); 650deba785f122a47915756ffd991f5540d952cf937Romain Guy 651deba785f122a47915756ffd991f5540d952cf937Romain Guy @Override 652e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy public void drawBitmap(Bitmap bitmap, float left, float top, Paint paint) { 653d27977d1a91d5a6b3cc9fa7664ac7e835e7bd895Romain Guy // Shaders are ignored when drawing bitmaps 654a168d7372132d6c87835878794b6ed43d0d282fdRomain Guy int modifiers = paint != null ? setupModifiers(bitmap, paint) : MODIFIER_NONE; 655ce0537b80087a6225273040a987414b1dd081aa0Romain Guy final int nativePaint = paint == null ? 0 : paint.mNativePaint; 656e4ac2d6b5723c95e648c489b187ddde449452c13Patrick Dubroy nDrawBitmap(mRenderer, bitmap.mNativeBitmap, bitmap.mBuffer, left, top, nativePaint); 657a168d7372132d6c87835878794b6ed43d0d282fdRomain Guy if (modifiers != MODIFIER_NONE) nResetModifiers(mRenderer, modifiers); 658e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy } 659e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy 6607d7b5490a0b0763e831b31bc11f17d8159b5914aRomain Guy private static native void nDrawBitmap( 661e4ac2d6b5723c95e648c489b187ddde449452c13Patrick Dubroy int renderer, int bitmap, byte[] buffer, float left, float top, int paint); 662dbd77cd444f89d94ec5333223c1bc17dbe0c90cdRomain Guy 663e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy @Override 664e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy public void drawBitmap(Bitmap bitmap, Matrix matrix, Paint paint) { 665d27977d1a91d5a6b3cc9fa7664ac7e835e7bd895Romain Guy // Shaders are ignored when drawing bitmaps 666a168d7372132d6c87835878794b6ed43d0d282fdRomain Guy int modifiers = paint != null ? setupModifiers(bitmap, paint) : MODIFIER_NONE; 667ce0537b80087a6225273040a987414b1dd081aa0Romain Guy final int nativePaint = paint == null ? 0 : paint.mNativePaint; 668e4ac2d6b5723c95e648c489b187ddde449452c13Patrick Dubroy nDrawBitmap(mRenderer, bitmap.mNativeBitmap, bitmap.mBuffer, 669e4ac2d6b5723c95e648c489b187ddde449452c13Patrick Dubroy matrix.native_instance, nativePaint); 670a168d7372132d6c87835878794b6ed43d0d282fdRomain Guy if (modifiers != MODIFIER_NONE) nResetModifiers(mRenderer, modifiers); 671e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy } 672e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy 6737d7b5490a0b0763e831b31bc11f17d8159b5914aRomain Guy private static native void nDrawBitmap(int renderer, int bitmap, byte[] buff, 6747d7b5490a0b0763e831b31bc11f17d8159b5914aRomain Guy int matrix, int paint); 675f86ef57f8bcd8ba43ce222ec6a8b4f67d3600640Romain Guy 676e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy @Override 677e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy public void drawBitmap(Bitmap bitmap, Rect src, Rect dst, Paint paint) { 678d27977d1a91d5a6b3cc9fa7664ac7e835e7bd895Romain Guy // Shaders are ignored when drawing bitmaps 679a168d7372132d6c87835878794b6ed43d0d282fdRomain Guy int modifiers = paint != null ? setupModifiers(bitmap, paint) : MODIFIER_NONE; 680ce0537b80087a6225273040a987414b1dd081aa0Romain Guy final int nativePaint = paint == null ? 0 : paint.mNativePaint; 681694b519ac647fe998fd396fe0784cc8e179aadc4Romain Guy 682694b519ac647fe998fd396fe0784cc8e179aadc4Romain Guy int left, top, right, bottom; 683694b519ac647fe998fd396fe0784cc8e179aadc4Romain Guy if (src == null) { 684694b519ac647fe998fd396fe0784cc8e179aadc4Romain Guy left = top = 0; 685694b519ac647fe998fd396fe0784cc8e179aadc4Romain Guy right = bitmap.getWidth(); 686694b519ac647fe998fd396fe0784cc8e179aadc4Romain Guy bottom = bitmap.getHeight(); 687694b519ac647fe998fd396fe0784cc8e179aadc4Romain Guy } else { 688694b519ac647fe998fd396fe0784cc8e179aadc4Romain Guy left = src.left; 689694b519ac647fe998fd396fe0784cc8e179aadc4Romain Guy right = src.right; 690694b519ac647fe998fd396fe0784cc8e179aadc4Romain Guy top = src.top; 691694b519ac647fe998fd396fe0784cc8e179aadc4Romain Guy bottom = src.bottom; 692694b519ac647fe998fd396fe0784cc8e179aadc4Romain Guy } 693694b519ac647fe998fd396fe0784cc8e179aadc4Romain Guy 694e4ac2d6b5723c95e648c489b187ddde449452c13Patrick Dubroy nDrawBitmap(mRenderer, bitmap.mNativeBitmap, bitmap.mBuffer, left, top, right, bottom, 695694b519ac647fe998fd396fe0784cc8e179aadc4Romain Guy dst.left, dst.top, dst.right, dst.bottom, nativePaint); 696a168d7372132d6c87835878794b6ed43d0d282fdRomain Guy if (modifiers != MODIFIER_NONE) nResetModifiers(mRenderer, modifiers); 697e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy } 698e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy 699e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy @Override 700e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy public void drawBitmap(Bitmap bitmap, Rect src, RectF dst, Paint paint) { 701d27977d1a91d5a6b3cc9fa7664ac7e835e7bd895Romain Guy // Shaders are ignored when drawing bitmaps 702a168d7372132d6c87835878794b6ed43d0d282fdRomain Guy int modifiers = paint != null ? setupModifiers(bitmap, paint) : MODIFIER_NONE; 703ce0537b80087a6225273040a987414b1dd081aa0Romain Guy final int nativePaint = paint == null ? 0 : paint.mNativePaint; 704e4ac2d6b5723c95e648c489b187ddde449452c13Patrick Dubroy nDrawBitmap(mRenderer, bitmap.mNativeBitmap, bitmap.mBuffer, src.left, src.top, src.right, 705e4ac2d6b5723c95e648c489b187ddde449452c13Patrick Dubroy src.bottom, dst.left, dst.top, dst.right, dst.bottom, nativePaint); 706a168d7372132d6c87835878794b6ed43d0d282fdRomain Guy if (modifiers != MODIFIER_NONE) nResetModifiers(mRenderer, modifiers); 707e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy } 708e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy 7097d7b5490a0b0763e831b31bc11f17d8159b5914aRomain Guy private static native void nDrawBitmap(int renderer, int bitmap, byte[] buffer, 710ce0537b80087a6225273040a987414b1dd081aa0Romain Guy float srcLeft, float srcTop, float srcRight, float srcBottom, 711dbd77cd444f89d94ec5333223c1bc17dbe0c90cdRomain Guy float left, float top, float right, float bottom, int paint); 712ce0537b80087a6225273040a987414b1dd081aa0Romain Guy 713e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy @Override 714e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy public void drawBitmap(int[] colors, int offset, int stride, float x, float y, 715e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy int width, int height, boolean hasAlpha, Paint paint) { 716d27977d1a91d5a6b3cc9fa7664ac7e835e7bd895Romain Guy // Shaders are ignored when drawing bitmaps 717a168d7372132d6c87835878794b6ed43d0d282fdRomain Guy int modifier = paint != null ? setupColorFilter(paint) : MODIFIER_NONE; 7186926c72e25b8dec3dd4b84af0819fa1937ae7296Romain Guy final Bitmap.Config config = hasAlpha ? Bitmap.Config.ARGB_8888 : Bitmap.Config.RGB_565; 7196926c72e25b8dec3dd4b84af0819fa1937ae7296Romain Guy final Bitmap b = Bitmap.createBitmap(colors, offset, stride, width, height, config); 7206926c72e25b8dec3dd4b84af0819fa1937ae7296Romain Guy final int nativePaint = paint == null ? 0 : paint.mNativePaint; 721e4ac2d6b5723c95e648c489b187ddde449452c13Patrick Dubroy nDrawBitmap(mRenderer, b.mNativeBitmap, b.mBuffer, x, y, nativePaint); 7226926c72e25b8dec3dd4b84af0819fa1937ae7296Romain Guy b.recycle(); 723a168d7372132d6c87835878794b6ed43d0d282fdRomain Guy if (modifier != MODIFIER_NONE) nResetModifiers(mRenderer, modifier); 724e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy } 725e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy 726e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy @Override 727e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy public void drawBitmap(int[] colors, int offset, int stride, int x, int y, 728e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy int width, int height, boolean hasAlpha, Paint paint) { 729d27977d1a91d5a6b3cc9fa7664ac7e835e7bd895Romain Guy // Shaders are ignored when drawing bitmaps 730ce0537b80087a6225273040a987414b1dd081aa0Romain Guy drawBitmap(colors, offset, stride, (float) x, (float) y, width, height, hasAlpha, paint); 731e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy } 732e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy 733e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy @Override 734e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy public void drawBitmapMesh(Bitmap bitmap, int meshWidth, int meshHeight, float[] verts, 735e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy int vertOffset, int[] colors, int colorOffset, Paint paint) { 7365a7b466a2b4b7ced739bd5c31e022de61650545aRomain Guy if (meshWidth < 0 || meshHeight < 0 || vertOffset < 0 || colorOffset < 0) { 7375a7b466a2b4b7ced739bd5c31e022de61650545aRomain Guy throw new ArrayIndexOutOfBoundsException(); 7385a7b466a2b4b7ced739bd5c31e022de61650545aRomain Guy } 7395a7b466a2b4b7ced739bd5c31e022de61650545aRomain Guy 7405a7b466a2b4b7ced739bd5c31e022de61650545aRomain Guy if (meshWidth == 0 || meshHeight == 0) { 7415a7b466a2b4b7ced739bd5c31e022de61650545aRomain Guy return; 7425a7b466a2b4b7ced739bd5c31e022de61650545aRomain Guy } 7435a7b466a2b4b7ced739bd5c31e022de61650545aRomain Guy 7445a7b466a2b4b7ced739bd5c31e022de61650545aRomain Guy final int count = (meshWidth + 1) * (meshHeight + 1); 7455a7b466a2b4b7ced739bd5c31e022de61650545aRomain Guy checkRange(verts.length, vertOffset, count * 2); 7465a7b466a2b4b7ced739bd5c31e022de61650545aRomain Guy 7475a7b466a2b4b7ced739bd5c31e022de61650545aRomain Guy // TODO: Colors are ignored for now 7485a7b466a2b4b7ced739bd5c31e022de61650545aRomain Guy colors = null; 7495a7b466a2b4b7ced739bd5c31e022de61650545aRomain Guy colorOffset = 0; 7505a7b466a2b4b7ced739bd5c31e022de61650545aRomain Guy 751a168d7372132d6c87835878794b6ed43d0d282fdRomain Guy int modifiers = paint != null ? setupModifiers(bitmap, paint) : MODIFIER_NONE; 7525a7b466a2b4b7ced739bd5c31e022de61650545aRomain Guy final int nativePaint = paint == null ? 0 : paint.mNativePaint; 7535a7b466a2b4b7ced739bd5c31e022de61650545aRomain Guy nDrawBitmapMesh(mRenderer, bitmap.mNativeBitmap, bitmap.mBuffer, meshWidth, meshHeight, 7545a7b466a2b4b7ced739bd5c31e022de61650545aRomain Guy verts, vertOffset, colors, colorOffset, nativePaint); 755a168d7372132d6c87835878794b6ed43d0d282fdRomain Guy if (modifiers != MODIFIER_NONE) nResetModifiers(mRenderer, modifiers); 756e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy } 757e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy 7587d7b5490a0b0763e831b31bc11f17d8159b5914aRomain Guy private static native void nDrawBitmapMesh(int renderer, int bitmap, byte[] buffer, 7595a7b466a2b4b7ced739bd5c31e022de61650545aRomain Guy int meshWidth, int meshHeight, float[] verts, int vertOffset, 7605a7b466a2b4b7ced739bd5c31e022de61650545aRomain Guy int[] colors, int colorOffset, int paint); 7615a7b466a2b4b7ced739bd5c31e022de61650545aRomain Guy 762e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy @Override 763e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy public void drawCircle(float cx, float cy, float radius, Paint paint) { 764a168d7372132d6c87835878794b6ed43d0d282fdRomain Guy int modifiers = setupModifiers(paint); 76501d58e43ede5ca98cbebdd166f9b0c545032c01bRomain Guy nDrawCircle(mRenderer, cx, cy, radius, paint.mNativePaint); 766a168d7372132d6c87835878794b6ed43d0d282fdRomain Guy if (modifiers != MODIFIER_NONE) nResetModifiers(mRenderer, modifiers); 767e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy } 768e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy 7697d7b5490a0b0763e831b31bc11f17d8159b5914aRomain Guy private static native void nDrawCircle(int renderer, float cx, float cy, 7707d7b5490a0b0763e831b31bc11f17d8159b5914aRomain Guy float radius, int paint); 77101d58e43ede5ca98cbebdd166f9b0c545032c01bRomain Guy 772e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy @Override 773e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy public void drawColor(int color) { 77485bf02fc16784d935fb9eebfa9cb20fe46ff7951Romain Guy drawColor(color, PorterDuff.Mode.SRC_OVER); 775e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy } 776e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy 777e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy @Override 778e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy public void drawColor(int color, PorterDuff.Mode mode) { 77985bf02fc16784d935fb9eebfa9cb20fe46ff7951Romain Guy nDrawColor(mRenderer, color, mode.nativeInt); 780e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy } 78185bf02fc16784d935fb9eebfa9cb20fe46ff7951Romain Guy 7827d7b5490a0b0763e831b31bc11f17d8159b5914aRomain Guy private static native void nDrawColor(int renderer, int color, int mode); 783e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy 784e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy @Override 785e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy public void drawLine(float startX, float startY, float stopX, float stopY, Paint paint) { 786ce0537b80087a6225273040a987414b1dd081aa0Romain Guy mLine[0] = startX; 787ce0537b80087a6225273040a987414b1dd081aa0Romain Guy mLine[1] = startY; 788ce0537b80087a6225273040a987414b1dd081aa0Romain Guy mLine[2] = stopX; 789ce0537b80087a6225273040a987414b1dd081aa0Romain Guy mLine[3] = stopY; 790759ea80dca64ad652110a129e0d8bf93fea79f61Romain Guy drawLines(mLine, 0, 4, paint); 791e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy } 792e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy 793e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy @Override 794e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy public void drawLines(float[] pts, int offset, int count, Paint paint) { 795759ea80dca64ad652110a129e0d8bf93fea79f61Romain Guy if ((offset | count) < 0 || offset + count > pts.length) { 796759ea80dca64ad652110a129e0d8bf93fea79f61Romain Guy throw new IllegalArgumentException("The lines array must contain 4 elements per line."); 797759ea80dca64ad652110a129e0d8bf93fea79f61Romain Guy } 798a168d7372132d6c87835878794b6ed43d0d282fdRomain Guy int modifiers = setupModifiers(paint); 799759ea80dca64ad652110a129e0d8bf93fea79f61Romain Guy nDrawLines(mRenderer, pts, offset, count, paint.mNativePaint); 800a168d7372132d6c87835878794b6ed43d0d282fdRomain Guy if (modifiers != MODIFIER_NONE) nResetModifiers(mRenderer, modifiers); 801e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy } 802e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy 8037d7b5490a0b0763e831b31bc11f17d8159b5914aRomain Guy private static native void nDrawLines(int renderer, float[] points, 8047d7b5490a0b0763e831b31bc11f17d8159b5914aRomain Guy int offset, int count, int paint); 805759ea80dca64ad652110a129e0d8bf93fea79f61Romain Guy 806e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy @Override 807e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy public void drawLines(float[] pts, Paint paint) { 808759ea80dca64ad652110a129e0d8bf93fea79f61Romain Guy drawLines(pts, 0, pts.length, paint); 809e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy } 810e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy 811e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy @Override 812e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy public void drawOval(RectF oval, Paint paint) { 813a168d7372132d6c87835878794b6ed43d0d282fdRomain Guy int modifiers = setupModifiers(paint); 814c1cd9ba335b293f11e1082447ef08e474710a05fRomain Guy nDrawOval(mRenderer, oval.left, oval.top, oval.right, oval.bottom, paint.mNativePaint); 815a168d7372132d6c87835878794b6ed43d0d282fdRomain Guy if (modifiers != MODIFIER_NONE) nResetModifiers(mRenderer, modifiers); 816e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy } 817e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy 8187d7b5490a0b0763e831b31bc11f17d8159b5914aRomain Guy private static native void nDrawOval(int renderer, float left, float top, 8197d7b5490a0b0763e831b31bc11f17d8159b5914aRomain Guy float right, float bottom, int paint); 820c1cd9ba335b293f11e1082447ef08e474710a05fRomain Guy 821e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy @Override 822e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy public void drawPaint(Paint paint) { 8236926c72e25b8dec3dd4b84af0819fa1937ae7296Romain Guy final Rect r = mClipBounds; 8246926c72e25b8dec3dd4b84af0819fa1937ae7296Romain Guy nGetClipBounds(mRenderer, r); 8256926c72e25b8dec3dd4b84af0819fa1937ae7296Romain Guy drawRect(r.left, r.top, r.right, r.bottom, paint); 826e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy } 827e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy 828e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy @Override 829e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy public void drawPath(Path path, Paint paint) { 830a168d7372132d6c87835878794b6ed43d0d282fdRomain Guy int modifiers = setupModifiers(paint); 831a48a1a87ba17f20f7006eaab21dcedf86c015c13Romain Guy if (path.isSimplePath) { 832a48a1a87ba17f20f7006eaab21dcedf86c015c13Romain Guy if (path.rects != null) { 833a48a1a87ba17f20f7006eaab21dcedf86c015c13Romain Guy nDrawRects(mRenderer, path.rects.mNativeRegion, paint.mNativePaint); 834a48a1a87ba17f20f7006eaab21dcedf86c015c13Romain Guy } 835a48a1a87ba17f20f7006eaab21dcedf86c015c13Romain Guy } else { 836a48a1a87ba17f20f7006eaab21dcedf86c015c13Romain Guy nDrawPath(mRenderer, path.mNativePath, paint.mNativePaint); 837a48a1a87ba17f20f7006eaab21dcedf86c015c13Romain Guy } 838a168d7372132d6c87835878794b6ed43d0d282fdRomain Guy if (modifiers != MODIFIER_NONE) nResetModifiers(mRenderer, modifiers); 839e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy } 840e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy 8417d7b5490a0b0763e831b31bc11f17d8159b5914aRomain Guy private static native void nDrawPath(int renderer, int path, int paint); 8427d7b5490a0b0763e831b31bc11f17d8159b5914aRomain Guy private static native void nDrawRects(int renderer, int region, int paint); 8437fbcc0492fca03857e3c45064f4aa040af817d55Romain Guy 844e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy @Override 845e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy public void drawPicture(Picture picture) { 846e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy throw new UnsupportedOperationException(); 847e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy } 848e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy 849e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy @Override 850e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy public void drawPicture(Picture picture, Rect dst) { 851e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy throw new UnsupportedOperationException(); 852e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy } 853e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy 854e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy @Override 855e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy public void drawPicture(Picture picture, RectF dst) { 856e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy throw new UnsupportedOperationException(); 857e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy } 858e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy 859e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy @Override 860e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy public void drawPoint(float x, float y, Paint paint) { 861ce0537b80087a6225273040a987414b1dd081aa0Romain Guy mPoint[0] = x; 862ce0537b80087a6225273040a987414b1dd081aa0Romain Guy mPoint[1] = y; 863ed6fcb034b44d9a6ac2fc72fee6030417811f234Romain Guy drawPoints(mPoint, 0, 2, paint); 864e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy } 865e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy 866e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy @Override 867ed6fcb034b44d9a6ac2fc72fee6030417811f234Romain Guy public void drawPoints(float[] pts, Paint paint) { 868ed6fcb034b44d9a6ac2fc72fee6030417811f234Romain Guy drawPoints(pts, 0, pts.length, paint); 869e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy } 870e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy 871e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy @Override 872ed6fcb034b44d9a6ac2fc72fee6030417811f234Romain Guy public void drawPoints(float[] pts, int offset, int count, Paint paint) { 873ed6fcb034b44d9a6ac2fc72fee6030417811f234Romain Guy int modifiers = setupModifiers(paint); 874ed6fcb034b44d9a6ac2fc72fee6030417811f234Romain Guy nDrawPoints(mRenderer, pts, offset, count, paint.mNativePaint); 875ed6fcb034b44d9a6ac2fc72fee6030417811f234Romain Guy if (modifiers != MODIFIER_NONE) nResetModifiers(mRenderer, modifiers); 876e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy } 877e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy 878ed6fcb034b44d9a6ac2fc72fee6030417811f234Romain Guy private static native void nDrawPoints(int renderer, float[] points, 879ed6fcb034b44d9a6ac2fc72fee6030417811f234Romain Guy int offset, int count, int paint); 880ed6fcb034b44d9a6ac2fc72fee6030417811f234Romain Guy 881e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy @Override 882e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy public void drawPosText(char[] text, int index, int count, float[] pos, Paint paint) { 883c1cd9ba335b293f11e1082447ef08e474710a05fRomain Guy // TODO: Implement 884e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy } 885e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy 886e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy @Override 887e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy public void drawPosText(String text, float[] pos, Paint paint) { 888c1cd9ba335b293f11e1082447ef08e474710a05fRomain Guy // TODO: Implement 889e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy } 890e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy 891e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy @Override 892e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy public void drawRect(float left, float top, float right, float bottom, Paint paint) { 893a168d7372132d6c87835878794b6ed43d0d282fdRomain Guy int modifiers = setupModifiers(paint); 894c7d53494f1fbd9f9d74af89053ff9fdb1ccbac6cRomain Guy nDrawRect(mRenderer, left, top, right, bottom, paint.mNativePaint); 895a168d7372132d6c87835878794b6ed43d0d282fdRomain Guy if (modifiers != MODIFIER_NONE) nResetModifiers(mRenderer, modifiers); 896e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy } 897e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy 8987d7b5490a0b0763e831b31bc11f17d8159b5914aRomain Guy private static native void nDrawRect(int renderer, float left, float top, 8997d7b5490a0b0763e831b31bc11f17d8159b5914aRomain Guy float right, float bottom, int paint); 900c7d53494f1fbd9f9d74af89053ff9fdb1ccbac6cRomain Guy 901e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy @Override 902e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy public void drawRect(Rect r, Paint paint) { 903c7d53494f1fbd9f9d74af89053ff9fdb1ccbac6cRomain Guy drawRect(r.left, r.top, r.right, r.bottom, paint); 904e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy } 905e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy 906e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy @Override 907c7d53494f1fbd9f9d74af89053ff9fdb1ccbac6cRomain Guy public void drawRect(RectF r, Paint paint) { 908c7d53494f1fbd9f9d74af89053ff9fdb1ccbac6cRomain Guy drawRect(r.left, r.top, r.right, r.bottom, paint); 909e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy } 910e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy 911e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy @Override 912e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy public void drawRGB(int r, int g, int b) { 91385bf02fc16784d935fb9eebfa9cb20fe46ff7951Romain Guy drawColor(0xFF000000 | (r & 0xFF) << 16 | (g & 0xFF) << 8 | (b & 0xFF)); 914e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy } 915e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy 916e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy @Override 917e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy public void drawRoundRect(RectF rect, float rx, float ry, Paint paint) { 918a168d7372132d6c87835878794b6ed43d0d282fdRomain Guy int modifiers = setupModifiers(paint); 91901d58e43ede5ca98cbebdd166f9b0c545032c01bRomain Guy nDrawRoundRect(mRenderer, rect.left, rect.top, rect.right, rect.bottom, 92001d58e43ede5ca98cbebdd166f9b0c545032c01bRomain Guy rx, ry, paint.mNativePaint); 921a168d7372132d6c87835878794b6ed43d0d282fdRomain Guy if (modifiers != MODIFIER_NONE) nResetModifiers(mRenderer, modifiers); 922e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy } 923e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy 9247d7b5490a0b0763e831b31bc11f17d8159b5914aRomain Guy private static native void nDrawRoundRect(int renderer, float left, float top, 92501d58e43ede5ca98cbebdd166f9b0c545032c01bRomain Guy float right, float bottom, float rx, float y, int paint); 92601d58e43ede5ca98cbebdd166f9b0c545032c01bRomain Guy 927e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy @Override 928e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy public void drawText(char[] text, int index, int count, float x, float y, Paint paint) { 929a1db574036c9bc2d397b69f8200594027e1fff16Romain Guy if ((index | count | (index + count) | (text.length - index - count)) < 0) { 930a1db574036c9bc2d397b69f8200594027e1fff16Romain Guy throw new IndexOutOfBoundsException(); 931a1db574036c9bc2d397b69f8200594027e1fff16Romain Guy } 93261c8c9c5b2006d18e9310b6521c65b36ffe75ce4Romain Guy 933a168d7372132d6c87835878794b6ed43d0d282fdRomain Guy int modifiers = setupModifiers(paint); 93461c8c9c5b2006d18e9310b6521c65b36ffe75ce4Romain Guy try { 93561c8c9c5b2006d18e9310b6521c65b36ffe75ce4Romain Guy nDrawText(mRenderer, text, index, count, x, y, paint.mBidiFlags, paint.mNativePaint); 93661c8c9c5b2006d18e9310b6521c65b36ffe75ce4Romain Guy } finally { 937a168d7372132d6c87835878794b6ed43d0d282fdRomain Guy if (modifiers != MODIFIER_NONE) nResetModifiers(mRenderer, modifiers); 93861c8c9c5b2006d18e9310b6521c65b36ffe75ce4Romain Guy } 939e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy } 940a1db574036c9bc2d397b69f8200594027e1fff16Romain Guy 9417d7b5490a0b0763e831b31bc11f17d8159b5914aRomain Guy private static native void nDrawText(int renderer, char[] text, int index, int count, 9427d7b5490a0b0763e831b31bc11f17d8159b5914aRomain Guy float x, float y, int bidiFlags, int paint); 943e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy 944e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy @Override 945e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy public void drawText(CharSequence text, int start, int end, float x, float y, Paint paint) { 946a168d7372132d6c87835878794b6ed43d0d282fdRomain Guy int modifiers = setupModifiers(paint); 94761c8c9c5b2006d18e9310b6521c65b36ffe75ce4Romain Guy try { 94861c8c9c5b2006d18e9310b6521c65b36ffe75ce4Romain Guy if (text instanceof String || text instanceof SpannedString || 94961c8c9c5b2006d18e9310b6521c65b36ffe75ce4Romain Guy text instanceof SpannableString) { 95061c8c9c5b2006d18e9310b6521c65b36ffe75ce4Romain Guy nDrawText(mRenderer, text.toString(), start, end, x, y, paint.mBidiFlags, 95161c8c9c5b2006d18e9310b6521c65b36ffe75ce4Romain Guy paint.mNativePaint); 95261c8c9c5b2006d18e9310b6521c65b36ffe75ce4Romain Guy } else if (text instanceof GraphicsOperations) { 95361c8c9c5b2006d18e9310b6521c65b36ffe75ce4Romain Guy ((GraphicsOperations) text).drawText(this, start, end, x, y, 95461c8c9c5b2006d18e9310b6521c65b36ffe75ce4Romain Guy paint); 95561c8c9c5b2006d18e9310b6521c65b36ffe75ce4Romain Guy } else { 95661c8c9c5b2006d18e9310b6521c65b36ffe75ce4Romain Guy char[] buf = TemporaryBuffer.obtain(end - start); 95761c8c9c5b2006d18e9310b6521c65b36ffe75ce4Romain Guy TextUtils.getChars(text, start, end, buf, 0); 9587d7b5490a0b0763e831b31bc11f17d8159b5914aRomain Guy nDrawText(mRenderer, buf, 0, end - start, x, y, 9597d7b5490a0b0763e831b31bc11f17d8159b5914aRomain Guy paint.mBidiFlags, paint.mNativePaint); 96061c8c9c5b2006d18e9310b6521c65b36ffe75ce4Romain Guy TemporaryBuffer.recycle(buf); 96161c8c9c5b2006d18e9310b6521c65b36ffe75ce4Romain Guy } 96261c8c9c5b2006d18e9310b6521c65b36ffe75ce4Romain Guy } finally { 963a168d7372132d6c87835878794b6ed43d0d282fdRomain Guy if (modifiers != MODIFIER_NONE) nResetModifiers(mRenderer, modifiers); 964a1db574036c9bc2d397b69f8200594027e1fff16Romain Guy } 965e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy } 966e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy 967e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy @Override 968e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy public void drawText(String text, int start, int end, float x, float y, Paint paint) { 969a1db574036c9bc2d397b69f8200594027e1fff16Romain Guy if ((start | end | (end - start) | (text.length() - end)) < 0) { 970a1db574036c9bc2d397b69f8200594027e1fff16Romain Guy throw new IndexOutOfBoundsException(); 971a1db574036c9bc2d397b69f8200594027e1fff16Romain Guy } 97261c8c9c5b2006d18e9310b6521c65b36ffe75ce4Romain Guy 973a168d7372132d6c87835878794b6ed43d0d282fdRomain Guy int modifiers = setupModifiers(paint); 97461c8c9c5b2006d18e9310b6521c65b36ffe75ce4Romain Guy try { 97561c8c9c5b2006d18e9310b6521c65b36ffe75ce4Romain Guy nDrawText(mRenderer, text, start, end, x, y, paint.mBidiFlags, paint.mNativePaint); 97661c8c9c5b2006d18e9310b6521c65b36ffe75ce4Romain Guy } finally { 977a168d7372132d6c87835878794b6ed43d0d282fdRomain Guy if (modifiers != MODIFIER_NONE) nResetModifiers(mRenderer, modifiers); 97861c8c9c5b2006d18e9310b6521c65b36ffe75ce4Romain Guy } 979e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy } 980e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy 9817d7b5490a0b0763e831b31bc11f17d8159b5914aRomain Guy private static native void nDrawText(int renderer, String text, int start, int end, 9827d7b5490a0b0763e831b31bc11f17d8159b5914aRomain Guy float x, float y, int bidiFlags, int paint); 983a1db574036c9bc2d397b69f8200594027e1fff16Romain Guy 984e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy @Override 985e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy public void drawText(String text, float x, float y, Paint paint) { 986a168d7372132d6c87835878794b6ed43d0d282fdRomain Guy int modifiers = setupModifiers(paint); 98761c8c9c5b2006d18e9310b6521c65b36ffe75ce4Romain Guy try { 98861c8c9c5b2006d18e9310b6521c65b36ffe75ce4Romain Guy nDrawText(mRenderer, text, 0, text.length(), x, y, paint.mBidiFlags, 98961c8c9c5b2006d18e9310b6521c65b36ffe75ce4Romain Guy paint.mNativePaint); 99061c8c9c5b2006d18e9310b6521c65b36ffe75ce4Romain Guy } finally { 991a168d7372132d6c87835878794b6ed43d0d282fdRomain Guy if (modifiers != MODIFIER_NONE) nResetModifiers(mRenderer, modifiers); 99261c8c9c5b2006d18e9310b6521c65b36ffe75ce4Romain Guy } 993e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy } 994e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy 995e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy @Override 996e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy public void drawTextOnPath(char[] text, int index, int count, Path path, float hOffset, 997e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy float vOffset, Paint paint) { 998c1cd9ba335b293f11e1082447ef08e474710a05fRomain Guy // TODO: Implement 999e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy } 1000e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy 1001e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy @Override 1002e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy public void drawTextOnPath(String text, Path path, float hOffset, float vOffset, Paint paint) { 1003c1cd9ba335b293f11e1082447ef08e474710a05fRomain Guy // TODO: Implement 1004e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy } 1005e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy 1006e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy @Override 1007e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy public void drawTextRun(char[] text, int index, int count, int contextIndex, int contextCount, 1008e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy float x, float y, int dir, Paint paint) { 100961c8c9c5b2006d18e9310b6521c65b36ffe75ce4Romain Guy if ((index | count | text.length - index - count) < 0) { 101061c8c9c5b2006d18e9310b6521c65b36ffe75ce4Romain Guy throw new IndexOutOfBoundsException(); 101161c8c9c5b2006d18e9310b6521c65b36ffe75ce4Romain Guy } 101261c8c9c5b2006d18e9310b6521c65b36ffe75ce4Romain Guy if (dir != DIRECTION_LTR && dir != DIRECTION_RTL) { 101361c8c9c5b2006d18e9310b6521c65b36ffe75ce4Romain Guy throw new IllegalArgumentException("Unknown direction: " + dir); 101461c8c9c5b2006d18e9310b6521c65b36ffe75ce4Romain Guy } 101561c8c9c5b2006d18e9310b6521c65b36ffe75ce4Romain Guy 1016a168d7372132d6c87835878794b6ed43d0d282fdRomain Guy int modifiers = setupModifiers(paint); 101761c8c9c5b2006d18e9310b6521c65b36ffe75ce4Romain Guy try { 101861c8c9c5b2006d18e9310b6521c65b36ffe75ce4Romain Guy nDrawTextRun(mRenderer, text, index, count, contextIndex, contextCount, x, y, dir, 101961c8c9c5b2006d18e9310b6521c65b36ffe75ce4Romain Guy paint.mNativePaint); 102061c8c9c5b2006d18e9310b6521c65b36ffe75ce4Romain Guy } finally { 1021a168d7372132d6c87835878794b6ed43d0d282fdRomain Guy if (modifiers != MODIFIER_NONE) nResetModifiers(mRenderer, modifiers); 102261c8c9c5b2006d18e9310b6521c65b36ffe75ce4Romain Guy } 1023e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy } 1024e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy 10257d7b5490a0b0763e831b31bc11f17d8159b5914aRomain Guy private static native void nDrawTextRun(int renderer, char[] text, int index, int count, 102661c8c9c5b2006d18e9310b6521c65b36ffe75ce4Romain Guy int contextIndex, int contextCount, float x, float y, int dir, int nativePaint); 102761c8c9c5b2006d18e9310b6521c65b36ffe75ce4Romain Guy 1028e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy @Override 1029e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy public void drawTextRun(CharSequence text, int start, int end, int contextStart, int contextEnd, 1030e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy float x, float y, int dir, Paint paint) { 103161c8c9c5b2006d18e9310b6521c65b36ffe75ce4Romain Guy if ((start | end | end - start | text.length() - end) < 0) { 103261c8c9c5b2006d18e9310b6521c65b36ffe75ce4Romain Guy throw new IndexOutOfBoundsException(); 103361c8c9c5b2006d18e9310b6521c65b36ffe75ce4Romain Guy } 103461c8c9c5b2006d18e9310b6521c65b36ffe75ce4Romain Guy 1035a168d7372132d6c87835878794b6ed43d0d282fdRomain Guy int modifiers = setupModifiers(paint); 103661c8c9c5b2006d18e9310b6521c65b36ffe75ce4Romain Guy try { 103761c8c9c5b2006d18e9310b6521c65b36ffe75ce4Romain Guy int flags = dir == 0 ? 0 : 1; 103861c8c9c5b2006d18e9310b6521c65b36ffe75ce4Romain Guy if (text instanceof String || text instanceof SpannedString || 103961c8c9c5b2006d18e9310b6521c65b36ffe75ce4Romain Guy text instanceof SpannableString) { 104061c8c9c5b2006d18e9310b6521c65b36ffe75ce4Romain Guy nDrawTextRun(mRenderer, text.toString(), start, end, contextStart, 104161c8c9c5b2006d18e9310b6521c65b36ffe75ce4Romain Guy contextEnd, x, y, flags, paint.mNativePaint); 104261c8c9c5b2006d18e9310b6521c65b36ffe75ce4Romain Guy } else if (text instanceof GraphicsOperations) { 104361c8c9c5b2006d18e9310b6521c65b36ffe75ce4Romain Guy ((GraphicsOperations) text).drawTextRun(this, start, end, 104461c8c9c5b2006d18e9310b6521c65b36ffe75ce4Romain Guy contextStart, contextEnd, x, y, flags, paint); 104561c8c9c5b2006d18e9310b6521c65b36ffe75ce4Romain Guy } else { 104661c8c9c5b2006d18e9310b6521c65b36ffe75ce4Romain Guy int contextLen = contextEnd - contextStart; 104761c8c9c5b2006d18e9310b6521c65b36ffe75ce4Romain Guy int len = end - start; 104861c8c9c5b2006d18e9310b6521c65b36ffe75ce4Romain Guy char[] buf = TemporaryBuffer.obtain(contextLen); 104961c8c9c5b2006d18e9310b6521c65b36ffe75ce4Romain Guy TextUtils.getChars(text, contextStart, contextEnd, buf, 0); 105061c8c9c5b2006d18e9310b6521c65b36ffe75ce4Romain Guy nDrawTextRun(mRenderer, buf, start - contextStart, len, 0, contextLen, 105161c8c9c5b2006d18e9310b6521c65b36ffe75ce4Romain Guy x, y, flags, paint.mNativePaint); 105261c8c9c5b2006d18e9310b6521c65b36ffe75ce4Romain Guy TemporaryBuffer.recycle(buf); 105361c8c9c5b2006d18e9310b6521c65b36ffe75ce4Romain Guy } 105461c8c9c5b2006d18e9310b6521c65b36ffe75ce4Romain Guy } finally { 1055a168d7372132d6c87835878794b6ed43d0d282fdRomain Guy if (modifiers != MODIFIER_NONE) nResetModifiers(mRenderer, modifiers); 105661c8c9c5b2006d18e9310b6521c65b36ffe75ce4Romain Guy } 1057e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy } 1058e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy 10597d7b5490a0b0763e831b31bc11f17d8159b5914aRomain Guy private static native void nDrawTextRun(int renderer, String text, int start, int end, 106061c8c9c5b2006d18e9310b6521c65b36ffe75ce4Romain Guy int contextStart, int contextEnd, float x, float y, int flags, int nativePaint); 106161c8c9c5b2006d18e9310b6521c65b36ffe75ce4Romain Guy 1062e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy @Override 1063e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy public void drawVertices(VertexMode mode, int vertexCount, float[] verts, int vertOffset, 1064e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy float[] texs, int texOffset, int[] colors, int colorOffset, short[] indices, 1065e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy int indexOffset, int indexCount, Paint paint) { 10666926c72e25b8dec3dd4b84af0819fa1937ae7296Romain Guy // TODO: Implement 1067e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy } 1068d27977d1a91d5a6b3cc9fa7664ac7e835e7bd895Romain Guy 1069a168d7372132d6c87835878794b6ed43d0d282fdRomain Guy private int setupModifiers(Bitmap b, Paint paint) { 1070a168d7372132d6c87835878794b6ed43d0d282fdRomain Guy if (b.getConfig() == Bitmap.Config.ALPHA_8) { 1071a168d7372132d6c87835878794b6ed43d0d282fdRomain Guy return setupModifiers(paint); 1072a168d7372132d6c87835878794b6ed43d0d282fdRomain Guy } 107356215274f25d0040af00bf69b0df990894c0b4b0Romain Guy 107456215274f25d0040af00bf69b0df990894c0b4b0Romain Guy final ColorFilter filter = paint.getColorFilter(); 107556215274f25d0040af00bf69b0df990894c0b4b0Romain Guy if (filter != null) { 107656215274f25d0040af00bf69b0df990894c0b4b0Romain Guy nSetupColorFilter(mRenderer, filter.nativeColorFilter); 107756215274f25d0040af00bf69b0df990894c0b4b0Romain Guy return MODIFIER_COLOR_FILTER; 107856215274f25d0040af00bf69b0df990894c0b4b0Romain Guy } 107956215274f25d0040af00bf69b0df990894c0b4b0Romain Guy 1080a168d7372132d6c87835878794b6ed43d0d282fdRomain Guy return MODIFIER_NONE; 1081a168d7372132d6c87835878794b6ed43d0d282fdRomain Guy } 1082a168d7372132d6c87835878794b6ed43d0d282fdRomain Guy 1083a168d7372132d6c87835878794b6ed43d0d282fdRomain Guy private int setupModifiers(Paint paint) { 1084a168d7372132d6c87835878794b6ed43d0d282fdRomain Guy int modifiers = MODIFIER_NONE; 1085db1938e0e6ef816e228c815adccebd5cb05f2aa8Romain Guy 10861e45aae5de003657e5d18f74d34998f5de5db5b7Romain Guy if (paint.hasShadow) { 10871e45aae5de003657e5d18f74d34998f5de5db5b7Romain Guy nSetupShadow(mRenderer, paint.shadowRadius, paint.shadowDx, paint.shadowDy, 10881e45aae5de003657e5d18f74d34998f5de5db5b7Romain Guy paint.shadowColor); 1089a168d7372132d6c87835878794b6ed43d0d282fdRomain Guy modifiers |= MODIFIER_SHADOW; 10901e45aae5de003657e5d18f74d34998f5de5db5b7Romain Guy } 10911e45aae5de003657e5d18f74d34998f5de5db5b7Romain Guy 1092d27977d1a91d5a6b3cc9fa7664ac7e835e7bd895Romain Guy final Shader shader = paint.getShader(); 1093d27977d1a91d5a6b3cc9fa7664ac7e835e7bd895Romain Guy if (shader != null) { 109406f96e2652e4855b6520ad9dd70583677605b79aRomain Guy nSetupShader(mRenderer, shader.native_shader); 1095a168d7372132d6c87835878794b6ed43d0d282fdRomain Guy modifiers |= MODIFIER_SHADER; 1096db1938e0e6ef816e228c815adccebd5cb05f2aa8Romain Guy } 1097db1938e0e6ef816e228c815adccebd5cb05f2aa8Romain Guy 1098db1938e0e6ef816e228c815adccebd5cb05f2aa8Romain Guy final ColorFilter filter = paint.getColorFilter(); 1099db1938e0e6ef816e228c815adccebd5cb05f2aa8Romain Guy if (filter != null) { 1100db1938e0e6ef816e228c815adccebd5cb05f2aa8Romain Guy nSetupColorFilter(mRenderer, filter.nativeColorFilter); 1101a168d7372132d6c87835878794b6ed43d0d282fdRomain Guy modifiers |= MODIFIER_COLOR_FILTER; 1102db1938e0e6ef816e228c815adccebd5cb05f2aa8Romain Guy } 1103db1938e0e6ef816e228c815adccebd5cb05f2aa8Romain Guy 1104a168d7372132d6c87835878794b6ed43d0d282fdRomain Guy return modifiers; 1105db1938e0e6ef816e228c815adccebd5cb05f2aa8Romain Guy } 11061e45aae5de003657e5d18f74d34998f5de5db5b7Romain Guy 1107a168d7372132d6c87835878794b6ed43d0d282fdRomain Guy private int setupColorFilter(Paint paint) { 1108db1938e0e6ef816e228c815adccebd5cb05f2aa8Romain Guy final ColorFilter filter = paint.getColorFilter(); 1109db1938e0e6ef816e228c815adccebd5cb05f2aa8Romain Guy if (filter != null) { 1110db1938e0e6ef816e228c815adccebd5cb05f2aa8Romain Guy nSetupColorFilter(mRenderer, filter.nativeColorFilter); 1111a168d7372132d6c87835878794b6ed43d0d282fdRomain Guy return MODIFIER_COLOR_FILTER; 1112d27977d1a91d5a6b3cc9fa7664ac7e835e7bd895Romain Guy } 111356215274f25d0040af00bf69b0df990894c0b4b0Romain Guy return MODIFIER_NONE; 1114d27977d1a91d5a6b3cc9fa7664ac7e835e7bd895Romain Guy } 1115a168d7372132d6c87835878794b6ed43d0d282fdRomain Guy 11167d7b5490a0b0763e831b31bc11f17d8159b5914aRomain Guy private static native void nSetupShader(int renderer, int shader); 11177d7b5490a0b0763e831b31bc11f17d8159b5914aRomain Guy private static native void nSetupColorFilter(int renderer, int colorFilter); 11187d7b5490a0b0763e831b31bc11f17d8159b5914aRomain Guy private static native void nSetupShadow(int renderer, float radius, 11197d7b5490a0b0763e831b31bc11f17d8159b5914aRomain Guy float dx, float dy, int color); 11201e45aae5de003657e5d18f74d34998f5de5db5b7Romain Guy 1121a168d7372132d6c87835878794b6ed43d0d282fdRomain Guy private static native void nResetModifiers(int renderer, int modifiers); 1122e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy} 1123