1282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski/*
2282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski * Copyright (C) 2010 The Android Open Source Project
3282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski *
4282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski * Licensed under the Apache License, Version 2.0 (the "License");
5282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski * you may not use this file except in compliance with the License.
6282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski * You may obtain a copy of the License at
7282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski *
8282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski *      http://www.apache.org/licenses/LICENSE-2.0
9282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski *
10282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski * Unless required by applicable law or agreed to in writing, software
11282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski * distributed under the License is distributed on an "AS IS" BASIS,
12282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski * See the License for the specific language governing permissions and
14282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski * limitations under the License.
15282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski */
16282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski
17282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinskipackage android.graphics;
18282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski
19282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinskiimport com.android.layoutlib.bridge.impl.DelegateManager;
20282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinskiimport com.android.tools.layoutlib.annotations.LayoutlibDelegate;
21282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski
22282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinskiimport java.awt.Composite;
23282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski
24282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski/**
25282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski * Delegate implementing the native methods of android.graphics.PixelXorXfermode
26282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski *
27282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski * Through the layoutlib_create tool, the original native methods of PixelXorXfermode have been
28282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski * replaced by calls to methods of the same name in this delegate class.
29282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski *
30282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski * This class behaves like the original native implementation, but in Java, keeping previously
31282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski * native data into its own objects and mapping them to int that are sent back and forth between
32282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski * it and the original PixelXorXfermode class.
33282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski *
34282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski * Because this extends {@link Xfermode_Delegate}, there's no need to use a
35282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski * {@link DelegateManager}, as all the PathEffect classes will be added to the manager owned by
36282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski * {@link Xfermode_Delegate}.
37282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski *
38282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski * @see Xfermode_Delegate
39282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski */
40282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinskipublic class PixelXorXfermode_Delegate extends Xfermode_Delegate {
41282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski    // ---- delegate data ----
42282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski
43282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski    // ---- Public Helper methods ----
44282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski
45282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski    @Override
46282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski    public Composite getComposite(int alpha) {
47282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski        // FIXME
48282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski        return null;
49282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski    }
50282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski
51282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski    @Override
52282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski    public boolean isSupported() {
53282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski        return false;
54282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski    }
55282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski
56282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski    @Override
57282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski    public String getSupportMessage() {
58282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski        return "Pixel XOR Xfermodes are not supported in Layout Preview mode.";
59282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski    }
60282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski
61282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski    // ---- native methods ----
62282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski
63282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski    @LayoutlibDelegate
6488a8364c386c694f7ad56662ef89713dbf7c9d63Narayan Kamath    /*package*/ static long nativeCreate(int opColor) {
65282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski        PixelXorXfermode_Delegate newDelegate = new PixelXorXfermode_Delegate();
66282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski        return sManager.addNewDelegate(newDelegate);
67282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski    }
68282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski
69282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski    // ---- Private delegate/helper methods ----
70282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski}
71