• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2007 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 #include <ui/PixelFormat.h>
17 // ----------------------------------------------------------------------------
18 namespace android {
19 // ----------------------------------------------------------------------------
bytesPerPixel(PixelFormat format)20 uint32_t bytesPerPixel(PixelFormat format) {
21     switch (format) {
22         case PIXEL_FORMAT_RGBA_FP16:
23             return 8;
24         case PIXEL_FORMAT_RGBA_8888:
25         case PIXEL_FORMAT_RGBX_8888:
26         case PIXEL_FORMAT_BGRA_8888:
27         case PIXEL_FORMAT_RGBA_1010102:
28             return 4;
29         case PIXEL_FORMAT_RGB_888:
30             return 3;
31         case PIXEL_FORMAT_RGB_565:
32         case PIXEL_FORMAT_RGBA_5551:
33         case PIXEL_FORMAT_RGBA_4444:
34             return 2;
35     }
36     return 0;
37 }
bitsPerPixel(PixelFormat format)38 uint32_t bitsPerPixel(PixelFormat format) {
39     switch (format) {
40         case PIXEL_FORMAT_RGBA_FP16:
41             return 64;
42         case PIXEL_FORMAT_RGBA_8888:
43         case PIXEL_FORMAT_RGBX_8888:
44         case PIXEL_FORMAT_BGRA_8888:
45         case PIXEL_FORMAT_RGBA_1010102:
46             return 32;
47         case PIXEL_FORMAT_RGB_888:
48             return 24;
49         case PIXEL_FORMAT_RGB_565:
50         case PIXEL_FORMAT_RGBA_5551:
51         case PIXEL_FORMAT_RGBA_4444:
52             return 16;
53     }
54     return 0;
55 }
56 // ----------------------------------------------------------------------------
57 }; // namespace android
58 // ----------------------------------------------------------------------------
59