1/*
2 * Copyright (C) 2016 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
17package com.android.layoutlib.bridge.android.graphics;
18
19import android.graphics.Bitmap;
20import android.graphics.Canvas;
21import android.graphics.Matrix;
22import android.graphics.NinePatch;
23import android.graphics.Paint;
24import android.graphics.Path;
25import android.graphics.Picture;
26import android.graphics.PorterDuff.Mode;
27import android.graphics.Rect;
28import android.graphics.RectF;
29
30/**
31 * Canvas implementation that does not do any rendering
32 */
33public class NopCanvas extends Canvas {
34    public NopCanvas() {
35        super();
36    }
37
38    @Override
39    public boolean isHardwareAccelerated() {
40        // Return true so there is no allocations for the software renderer in the constructor
41        return true;
42    }
43
44    @Override
45    public int save() {
46        return 0;
47    }
48
49    @Override
50    public int save(int saveFlags) {
51        return 0;
52    }
53
54    @Override
55    public int saveLayer(RectF bounds, Paint paint, int saveFlags) {
56        return 0;
57    }
58
59    @Override
60    public int saveLayer(RectF bounds, Paint paint) {
61        return 0;
62    }
63
64    @Override
65    public int saveLayer(float left, float top, float right, float bottom, Paint paint,
66            int saveFlags) {
67        return 0;
68    }
69
70    @Override
71    public int saveLayer(float left, float top, float right, float bottom, Paint paint) {
72        return 0;
73    }
74
75    @Override
76    public int saveLayerAlpha(RectF bounds, int alpha, int saveFlags) {
77        return 0;
78    }
79
80    @Override
81    public int saveLayerAlpha(RectF bounds, int alpha) {
82        return 0;
83    }
84
85    @Override
86    public int saveLayerAlpha(float left, float top, float right, float bottom, int alpha,
87            int saveFlags) {
88        return 0;
89    }
90
91    @Override
92    public int saveLayerAlpha(float left, float top, float right, float bottom, int alpha) {
93        return 0;
94    }
95
96    @Override
97    public void restore() {
98    }
99
100    @Override
101    public int getSaveCount() {
102        return 0;
103    }
104
105    @Override
106    public void restoreToCount(int saveCount) {
107    }
108
109    @Override
110    public void drawRGB(int r, int g, int b) {
111    }
112
113    @Override
114    public void drawARGB(int a, int r, int g, int b) {
115    }
116
117    @Override
118    public void drawColor(int color) {
119    }
120
121    @Override
122    public void drawColor(int color, Mode mode) {
123    }
124
125    @Override
126    public void drawPaint(Paint paint) {
127    }
128
129    @Override
130    public void drawPoints(float[] pts, int offset, int count, Paint paint) {
131    }
132
133    @Override
134    public void drawPoints(float[] pts, Paint paint) {
135    }
136
137    @Override
138    public void drawPoint(float x, float y, Paint paint) {
139    }
140
141    @Override
142    public void drawLine(float startX, float startY, float stopX, float stopY, Paint paint) {
143    }
144
145    @Override
146    public void drawLines(float[] pts, int offset, int count, Paint paint) {
147    }
148
149    @Override
150    public void drawLines(float[] pts, Paint paint) {
151    }
152
153    @Override
154    public void drawRect(RectF rect, Paint paint) {
155    }
156
157    @Override
158    public void drawRect(Rect r, Paint paint) {
159    }
160
161    @Override
162    public void drawRect(float left, float top, float right, float bottom, Paint paint) {
163    }
164
165    @Override
166    public void drawOval(RectF oval, Paint paint) {
167    }
168
169    @Override
170    public void drawOval(float left, float top, float right, float bottom, Paint paint) {
171    }
172
173    @Override
174    public void drawCircle(float cx, float cy, float radius, Paint paint) {
175    }
176
177    @Override
178    public void drawArc(RectF oval, float startAngle, float sweepAngle, boolean useCenter,
179            Paint paint) {
180    }
181
182    @Override
183    public void drawArc(float left, float top, float right, float bottom, float startAngle,
184            float sweepAngle, boolean useCenter, Paint paint) {
185    }
186
187    @Override
188    public void drawRoundRect(RectF rect, float rx, float ry, Paint paint) {
189    }
190
191    @Override
192    public void drawRoundRect(float left, float top, float right, float bottom, float rx, float ry,
193            Paint paint) {
194    }
195
196    @Override
197    public void drawPath(Path path, Paint paint) {
198    }
199
200    @Override
201    protected void throwIfCannotDraw(Bitmap bitmap) {
202    }
203
204    @Override
205    public void drawPatch(NinePatch patch, Rect dst, Paint paint) {
206    }
207
208    @Override
209    public void drawPatch(NinePatch patch, RectF dst, Paint paint) {
210    }
211
212    @Override
213    public void drawBitmap(Bitmap bitmap, float left, float top, Paint paint) {
214    }
215
216    @Override
217    public void drawBitmap(Bitmap bitmap, Rect src, RectF dst, Paint paint) {
218    }
219
220    @Override
221    public void drawBitmap(Bitmap bitmap, Rect src, Rect dst, Paint paint) {
222    }
223
224    @Override
225    public void drawBitmap(int[] colors, int offset, int stride, float x, float y, int width,
226            int height, boolean hasAlpha, Paint paint) {
227    }
228
229    @Override
230    public void drawBitmap(int[] colors, int offset, int stride, int x, int y, int width,
231            int height, boolean hasAlpha, Paint paint) {
232    }
233
234    @Override
235    public void drawBitmap(Bitmap bitmap, Matrix matrix, Paint paint) {
236    }
237
238    @Override
239    public void drawBitmapMesh(Bitmap bitmap, int meshWidth, int meshHeight, float[] verts,
240            int vertOffset, int[] colors, int colorOffset, Paint paint) {
241    }
242
243    @Override
244    public void drawVertices(VertexMode mode, int vertexCount, float[] verts, int vertOffset,
245            float[] texs, int texOffset, int[] colors, int colorOffset, short[] indices,
246            int indexOffset, int indexCount, Paint paint) {
247    }
248
249    @Override
250    public void drawText(char[] text, int index, int count, float x, float y, Paint paint) {
251    }
252
253    @Override
254    public void drawText(String text, float x, float y, Paint paint) {
255    }
256
257    @Override
258    public void drawText(String text, int start, int end, float x, float y, Paint paint) {
259    }
260
261    @Override
262    public void drawText(CharSequence text, int start, int end, float x, float y, Paint paint) {
263    }
264
265    @Override
266    public void drawTextRun(char[] text, int index, int count, int contextIndex, int contextCount,
267            float x, float y, boolean isRtl, Paint paint) {
268    }
269
270    @Override
271    public void drawTextRun(CharSequence text, int start, int end, int contextStart, int contextEnd,
272            float x, float y, boolean isRtl, Paint paint) {
273    }
274
275    @Override
276    public void drawPosText(char[] text, int index, int count, float[] pos, Paint paint) {
277    }
278
279    @Override
280    public void drawPosText(String text, float[] pos, Paint paint) {
281    }
282
283    @Override
284    public void drawTextOnPath(char[] text, int index, int count, Path path, float hOffset,
285            float vOffset, Paint paint) {
286    }
287
288    @Override
289    public void drawTextOnPath(String text, Path path, float hOffset, float vOffset, Paint paint) {
290    }
291
292    @Override
293    public void drawPicture(Picture picture) {
294    }
295
296    @Override
297    public void drawPicture(Picture picture, RectF dst) {
298    }
299
300    @Override
301    public void drawPicture(Picture picture, Rect dst) {
302    }
303}
304