1edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project/*
2edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project * Copyright (C) 2005 The Android Open Source Project
3edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project *
4edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project * Licensed under the Apache License, Version 2.0 (the "License");
5edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project * you may not use this file except in compliance with the License.
6edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project * You may obtain a copy of the License at
7edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project *
8edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project *      http://www.apache.org/licenses/LICENSE-2.0
9edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project *
10edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project * Unless required by applicable law or agreed to in writing, software
11edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project * distributed under the License is distributed on an "AS IS" BASIS,
12edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project * See the License for the specific language governing permissions and
14edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project * limitations under the License.
15edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project */
16edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project
17edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project//
18edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project
19edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project// Pixel formats used across the system.
20edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project// These formats might not all be supported by all renderers, for instance
21edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project// skia or SurfaceFlinger are not required to support all of these formats
22edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project// (either as source or destination)
23edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project
24edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project
25edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project#ifndef UI_PIXELFORMAT_H
26edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project#define UI_PIXELFORMAT_H
27edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project
28edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project#include <stdint.h>
29edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project#include <sys/types.h>
30edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project#include <utils/Errors.h>
3154ed4f6282bdea251455f39b978626026affdbefMathias Agopian#include <hardware/hardware.h>
32edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project
33edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Projectnamespace android {
34edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project
35edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Projectenum {
36edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project    //
37edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project    // these constants need to match those
38edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project    // in graphics/PixelFormat.java & pixelflinger/format.h
39edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project    //
40edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project    PIXEL_FORMAT_UNKNOWN    =   0,
41edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project    PIXEL_FORMAT_NONE       =   0,
42edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project
43edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project    // logical pixel formats used by the SurfaceFlinger -----------------------
44edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project    PIXEL_FORMAT_CUSTOM         = -4,
45edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project        // Custom pixel-format described by a PixelFormatInfo structure
46edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project
47edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project    PIXEL_FORMAT_TRANSLUCENT    = -3,
48edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project        // System chooses a format that supports translucency (many alpha bits)
49edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project
50edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project    PIXEL_FORMAT_TRANSPARENT    = -2,
51edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project        // System chooses a format that supports transparency
52edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project        // (at least 1 alpha bit)
53edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project
54edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project    PIXEL_FORMAT_OPAQUE         = -1,
55edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project        // System chooses an opaque format (no alpha bits required)
56acb7b5dfc804d2e6b2e75b688f536fd38d75641aPannag Sanketi
57edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project    // real pixel formats supported for rendering -----------------------------
58edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project
596a5d35dd5cd8710c6c9f100076e62ffbdb0b868bDan Stoza    PIXEL_FORMAT_RGBA_8888   = HAL_PIXEL_FORMAT_RGBA_8888,   // 4x8-bit RGBA
606a5d35dd5cd8710c6c9f100076e62ffbdb0b868bDan Stoza    PIXEL_FORMAT_RGBX_8888   = HAL_PIXEL_FORMAT_RGBX_8888,   // 4x8-bit RGB0
616a5d35dd5cd8710c6c9f100076e62ffbdb0b868bDan Stoza    PIXEL_FORMAT_RGB_888     = HAL_PIXEL_FORMAT_RGB_888,     // 3x8-bit RGB
626a5d35dd5cd8710c6c9f100076e62ffbdb0b868bDan Stoza    PIXEL_FORMAT_RGB_565     = HAL_PIXEL_FORMAT_RGB_565,     // 16-bit RGB
636a5d35dd5cd8710c6c9f100076e62ffbdb0b868bDan Stoza    PIXEL_FORMAT_BGRA_8888   = HAL_PIXEL_FORMAT_BGRA_8888,   // 4x8-bit BGRA
646a5d35dd5cd8710c6c9f100076e62ffbdb0b868bDan Stoza    PIXEL_FORMAT_RGBA_5551   = 6,                            // 16-bit ARGB
656a5d35dd5cd8710c6c9f100076e62ffbdb0b868bDan Stoza    PIXEL_FORMAT_RGBA_4444   = 7,                            // 16-bit ARGB
666a5d35dd5cd8710c6c9f100076e62ffbdb0b868bDan Stoza    PIXEL_FORMAT_sRGB_A_8888 = HAL_PIXEL_FORMAT_sRGB_A_8888, // 4x8-bit sRGB + A
676a5d35dd5cd8710c6c9f100076e62ffbdb0b868bDan Stoza    PIXEL_FORMAT_sRGB_X_8888 = HAL_PIXEL_FORMAT_sRGB_X_8888, // 4x8-bit sRGB, no A
68edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project};
69edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project
70edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Projecttypedef int32_t PixelFormat;
71edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project
725773d3f5b2694c647e010246dff99acc70131289Mathias Agopianssize_t bytesPerPixel(PixelFormat format);
735773d3f5b2694c647e010246dff99acc70131289Mathias Agopianssize_t bitsPerPixel(PixelFormat format);
74edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project
75edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project}; // namespace android
76edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project
77edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project#endif // UI_PIXELFORMAT_H
78