2 * Copyright (C) 2006 The Android Open Source Project
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 package android.graphics;
20 * Shader is the based class for objects that return horizontal spans of colors
21 * during drawing. A subclass of Shader is installed in a Paint calling
22 * paint.setShader(shader). After that any object (other than a bitmap) that is
23 * drawn with that paint will get its color(s) from the shader.
27 // this is set by subclasses, but don't make it public
28 /* package */ int native_instance;
30 public enum TileMode {
32 * replicate the edge color if the shader draws outside of its
37 * repeat the shader's image horizontally and vertically
41 * repeat the shader's image horizontally and vertically, alternating
42 * mirror images so that adjacent images always seam
46 TileMode(int nativeInt) {
47 this.nativeInt = nativeInt;
53 * Return true if the shader has a non-identity local matrix.
54 * @param localM If not null, it is set to the shader's local matrix.
55 * @return true if the shader has a non-identity local matrix
57 public boolean getLocalMatrix(Matrix localM) {
58 return nativeGetLocalMatrix(native_instance, localM.native_instance);
62 * Set the shader's local matrix. Passing null will reset the shader's
64 * @param localM The shader's new local matrix, or null to specify identity
66 public void setLocalMatrix(Matrix localM) {
67 nativeSetLocalMatrix(native_instance,
68 localM != null ? localM.native_instance : 0);
71 protected void finalize() throws Throwable {
72 nativeDestructor(native_instance);
75 private static native void nativeDestructor(int native_shader);
76 private static native boolean nativeGetLocalMatrix(int native_shader,
78 private static native void nativeSetLocalMatrix(int native_shader,