ColorFilter_Delegate.java revision d43909c7503e11eb335a452d296a10804bb01fd6
1/*
2 * Copyright (C) 2010 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 *      http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package android.graphics;
18
19import com.android.layoutlib.bridge.impl.DelegateManager;
20
21/**
22 * Delegate implementing the native methods of android.graphics.ColorFilter
23 *
24 * Through the layoutlib_create tool, the original native methods of ColorFilter have been replaced
25 * by calls to methods of the same name in this delegate class.
26 *
27 * This class behaves like the original native implementation, but in Java, keeping previously
28 * native data into its own objects and mapping them to int that are sent back and forth between
29 * it and the original ColorFilter class.
30 *
31 * This also serve as a base class for all ColorFilter delegate classes.
32 *
33 * @see DelegateManager
34 *
35 */
36public abstract class ColorFilter_Delegate {
37
38    // ---- delegate manager ----
39    protected static final DelegateManager<ColorFilter_Delegate> sManager =
40            new DelegateManager<ColorFilter_Delegate>();
41
42    // ---- delegate helper data ----
43
44    // ---- delegate data ----
45
46    // ---- Public Helper methods ----
47
48    public static ColorFilter_Delegate getDelegate(int nativeShader) {
49        return sManager.getDelegate(nativeShader);
50    }
51
52    public abstract boolean isSupported();
53    public abstract String getSupportMessage();
54
55    // ---- native methods ----
56
57    /*package*/ static void finalizer(int native_instance, int nativeColorFilter) {
58        sManager.removeDelegate(native_instance);
59    }
60
61    // ---- Private delegate/helper methods ----
62}
63