Xavier Ducrohet | d43909c | 2010-12-23 07:16:21 -0800 | [diff] [blame] | 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 | |
| 17 | package android.graphics; |
| 18 | |
| 19 | import com.android.layoutlib.bridge.impl.DelegateManager; |
Xavier Ducrohet | 9a4fe29 | 2011-02-09 17:17:49 -0800 | [diff] [blame] | 20 | import com.android.tools.layoutlib.annotations.LayoutlibDelegate; |
Xavier Ducrohet | d43909c | 2010-12-23 07:16:21 -0800 | [diff] [blame] | 21 | |
| 22 | /** |
| 23 | * Delegate implementing the native methods of android.graphics.ColorFilter |
| 24 | * |
| 25 | * Through the layoutlib_create tool, the original native methods of ColorFilter have been replaced |
| 26 | * by calls to methods of the same name in this delegate class. |
| 27 | * |
| 28 | * This class behaves like the original native implementation, but in Java, keeping previously |
| 29 | * native data into its own objects and mapping them to int that are sent back and forth between |
| 30 | * it and the original ColorFilter class. |
| 31 | * |
| 32 | * This also serve as a base class for all ColorFilter delegate classes. |
| 33 | * |
| 34 | * @see DelegateManager |
| 35 | * |
| 36 | */ |
| 37 | public abstract class ColorFilter_Delegate { |
| 38 | |
| 39 | // ---- delegate manager ---- |
| 40 | protected static final DelegateManager<ColorFilter_Delegate> sManager = |
Xavier Ducrohet | f0a5343 | 2011-02-23 16:51:08 -0800 | [diff] [blame] | 41 | new DelegateManager<ColorFilter_Delegate>(ColorFilter_Delegate.class); |
Xavier Ducrohet | d43909c | 2010-12-23 07:16:21 -0800 | [diff] [blame] | 42 | |
| 43 | // ---- delegate helper data ---- |
| 44 | |
| 45 | // ---- delegate data ---- |
| 46 | |
| 47 | // ---- Public Helper methods ---- |
| 48 | |
Narayan Kamath | 8415143 | 2014-01-27 14:24:16 +0000 | [diff] [blame] | 49 | public static ColorFilter_Delegate getDelegate(long nativeShader) { |
Xavier Ducrohet | d43909c | 2010-12-23 07:16:21 -0800 | [diff] [blame] | 50 | return sManager.getDelegate(nativeShader); |
| 51 | } |
| 52 | |
| 53 | public abstract boolean isSupported(); |
| 54 | public abstract String getSupportMessage(); |
| 55 | |
| 56 | // ---- native methods ---- |
| 57 | |
Xavier Ducrohet | 9a4fe29 | 2011-02-09 17:17:49 -0800 | [diff] [blame] | 58 | @LayoutlibDelegate |
Narayan Kamath | 8415143 | 2014-01-27 14:24:16 +0000 | [diff] [blame] | 59 | /*package*/ static void finalizer(long native_instance, long nativeColorFilter) { |
Xavier Ducrohet | cc4977d | 2011-02-22 11:54:37 -0800 | [diff] [blame] | 60 | sManager.removeJavaReferenceFor(native_instance); |
Xavier Ducrohet | d43909c | 2010-12-23 07:16:21 -0800 | [diff] [blame] | 61 | } |
| 62 | |
| 63 | // ---- Private delegate/helper methods ---- |
| 64 | } |