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