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