GLES20Canvas.java revision deba785f122a47915756ffd991f5540d952cf937
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; 21e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guyimport android.graphics.DrawFilter; 22e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guyimport android.graphics.Matrix; 23e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guyimport android.graphics.Paint; 24e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guyimport android.graphics.Path; 25e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guyimport android.graphics.Picture; 26e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guyimport android.graphics.PorterDuff; 27e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guyimport android.graphics.Rect; 28e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guyimport android.graphics.RectF; 29e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guyimport android.graphics.Region; 30e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy 31e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guyimport javax.microedition.khronos.opengles.GL; 32e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy 33e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy/** 34e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy * An implementation of Canvas on top of OpenGL ES 2.0. 35e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy */ 36e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy@SuppressWarnings({"deprecation"}) 37e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guyclass GLES20Canvas extends Canvas { 38e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy @SuppressWarnings({"FieldCanBeLocal", "UnusedDeclaration"}) 39e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy private final GL mGl; 40e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy private final boolean mOpaque; 41e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy private final int mRenderer; 42e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy 43e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy private int mWidth; 44e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy private int mHeight; 45ce0537b80087a6225273040a987414b1dd081aa0Romain Guy 46ce0537b80087a6225273040a987414b1dd081aa0Romain Guy private final float[] mPoint = new float[2]; 47ce0537b80087a6225273040a987414b1dd081aa0Romain Guy private final float[] mLine = new float[4]; 48e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy 49e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy /////////////////////////////////////////////////////////////////////////// 50e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy // Constructors 51e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy /////////////////////////////////////////////////////////////////////////// 52e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy 53e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy GLES20Canvas(GL gl, boolean translucent) { 54e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy mGl = gl; 55e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy mOpaque = !translucent; 56e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy 57e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy mRenderer = nCreateRenderer(); 58e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy } 59e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy 60e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy private native int nCreateRenderer(); 61e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy 62e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy @Override 63e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy protected void finalize() throws Throwable { 64e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy try { 65e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy super.finalize(); 66e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy } finally { 67e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy nDestroyRenderer(mRenderer); 68e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy } 69e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy } 70ce0537b80087a6225273040a987414b1dd081aa0Romain Guy 71e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy private native void nDestroyRenderer(int renderer); 72e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy 73e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy /////////////////////////////////////////////////////////////////////////// 74e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy // Canvas management 75e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy /////////////////////////////////////////////////////////////////////////// 76e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy 77e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy @Override 78e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy public boolean isHardwareAccelerated() { 79e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy return true; 80e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy } 81e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy 82e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy @Override 83e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy public GL getGL() { 84e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy throw new UnsupportedOperationException(); 85e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy } 86e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy 87e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy @Override 88e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy public void setBitmap(Bitmap bitmap) { 89e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy throw new UnsupportedOperationException(); 90e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy } 91e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy 92e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy @Override 93e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy public boolean isOpaque() { 94e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy return mOpaque; 95e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy } 96e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy 97e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy @Override 98e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy public int getWidth() { 99e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy return mWidth; 100e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy } 101e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy 102e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy @Override 103e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy public int getHeight() { 104e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy return mHeight; 105e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy } 106e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy 107e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy /////////////////////////////////////////////////////////////////////////// 108e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy // Setup 109e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy /////////////////////////////////////////////////////////////////////////// 110e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy 111e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy @Override 112e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy public void setViewport(int width, int height) { 113e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy mWidth = width; 114e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy mHeight = height; 115e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy 116e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy nSetViewport(mRenderer, width, height); 117e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy } 118e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy 119e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy private native void nSetViewport(int renderer, int width, int height); 120e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy 121e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy void onPreDraw() { 122e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy nPrepare(mRenderer); 123e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy } 124e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy 125e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy private native void nPrepare(int renderer); 126e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy 127e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy /////////////////////////////////////////////////////////////////////////// 128e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy // Clipping 129e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy /////////////////////////////////////////////////////////////////////////// 130e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy 131e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy @Override 132e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy public boolean clipPath(Path path) { 133e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy throw new UnsupportedOperationException(); 134e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy } 135e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy 136e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy @Override 137e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy public boolean clipPath(Path path, Region.Op op) { 138e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy throw new UnsupportedOperationException(); 139e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy } 140e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy 141e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy @Override 142e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy public boolean clipRect(float left, float top, float right, float bottom) { 143bb9524b6bdddc7ac77d8628daa8b366b8a7be4a4Romain Guy return nClipRect(mRenderer, left, top, right, bottom); 144e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy } 145bb9524b6bdddc7ac77d8628daa8b366b8a7be4a4Romain Guy 146bb9524b6bdddc7ac77d8628daa8b366b8a7be4a4Romain Guy private native boolean nClipRect(int renderer, float left, float top, float right, float bottom); 147e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy 148e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy @Override 149e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy public boolean clipRect(float left, float top, float right, float bottom, Region.Op op) { 150e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy throw new UnsupportedOperationException(); 151e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy } 152e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy 153e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy @Override 154e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy public boolean clipRect(int left, int top, int right, int bottom) { 155bb9524b6bdddc7ac77d8628daa8b366b8a7be4a4Romain Guy return nClipRect(mRenderer, left, top, right, bottom); 156e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy } 157bb9524b6bdddc7ac77d8628daa8b366b8a7be4a4Romain Guy 158bb9524b6bdddc7ac77d8628daa8b366b8a7be4a4Romain Guy private native boolean nClipRect(int renderer, int left, int top, int right, int bottom); 159e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy 160e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy @Override 161e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy public boolean clipRect(Rect rect) { 162bb9524b6bdddc7ac77d8628daa8b366b8a7be4a4Romain Guy return clipRect(rect.left, rect.top, rect.right, rect.bottom); 163e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy } 164e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy 165e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy @Override 166e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy public boolean clipRect(Rect rect, Region.Op op) { 167e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy throw new UnsupportedOperationException(); 168e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy } 169e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy 170e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy @Override 171e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy public boolean clipRect(RectF rect) { 172bb9524b6bdddc7ac77d8628daa8b366b8a7be4a4Romain Guy return clipRect(rect.left, rect.top, rect.right, rect.bottom); 173e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy } 174e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy 175e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy @Override 176e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy public boolean clipRect(RectF rect, Region.Op op) { 177e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy throw new UnsupportedOperationException(); 178e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy } 179e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy 180e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy @Override 181e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy public boolean clipRegion(Region region) { 182e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy throw new UnsupportedOperationException(); 183e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy } 184e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy 185e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy @Override 186e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy public boolean clipRegion(Region region, Region.Op op) { 187e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy throw new UnsupportedOperationException(); 188e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy } 189e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy 190e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy @Override 191e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy public boolean getClipBounds(Rect bounds) { 1929d5316e3f56d138504565ff311145ac01621dff4Romain Guy return nGetClipBounds(mRenderer, bounds); 193e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy } 194e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy 1959d5316e3f56d138504565ff311145ac01621dff4Romain Guy private native boolean nGetClipBounds(int renderer, Rect bounds); 1969d5316e3f56d138504565ff311145ac01621dff4Romain Guy 197e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy @Override 198e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy public boolean quickReject(float left, float top, float right, float bottom, EdgeType type) { 199c7d53494f1fbd9f9d74af89053ff9fdb1ccbac6cRomain Guy return nQuickReject(mRenderer, left, top, right, bottom, type.nativeInt); 200e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy } 201c7d53494f1fbd9f9d74af89053ff9fdb1ccbac6cRomain Guy 202c7d53494f1fbd9f9d74af89053ff9fdb1ccbac6cRomain Guy private native boolean nQuickReject(int renderer, float left, float top, 203c7d53494f1fbd9f9d74af89053ff9fdb1ccbac6cRomain Guy float right, float bottom, int edge); 204e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy 205e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy @Override 206e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy public boolean quickReject(Path path, EdgeType type) { 207bb9524b6bdddc7ac77d8628daa8b366b8a7be4a4Romain Guy throw new UnsupportedOperationException(); 208e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy } 209e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy 210e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy @Override 211e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy public boolean quickReject(RectF rect, EdgeType type) { 212bb9524b6bdddc7ac77d8628daa8b366b8a7be4a4Romain Guy return quickReject(rect.left, rect.top, rect.right, rect.bottom, type); 213e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy } 214e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy 215e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy /////////////////////////////////////////////////////////////////////////// 216e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy // Transformations 217e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy /////////////////////////////////////////////////////////////////////////// 218e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy 219e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy @Override 220e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy public void translate(float dx, float dy) { 221f6a11b8a9e25ff9861bbba19251bea84d8a5daf2Romain Guy nTranslate(mRenderer, dx, dy); 222e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy } 223f6a11b8a9e25ff9861bbba19251bea84d8a5daf2Romain Guy 224f6a11b8a9e25ff9861bbba19251bea84d8a5daf2Romain Guy private native void nTranslate(int renderer, float dx, float dy); 225e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy 226e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy @Override 227e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy public void skew(float sx, float sy) { 228e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy throw new UnsupportedOperationException(); 229e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy } 230e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy 231e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy @Override 232e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy public void rotate(float degrees) { 233f6a11b8a9e25ff9861bbba19251bea84d8a5daf2Romain Guy nRotate(mRenderer, degrees); 234e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy } 235f6a11b8a9e25ff9861bbba19251bea84d8a5daf2Romain Guy 236f6a11b8a9e25ff9861bbba19251bea84d8a5daf2Romain Guy private native void nRotate(int renderer, float degrees); 237e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy 238e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy @Override 239e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy public void scale(float sx, float sy) { 240f6a11b8a9e25ff9861bbba19251bea84d8a5daf2Romain Guy nScale(mRenderer, sx, sy); 241e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy } 242e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy 243f6a11b8a9e25ff9861bbba19251bea84d8a5daf2Romain Guy private native void nScale(int renderer, float sx, float sy); 244f6a11b8a9e25ff9861bbba19251bea84d8a5daf2Romain Guy 245e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy @Override 246e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy public void setMatrix(Matrix matrix) { 247f6a11b8a9e25ff9861bbba19251bea84d8a5daf2Romain Guy nSetMatrix(mRenderer, matrix.native_instance); 248e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy } 249f6a11b8a9e25ff9861bbba19251bea84d8a5daf2Romain Guy 250f6a11b8a9e25ff9861bbba19251bea84d8a5daf2Romain Guy private native void nSetMatrix(int renderer, int matrix); 251e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy 252e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy @Override 253f6a11b8a9e25ff9861bbba19251bea84d8a5daf2Romain Guy public void getMatrix(Matrix matrix) { 254f6a11b8a9e25ff9861bbba19251bea84d8a5daf2Romain Guy nGetMatrix(mRenderer, matrix.native_instance); 255e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy } 256f6a11b8a9e25ff9861bbba19251bea84d8a5daf2Romain Guy 257f6a11b8a9e25ff9861bbba19251bea84d8a5daf2Romain Guy private native void nGetMatrix(int renderer, int matrix); 258e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy 259e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy @Override 260e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy public void concat(Matrix matrix) { 261f6a11b8a9e25ff9861bbba19251bea84d8a5daf2Romain Guy nConcatMatrix(mRenderer, matrix.native_instance); 262e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy } 263e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy 264f6a11b8a9e25ff9861bbba19251bea84d8a5daf2Romain Guy private native void nConcatMatrix(int renderer, int matrix); 265f6a11b8a9e25ff9861bbba19251bea84d8a5daf2Romain Guy 266e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy /////////////////////////////////////////////////////////////////////////// 267e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy // State management 268e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy /////////////////////////////////////////////////////////////////////////// 269e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy 270e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy @Override 271e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy public int save() { 272bb9524b6bdddc7ac77d8628daa8b366b8a7be4a4Romain Guy return nSave(mRenderer, 0); 273e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy } 274bb9524b6bdddc7ac77d8628daa8b366b8a7be4a4Romain Guy 275e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy @Override 276e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy public int save(int saveFlags) { 277bb9524b6bdddc7ac77d8628daa8b366b8a7be4a4Romain Guy return nSave(mRenderer, saveFlags); 278e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy } 279e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy 280bb9524b6bdddc7ac77d8628daa8b366b8a7be4a4Romain Guy private native int nSave(int renderer, int flags); 281bb9524b6bdddc7ac77d8628daa8b366b8a7be4a4Romain Guy 282e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy @Override 283e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy public int saveLayer(RectF bounds, Paint paint, int saveFlags) { 284bd6b79b40247aea7bfe13d0831c6c0472df6c636Romain Guy return saveLayer(bounds.left, bounds.top, bounds.right, bounds.bottom, paint, saveFlags); 285e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy } 286e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy 287e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy @Override 288e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy public int saveLayer(float left, float top, float right, float bottom, Paint paint, 289e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy int saveFlags) { 290bd6b79b40247aea7bfe13d0831c6c0472df6c636Romain Guy int nativePaint = paint == null ? 0 : paint.mNativePaint; 291bd6b79b40247aea7bfe13d0831c6c0472df6c636Romain Guy return nSaveLayer(mRenderer, left, top, right, bottom, nativePaint, saveFlags); 292e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy } 293e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy 294bd6b79b40247aea7bfe13d0831c6c0472df6c636Romain Guy private native int nSaveLayer(int renderer, float left, float top, float right, float bottom, 295bd6b79b40247aea7bfe13d0831c6c0472df6c636Romain Guy int paint, int saveFlags); 296bd6b79b40247aea7bfe13d0831c6c0472df6c636Romain Guy 297e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy @Override 298e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy public int saveLayerAlpha(RectF bounds, int alpha, int saveFlags) { 299bd6b79b40247aea7bfe13d0831c6c0472df6c636Romain Guy return saveLayerAlpha(bounds.left, bounds.top, bounds.right, bounds.bottom, 300bd6b79b40247aea7bfe13d0831c6c0472df6c636Romain Guy alpha, saveFlags); 301e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy } 302e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy 303e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy @Override 304e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy public int saveLayerAlpha(float left, float top, float right, float bottom, int alpha, 305e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy int saveFlags) { 306bd6b79b40247aea7bfe13d0831c6c0472df6c636Romain Guy return nSaveLayerAlpha(mRenderer, left, top, right, bottom, alpha, saveFlags); 307e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy } 308e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy 309bd6b79b40247aea7bfe13d0831c6c0472df6c636Romain Guy private native int nSaveLayerAlpha(int renderer, float left, float top, float right, 310bd6b79b40247aea7bfe13d0831c6c0472df6c636Romain Guy float bottom, int alpha, int saveFlags); 311bd6b79b40247aea7bfe13d0831c6c0472df6c636Romain Guy 312e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy @Override 313e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy public void restore() { 314bb9524b6bdddc7ac77d8628daa8b366b8a7be4a4Romain Guy nRestore(mRenderer); 315e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy } 316bb9524b6bdddc7ac77d8628daa8b366b8a7be4a4Romain Guy 317bb9524b6bdddc7ac77d8628daa8b366b8a7be4a4Romain Guy private native void nRestore(int renderer); 318e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy 319e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy @Override 320e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy public void restoreToCount(int saveCount) { 321bb9524b6bdddc7ac77d8628daa8b366b8a7be4a4Romain Guy nRestoreToCount(mRenderer, saveCount); 322e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy } 323e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy 324bb9524b6bdddc7ac77d8628daa8b366b8a7be4a4Romain Guy private native void nRestoreToCount(int renderer, int saveCount); 325bb9524b6bdddc7ac77d8628daa8b366b8a7be4a4Romain Guy 326e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy @Override 327e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy public int getSaveCount() { 328bb9524b6bdddc7ac77d8628daa8b366b8a7be4a4Romain Guy return nGetSaveCount(mRenderer); 329e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy } 330bb9524b6bdddc7ac77d8628daa8b366b8a7be4a4Romain Guy 331bb9524b6bdddc7ac77d8628daa8b366b8a7be4a4Romain Guy private native int nGetSaveCount(int renderer); 332e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy 333e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy /////////////////////////////////////////////////////////////////////////// 334e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy // Filtering 335e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy /////////////////////////////////////////////////////////////////////////// 336e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy 337e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy @Override 338e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy public void setDrawFilter(DrawFilter filter) { 339e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy throw new UnsupportedOperationException(); 340e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy } 341e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy 342e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy @Override 343e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy public DrawFilter getDrawFilter() { 344e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy throw new UnsupportedOperationException(); 345e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy } 346e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy 347e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy /////////////////////////////////////////////////////////////////////////// 348e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy // Drawing 349e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy /////////////////////////////////////////////////////////////////////////// 350e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy 351e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy @Override 352e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy public void drawArc(RectF oval, float startAngle, float sweepAngle, boolean useCenter, 353e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy Paint paint) { 354e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy throw new UnsupportedOperationException(); 355e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy } 356e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy 357e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy @Override 358e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy public void drawARGB(int a, int r, int g, int b) { 35985bf02fc16784d935fb9eebfa9cb20fe46ff7951Romain Guy drawColor((a & 0xFF) << 24 | (r & 0xFF) << 16 | (g & 0xFF) << 8 | (b & 0xFF)); 360e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy } 361e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy 362e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy @Override 363deba785f122a47915756ffd991f5540d952cf937Romain Guy public void drawPatch(Bitmap bitmap, byte[] chunks, RectF dst, Paint paint) { 364deba785f122a47915756ffd991f5540d952cf937Romain Guy final int nativePaint = paint == null ? 0 : paint.mNativePaint; 365deba785f122a47915756ffd991f5540d952cf937Romain Guy nDrawPatch(mRenderer, bitmap.mNativeBitmap, chunks, dst.left, dst.top, dst.right, 366deba785f122a47915756ffd991f5540d952cf937Romain Guy dst.bottom, nativePaint, bitmap.getDensity(), mDensity, mScreenDensity); 367deba785f122a47915756ffd991f5540d952cf937Romain Guy } 368deba785f122a47915756ffd991f5540d952cf937Romain Guy 369deba785f122a47915756ffd991f5540d952cf937Romain Guy private native void nDrawPatch(int renderer, int bitmap, byte[] chunks, float left, float top, 370deba785f122a47915756ffd991f5540d952cf937Romain Guy float right, float bottom, int paint, int bitmapDensity, int canvasDensity, int screenDensity); 371deba785f122a47915756ffd991f5540d952cf937Romain Guy 372deba785f122a47915756ffd991f5540d952cf937Romain Guy @Override 373e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy public void drawBitmap(Bitmap bitmap, float left, float top, Paint paint) { 374ce0537b80087a6225273040a987414b1dd081aa0Romain Guy final int nativePaint = paint == null ? 0 : paint.mNativePaint; 375ce0537b80087a6225273040a987414b1dd081aa0Romain Guy nDrawBitmap(mRenderer, bitmap.mNativeBitmap, left, top, nativePaint, 376ce0537b80087a6225273040a987414b1dd081aa0Romain Guy bitmap.getDensity(), mDensity, mScreenDensity); 377e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy } 378e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy 379e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy @Override 380e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy public void drawBitmap(Bitmap bitmap, Matrix matrix, Paint paint) { 381ce0537b80087a6225273040a987414b1dd081aa0Romain Guy final int nativePaint = paint == null ? 0 : paint.mNativePaint; 382f86ef57f8bcd8ba43ce222ec6a8b4f67d3600640Romain Guy nDrawBitmap(mRenderer, bitmap.mNativeBitmap, matrix.native_instance, nativePaint, 383ce0537b80087a6225273040a987414b1dd081aa0Romain Guy bitmap.getDensity(), mDensity, mScreenDensity); 384e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy } 385e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy 386f86ef57f8bcd8ba43ce222ec6a8b4f67d3600640Romain Guy private native void nDrawBitmap(int renderer, int bitmap, int matrix, int paint, 387f86ef57f8bcd8ba43ce222ec6a8b4f67d3600640Romain Guy int bitmapDensity, int canvasDensity, int screenDensity); 388f86ef57f8bcd8ba43ce222ec6a8b4f67d3600640Romain Guy 389e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy @Override 390e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy public void drawBitmap(Bitmap bitmap, Rect src, Rect dst, Paint paint) { 391ce0537b80087a6225273040a987414b1dd081aa0Romain Guy final int nativePaint = paint == null ? 0 : paint.mNativePaint; 392ce0537b80087a6225273040a987414b1dd081aa0Romain Guy nDrawBitmap(mRenderer, bitmap.mNativeBitmap, src.left, src.top, src.right, src.bottom, 393f86ef57f8bcd8ba43ce222ec6a8b4f67d3600640Romain Guy dst.left, dst.top, dst.right, dst.bottom, nativePaint, 394ce0537b80087a6225273040a987414b1dd081aa0Romain Guy bitmap.getDensity(), mDensity, mScreenDensity); 395e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy } 396e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy 397e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy @Override 398e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy public void drawBitmap(Bitmap bitmap, Rect src, RectF dst, Paint paint) { 399ce0537b80087a6225273040a987414b1dd081aa0Romain Guy final int nativePaint = paint == null ? 0 : paint.mNativePaint; 400ce0537b80087a6225273040a987414b1dd081aa0Romain Guy nDrawBitmap(mRenderer, bitmap.mNativeBitmap, src.left, src.top, src.right, src.bottom, 401f86ef57f8bcd8ba43ce222ec6a8b4f67d3600640Romain Guy dst.left, dst.top, dst.right, dst.bottom, nativePaint, 402ce0537b80087a6225273040a987414b1dd081aa0Romain Guy bitmap.getDensity(), mDensity, mScreenDensity); 403e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy } 404e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy 405ce0537b80087a6225273040a987414b1dd081aa0Romain Guy private native void nDrawBitmap(int renderer, int bitmap, float left, float top, int paint, 406ce0537b80087a6225273040a987414b1dd081aa0Romain Guy int bitmapDensity, int canvasDensity, int screenDensity); 407ce0537b80087a6225273040a987414b1dd081aa0Romain Guy 408ce0537b80087a6225273040a987414b1dd081aa0Romain Guy private native void nDrawBitmap(int renderer, int bitmap, 409ce0537b80087a6225273040a987414b1dd081aa0Romain Guy float srcLeft, float srcTop, float srcRight, float srcBottom, 410f86ef57f8bcd8ba43ce222ec6a8b4f67d3600640Romain Guy float left, float top, float right, float bottom, int paint, 411ce0537b80087a6225273040a987414b1dd081aa0Romain Guy int bitmapDensity, int canvasDensity, int screenDensity); 412ce0537b80087a6225273040a987414b1dd081aa0Romain Guy 413e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy @Override 414e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy public void drawBitmap(int[] colors, int offset, int stride, float x, float y, 415e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy int width, int height, boolean hasAlpha, Paint paint) { 416e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy // TODO: Implement 417e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy } 418e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy 419e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy @Override 420e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy public void drawBitmap(int[] colors, int offset, int stride, int x, int y, 421e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy int width, int height, boolean hasAlpha, Paint paint) { 422ce0537b80087a6225273040a987414b1dd081aa0Romain Guy drawBitmap(colors, offset, stride, (float) x, (float) y, width, height, hasAlpha, paint); 423e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy } 424e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy 425e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy @Override 426e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy public void drawBitmapMesh(Bitmap bitmap, int meshWidth, int meshHeight, float[] verts, 427e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy int vertOffset, int[] colors, int colorOffset, Paint paint) { 428e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy throw new UnsupportedOperationException(); 429e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy } 430e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy 431e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy @Override 432e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy public void drawCircle(float cx, float cy, float radius, Paint paint) { 433e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy throw new UnsupportedOperationException(); 434e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy } 435e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy 436e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy @Override 437e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy public void drawColor(int color) { 43885bf02fc16784d935fb9eebfa9cb20fe46ff7951Romain Guy drawColor(color, PorterDuff.Mode.SRC_OVER); 439e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy } 440e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy 441e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy @Override 442e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy public void drawColor(int color, PorterDuff.Mode mode) { 44385bf02fc16784d935fb9eebfa9cb20fe46ff7951Romain Guy nDrawColor(mRenderer, color, mode.nativeInt); 444e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy } 44585bf02fc16784d935fb9eebfa9cb20fe46ff7951Romain Guy 44685bf02fc16784d935fb9eebfa9cb20fe46ff7951Romain Guy private native void nDrawColor(int renderer, int color, int mode); 447e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy 448e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy @Override 449e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy public void drawLine(float startX, float startY, float stopX, float stopY, Paint paint) { 450ce0537b80087a6225273040a987414b1dd081aa0Romain Guy mLine[0] = startX; 451ce0537b80087a6225273040a987414b1dd081aa0Romain Guy mLine[1] = startY; 452ce0537b80087a6225273040a987414b1dd081aa0Romain Guy mLine[2] = stopX; 453ce0537b80087a6225273040a987414b1dd081aa0Romain Guy mLine[3] = stopY; 454ce0537b80087a6225273040a987414b1dd081aa0Romain Guy drawLines(mLine, 0, 1, paint); 455e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy } 456e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy 457e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy @Override 458e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy public void drawLines(float[] pts, int offset, int count, Paint paint) { 459e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy // TODO: Implement 460e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy } 461e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy 462e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy @Override 463e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy public void drawLines(float[] pts, Paint paint) { 464ce0537b80087a6225273040a987414b1dd081aa0Romain Guy drawLines(pts, 0, pts.length / 4, paint); 465e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy } 466e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy 467e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy @Override 468e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy public void drawOval(RectF oval, Paint paint) { 469e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy throw new UnsupportedOperationException(); 470e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy } 471e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy 472e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy @Override 473e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy public void drawPaint(Paint paint) { 474e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy // TODO: Implement 475e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy } 476e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy 477e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy @Override 478e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy public void drawPath(Path path, Paint paint) { 479e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy throw new UnsupportedOperationException(); 480e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy } 481e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy 482e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy @Override 483e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy public void drawPicture(Picture picture) { 484e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy throw new UnsupportedOperationException(); 485e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy } 486e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy 487e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy @Override 488e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy public void drawPicture(Picture picture, Rect dst) { 489e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy throw new UnsupportedOperationException(); 490e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy } 491e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy 492e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy @Override 493e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy public void drawPicture(Picture picture, RectF dst) { 494e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy throw new UnsupportedOperationException(); 495e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy } 496e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy 497e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy @Override 498e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy public void drawPoint(float x, float y, Paint paint) { 499ce0537b80087a6225273040a987414b1dd081aa0Romain Guy mPoint[0] = x; 500ce0537b80087a6225273040a987414b1dd081aa0Romain Guy mPoint[1] = y; 501ce0537b80087a6225273040a987414b1dd081aa0Romain Guy drawPoints(mPoint, 0, 1, paint); 502e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy } 503e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy 504e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy @Override 505e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy public void drawPoints(float[] pts, int offset, int count, Paint paint) { 506e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy // TODO: Implement 507e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy } 508e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy 509e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy @Override 510e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy public void drawPoints(float[] pts, Paint paint) { 511ce0537b80087a6225273040a987414b1dd081aa0Romain Guy drawPoints(pts, 0, pts.length / 2, paint); 512e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy } 513e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy 514e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy @Override 515e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy public void drawPosText(char[] text, int index, int count, float[] pos, Paint paint) { 516e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy throw new UnsupportedOperationException(); 517e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy } 518e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy 519e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy @Override 520e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy public void drawPosText(String text, float[] pos, Paint paint) { 521e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy throw new UnsupportedOperationException(); 522e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy } 523e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy 524e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy @Override 525e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy public void drawRect(float left, float top, float right, float bottom, Paint paint) { 526c7d53494f1fbd9f9d74af89053ff9fdb1ccbac6cRomain Guy nDrawRect(mRenderer, left, top, right, bottom, paint.mNativePaint); 527e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy } 528e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy 529c7d53494f1fbd9f9d74af89053ff9fdb1ccbac6cRomain Guy private native void nDrawRect(int renderer, float left, float top, float right, float bottom, 530c7d53494f1fbd9f9d74af89053ff9fdb1ccbac6cRomain Guy int paint); 531c7d53494f1fbd9f9d74af89053ff9fdb1ccbac6cRomain Guy 532e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy @Override 533e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy public void drawRect(Rect r, Paint paint) { 534c7d53494f1fbd9f9d74af89053ff9fdb1ccbac6cRomain Guy drawRect(r.left, r.top, r.right, r.bottom, paint); 535e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy } 536e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy 537e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy @Override 538c7d53494f1fbd9f9d74af89053ff9fdb1ccbac6cRomain Guy public void drawRect(RectF r, Paint paint) { 539c7d53494f1fbd9f9d74af89053ff9fdb1ccbac6cRomain Guy drawRect(r.left, r.top, r.right, r.bottom, paint); 540e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy } 541e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy 542e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy @Override 543e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy public void drawRGB(int r, int g, int b) { 54485bf02fc16784d935fb9eebfa9cb20fe46ff7951Romain Guy drawColor(0xFF000000 | (r & 0xFF) << 16 | (g & 0xFF) << 8 | (b & 0xFF)); 545e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy } 546e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy 547e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy @Override 548e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy public void drawRoundRect(RectF rect, float rx, float ry, Paint paint) { 549e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy throw new UnsupportedOperationException(); 550e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy } 551e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy 552e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy @Override 553e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy public void drawText(char[] text, int index, int count, float x, float y, Paint paint) { 554e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy // TODO: Implement 555e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy } 556e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy 557e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy @Override 558e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy public void drawText(CharSequence text, int start, int end, float x, float y, Paint paint) { 559e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy // TODO: Implement 560e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy } 561e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy 562e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy @Override 563e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy public void drawText(String text, int start, int end, float x, float y, Paint paint) { 564e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy // TODO: Implement 565e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy } 566e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy 567e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy @Override 568e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy public void drawText(String text, float x, float y, Paint paint) { 569ce0537b80087a6225273040a987414b1dd081aa0Romain Guy drawText(text, 0, text.length(), x, y, paint); 570e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy } 571e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy 572e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy @Override 573e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy public void drawTextOnPath(char[] text, int index, int count, Path path, float hOffset, 574e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy float vOffset, Paint paint) { 575e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy throw new UnsupportedOperationException(); 576e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy } 577e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy 578e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy @Override 579e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy public void drawTextOnPath(String text, Path path, float hOffset, float vOffset, Paint paint) { 580e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy throw new UnsupportedOperationException(); 581e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy } 582e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy 583e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy @Override 584e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy public void drawTextRun(char[] text, int index, int count, int contextIndex, int contextCount, 585e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy float x, float y, int dir, Paint paint) { 586e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy throw new UnsupportedOperationException(); 587e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy } 588e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy 589e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy @Override 590e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy public void drawTextRun(CharSequence text, int start, int end, int contextStart, int contextEnd, 591e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy float x, float y, int dir, Paint paint) { 592e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy throw new UnsupportedOperationException(); 593e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy } 594e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy 595e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy @Override 596e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy public void drawVertices(VertexMode mode, int vertexCount, float[] verts, int vertOffset, 597e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy float[] texs, int texOffset, int[] colors, int colorOffset, short[] indices, 598e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy int indexOffset, int indexCount, Paint paint) { 599e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy throw new UnsupportedOperationException(); 600e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy } 601e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy} 602