• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2019 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 
17 #ifndef ANDROID_GRAPHICS_TYPECAST_H
18 #define ANDROID_GRAPHICS_TYPECAST_H
19 
20 struct ABitmap;
21 struct ACanvas;
22 struct APaint;
23 
24 namespace android {
25 
26     class Bitmap;
27     class Canvas;
28     class Paint;
29 
30     class TypeCast {
31     public:
toBitmapRef(const ABitmap * bitmap)32         static inline Bitmap& toBitmapRef(const ABitmap* bitmap) {
33             return const_cast<Bitmap&>(reinterpret_cast<const Bitmap&>(*bitmap));
34         }
35 
toBitmap(ABitmap * bitmap)36         static inline Bitmap* toBitmap(ABitmap* bitmap) {
37             return reinterpret_cast<Bitmap*>(bitmap);
38         }
39 
toABitmap(Bitmap * bitmap)40         static inline ABitmap* toABitmap(Bitmap* bitmap) {
41             return reinterpret_cast<ABitmap*>(bitmap);
42         }
43 
toCanvas(ACanvas * canvas)44         static inline Canvas* toCanvas(ACanvas* canvas) {
45             return reinterpret_cast<Canvas*>(canvas);
46         }
47 
toACanvas(Canvas * canvas)48         static inline ACanvas* toACanvas(Canvas* canvas) {
49             return reinterpret_cast<ACanvas *>(canvas);
50         }
51 
toPaintRef(const APaint * paint)52         static inline const Paint& toPaintRef(const APaint* paint) {
53             return reinterpret_cast<const Paint&>(*paint);
54         }
55 
toPaint(const APaint * paint)56         static inline const Paint* toPaint(const APaint* paint) {
57             return reinterpret_cast<const Paint*>(paint);
58         }
59 
toPaint(APaint * paint)60         static inline Paint* toPaint(APaint* paint) {
61             return reinterpret_cast<Paint*>(paint);
62         }
63 
toAPaint(Paint * paint)64         static inline APaint* toAPaint(Paint* paint) {
65             return reinterpret_cast<APaint*>(paint);
66         }
67     };
68 }; // namespace android
69 
70 #endif // ANDROID_GRAPHICS_TYPECAST_H
71