blob: 799fbc9d544a975d6d15b180a5aabc3f91e642eb [file] [log] [blame]
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -08001/*
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
17#include <ui/PixelFormat.h>
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080018
Mathias Agopian42e24582012-02-21 18:56:08 -080019// ----------------------------------------------------------------------------
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080020namespace android {
Mathias Agopian42e24582012-02-21 18:56:08 -080021// ----------------------------------------------------------------------------
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080022
Dan Stoza303b9a52014-11-17 12:03:59 -080023uint32_t bytesPerPixel(PixelFormat format) {
Mathias Agopian3db21642010-02-16 20:43:39 -080024 switch (format) {
Romain Guyff415142016-12-13 16:51:25 -080025 case PIXEL_FORMAT_RGBA_FP16:
Romain Guyff415142016-12-13 16:51:25 -080026 return 8;
Mathias Agopianc2414bb2013-07-26 14:49:50 -070027 case PIXEL_FORMAT_RGBA_8888:
28 case PIXEL_FORMAT_RGBX_8888:
29 case PIXEL_FORMAT_BGRA_8888:
Romain Guy541f2262017-02-10 18:50:17 -080030 case PIXEL_FORMAT_RGBA_1010102:
Mathias Agopian5773d3f2013-07-25 19:24:31 -070031 return 4;
Mathias Agopianc2414bb2013-07-26 14:49:50 -070032 case PIXEL_FORMAT_RGB_888:
Mathias Agopian5773d3f2013-07-25 19:24:31 -070033 return 3;
Mathias Agopianc2414bb2013-07-26 14:49:50 -070034 case PIXEL_FORMAT_RGB_565:
35 case PIXEL_FORMAT_RGBA_5551:
36 case PIXEL_FORMAT_RGBA_4444:
Mathias Agopian5773d3f2013-07-25 19:24:31 -070037 return 2;
Leon Scroggins III4d258852021-11-24 14:40:53 -050038 case PIXEL_FORMAT_R_8:
39 return 1;
Mathias Agopian3db21642010-02-16 20:43:39 -080040 }
Dan Stoza303b9a52014-11-17 12:03:59 -080041 return 0;
Mathias Agopian5773d3f2013-07-25 19:24:31 -070042}
Mathias Agopian3db21642010-02-16 20:43:39 -080043
Mathias Agopian42e24582012-02-21 18:56:08 -080044// ----------------------------------------------------------------------------
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080045}; // namespace android
Mathias Agopian42e24582012-02-21 18:56:08 -080046// ----------------------------------------------------------------------------