Xavier Ducrohet | c810bea | 2010-12-20 08:22:47 -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; |
| 20 | |
| 21 | import java.awt.Paint; |
| 22 | |
| 23 | /** |
| 24 | * Delegate implementing the native methods of android.graphics.ComposeShader |
| 25 | * |
| 26 | * Through the layoutlib_create tool, the original native methods of ComposeShader have been |
| 27 | * replaced by calls to methods of the same name in this delegate class. |
| 28 | * |
| 29 | * This class behaves like the original native implementation, but in Java, keeping previously |
| 30 | * native data into its own objects and mapping them to int that are sent back and forth between |
| 31 | * it and the original ComposeShader class. |
| 32 | * |
| 33 | * Because this extends {@link Shader_Delegate}, there's no need to use a {@link DelegateManager}, |
| 34 | * as all the Shader classes will be added to the manager owned by {@link Shader_Delegate}. |
| 35 | * |
| 36 | * @see Shader_Delegate |
| 37 | * |
| 38 | */ |
| 39 | public class ComposeShader_Delegate extends Shader_Delegate { |
| 40 | |
| 41 | // ---- delegate data ---- |
| 42 | |
| 43 | // ---- Public Helper methods ---- |
| 44 | |
| 45 | @Override |
| 46 | public Paint getJavaPaint() { |
| 47 | // FIXME |
| 48 | return null; |
| 49 | } |
| 50 | |
| 51 | @Override |
| 52 | public boolean isSupported() { |
| 53 | return false; |
| 54 | } |
| 55 | |
| 56 | @Override |
| 57 | public String getSupportMessage() { |
| 58 | return "Compose Shader are not supported in Layout Preview mode."; |
| 59 | } |
| 60 | |
| 61 | |
| 62 | // ---- native methods ---- |
| 63 | |
| 64 | /*package*/ static int nativeCreate1(int native_shaderA, int native_shaderB, |
| 65 | int native_mode) { |
| 66 | // FIXME not supported yet. |
| 67 | ComposeShader_Delegate newDelegate = new ComposeShader_Delegate(); |
| 68 | return sManager.addDelegate(newDelegate); |
| 69 | } |
| 70 | |
| 71 | /*package*/ static int nativeCreate2(int native_shaderA, int native_shaderB, |
| 72 | int porterDuffMode) { |
| 73 | // FIXME not supported yet. |
| 74 | ComposeShader_Delegate newDelegate = new ComposeShader_Delegate(); |
| 75 | return sManager.addDelegate(newDelegate); |
| 76 | } |
| 77 | |
| 78 | /*package*/ static int nativePostCreate1(int native_shader, int native_skiaShaderA, |
| 79 | int native_skiaShaderB, int native_mode) { |
| 80 | // pass, not needed. |
| 81 | return 0; |
| 82 | } |
| 83 | |
| 84 | /*package*/ static int nativePostCreate2(int native_shader, int native_skiaShaderA, |
| 85 | int native_skiaShaderB, int porterDuffMode) { |
| 86 | // pass, not needed. |
| 87 | return 0; |
| 88 | } |
| 89 | |
| 90 | |
| 91 | // ---- Private delegate/helper methods ---- |
| 92 | |
| 93 | } |