1 /*
2  * Copyright (C) 2024 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 package com.android.internal.widget.remotecompose.core.operations.paint;
17 
18 /**
19  * Interface to a paint object
20  * For more details see Android Paint
21  */
22 public interface PaintChanges {
23 
24     // MASK to be set/cleared
25     int CLEAR_TEXT_SIZE = 1 << (PaintBundle.TEXT_SIZE - 1);
26     int CLEAR_TEXT_STYLE = 1 << (PaintBundle.TYPEFACE - 1);
27     int CLEAR_COLOR = 1 << (PaintBundle.COLOR - 1);
28     int CLEAR_STROKE_WIDTH = 1 << (PaintBundle.STROKE_WIDTH - 1);
29     int CLEAR_STROKE_MITER = 1 << (PaintBundle.STROKE_MITER - 1);
30     int CLEAR_CAP = 1 << (PaintBundle.STROKE_CAP - 1);
31     int CLEAR_STYLE = 1 << (PaintBundle.STYLE - 1);
32     int CLEAR_SHADER = 1 << (PaintBundle.SHADER - 1);
33     int CLEAR_IMAGE_FILTER_QUALITY =
34             1 << (PaintBundle.IMAGE_FILTER_QUALITY - 1);
35     int CLEAR_RADIENT = 1 << (PaintBundle.GRADIENT - 1);
36     int CLEAR_ALPHA = 1 << (PaintBundle.ALPHA - 1);
37     int CLEAR_COLOR_FILTER = 1 << (PaintBundle.COLOR_FILTER - 1);
38     int VALID_BITS = 0x1FFF; // only the first 13 bit are valid now
39 
40     /**
41      * Set the size of text
42      * @param size
43      */
setTextSize(float size)44     void setTextSize(float size);
45 
46     /**
47      * Set the width of lines
48      * @param width
49      */
setStrokeWidth(float width)50     void setStrokeWidth(float width);
51 
52     /**
53      * Set the color to use
54      * @param color
55      */
setColor(int color)56     void setColor(int color);
57 
58     /**
59      * Set the Stroke Cap
60      * @param cap
61      */
setStrokeCap(int cap)62     void setStrokeCap(int cap);
63 
64     /**
65      * Set the Stroke style FILL and/or STROKE
66      * @param style
67      */
setStyle(int style)68     void setStyle(int style);
69 
70     /**
71      * Set the id of the shader to use
72      * @param shader
73      */
setShader(int shader)74     void setShader(int shader);
75 
76     /**
77      * Set the way image is interpolated
78      * @param quality
79      */
setImageFilterQuality(int quality)80     void setImageFilterQuality(int quality);
81 
82     /**
83      * Set the alpha to draw under
84      * @param a
85      */
setAlpha(float a)86     void setAlpha(float a);
87 
88     /**
89      * Set the Stroke Miter
90      * @param miter
91      */
setStrokeMiter(float miter)92     void setStrokeMiter(float miter);
93 
94     /**
95      * Set the Stroke Join
96      * @param join
97      */
setStrokeJoin(int join)98     void setStrokeJoin(int join);
99 
100     /**
101      * Should bitmaps be interpolated
102      * @param filter
103      */
setFilterBitmap(boolean filter)104     void setFilterBitmap(boolean filter);
105 
106     /**
107      * Set the blend mode can be porterduff + others
108      * @param mode
109      */
setBlendMode(int mode)110     void setBlendMode(int mode);
111 
112     /**
113      * Set the AntiAlias. Typically true
114      * Set to off when you need pixilated look (e.g. QR codes)
115      * @param aa
116      */
setAntiAlias(boolean aa)117     void setAntiAlias(boolean aa);
118 
119     /**
120      * Clear some sub set of the settings
121      * @param mask
122      */
clear(long mask)123     void clear(long mask);
124 
125     /**
126      * Set a linear gradient fill
127      * @param colorsArray
128      * @param stopsArray
129      * @param startX
130      * @param startY
131      * @param endX
132      * @param endY
133      * @param tileMode
134      */
setLinearGradient( int[] colorsArray, float[] stopsArray, float startX, float startY, float endX, float endY, int tileMode )135     void setLinearGradient(
136             int[] colorsArray,
137             float[] stopsArray,
138             float startX,
139             float startY,
140             float endX,
141             float endY,
142             int tileMode
143     );
144 
145     /**
146      * Set a radial gradient fill
147      * @param colorsArray
148      * @param stopsArray
149      * @param centerX
150      * @param centerY
151      * @param radius
152      * @param tileMode
153      */
setRadialGradient( int[] colorsArray, float[] stopsArray, float centerX, float centerY, float radius, int tileMode )154     void setRadialGradient(
155             int[] colorsArray,
156             float[] stopsArray,
157             float centerX,
158             float centerY,
159             float radius,
160             int tileMode
161     );
162 
163     /**
164      * Set a sweep gradient fill
165      * @param colorsArray
166      * @param stopsArray
167      * @param centerX
168      * @param centerY
169      */
setSweepGradient( int[] colorsArray, float[] stopsArray, float centerX, float centerY )170     void setSweepGradient(
171             int[] colorsArray,
172             float[] stopsArray,
173             float centerX,
174             float centerY
175     );
176 
177     /**
178      * Set Color filter mod
179      * @param color
180      * @param mode
181      */
setColorFilter(int color, int mode)182     void setColorFilter(int color, int mode);
183 
184     /**
185      * Set TypeFace 0,1,2
186      * TODO above should point to a string to be decoded
187      * @param fontType
188      * @param weight
189      * @param italic
190      */
setTypeFace(int fontType, int weight, boolean italic)191     void setTypeFace(int fontType, int weight, boolean italic);
192 }