152244fff29042926e21fa897ef5ab11148e35299John Reck/* 252244fff29042926e21fa897ef5ab11148e35299John Reck * Copyright (C) 2014 The Android Open Source Project 352244fff29042926e21fa897ef5ab11148e35299John Reck * 452244fff29042926e21fa897ef5ab11148e35299John Reck * Licensed under the Apache License, Version 2.0 (the "License"); 552244fff29042926e21fa897ef5ab11148e35299John Reck * you may not use this file except in compliance with the License. 652244fff29042926e21fa897ef5ab11148e35299John Reck * You may obtain a copy of the License at 752244fff29042926e21fa897ef5ab11148e35299John Reck * 852244fff29042926e21fa897ef5ab11148e35299John Reck * http://www.apache.org/licenses/LICENSE-2.0 952244fff29042926e21fa897ef5ab11148e35299John Reck * 1052244fff29042926e21fa897ef5ab11148e35299John Reck * Unless required by applicable law or agreed to in writing, software 1152244fff29042926e21fa897ef5ab11148e35299John Reck * distributed under the License is distributed on an "AS IS" BASIS, 1252244fff29042926e21fa897ef5ab11148e35299John Reck * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1352244fff29042926e21fa897ef5ab11148e35299John Reck * See the License for the specific language governing permissions and 1452244fff29042926e21fa897ef5ab11148e35299John Reck * limitations under the License. 1552244fff29042926e21fa897ef5ab11148e35299John Reck */ 1652244fff29042926e21fa897ef5ab11148e35299John Reck 1752244fff29042926e21fa897ef5ab11148e35299John Reckpackage android.graphics; 1852244fff29042926e21fa897ef5ab11148e35299John Reck 199fa4071c4768c63902c6a74a4b480b51a8b95d43John Reckimport com.android.internal.util.VirtualRefBasePtr; 209fa4071c4768c63902c6a74a4b480b51a8b95d43John Reck 2152244fff29042926e21fa897ef5ab11148e35299John Reck/** 2252244fff29042926e21fa897ef5ab11148e35299John Reck * TODO: Make public? 2352244fff29042926e21fa897ef5ab11148e35299John Reck * @hide 2452244fff29042926e21fa897ef5ab11148e35299John Reck */ 2552244fff29042926e21fa897ef5ab11148e35299John Reckpublic final class CanvasProperty<T> { 269fa4071c4768c63902c6a74a4b480b51a8b95d43John Reck 279fa4071c4768c63902c6a74a4b480b51a8b95d43John Reck private VirtualRefBasePtr mProperty; 2852244fff29042926e21fa897ef5ab11148e35299John Reck 2952244fff29042926e21fa897ef5ab11148e35299John Reck public static CanvasProperty<Float> createFloat(float initialValue) { 3052244fff29042926e21fa897ef5ab11148e35299John Reck return new CanvasProperty<Float>(nCreateFloat(initialValue)); 3152244fff29042926e21fa897ef5ab11148e35299John Reck } 3252244fff29042926e21fa897ef5ab11148e35299John Reck 3352244fff29042926e21fa897ef5ab11148e35299John Reck public static CanvasProperty<Paint> createPaint(Paint initialValue) { 34dfba4d3d11bbf47dff45f94d61d4d97510b3034aDerek Sollenberger return new CanvasProperty<Paint>(nCreatePaint(initialValue.getNativeInstance())); 3552244fff29042926e21fa897ef5ab11148e35299John Reck } 3652244fff29042926e21fa897ef5ab11148e35299John Reck 3752244fff29042926e21fa897ef5ab11148e35299John Reck private CanvasProperty(long nativeContainer) { 389fa4071c4768c63902c6a74a4b480b51a8b95d43John Reck mProperty = new VirtualRefBasePtr(nativeContainer); 3952244fff29042926e21fa897ef5ab11148e35299John Reck } 4052244fff29042926e21fa897ef5ab11148e35299John Reck 4152244fff29042926e21fa897ef5ab11148e35299John Reck /** @hide */ 4252244fff29042926e21fa897ef5ab11148e35299John Reck public long getNativeContainer() { 439fa4071c4768c63902c6a74a4b480b51a8b95d43John Reck return mProperty.get(); 4452244fff29042926e21fa897ef5ab11148e35299John Reck } 4552244fff29042926e21fa897ef5ab11148e35299John Reck 4652244fff29042926e21fa897ef5ab11148e35299John Reck private static native long nCreateFloat(float initialValue); 4752244fff29042926e21fa897ef5ab11148e35299John Reck private static native long nCreatePaint(long initialValuePaintPtr); 4852244fff29042926e21fa897ef5ab11148e35299John Reck} 49