media/omx-plugin/include/froyo/ui/PixelFormat.h

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

michael@0 1 /*
michael@0 2 * Copyright (C) 2005 The Android Open Source Project
michael@0 3 *
michael@0 4 * Licensed under the Apache License, Version 2.0 (the "License");
michael@0 5 * you may not use this file except in compliance with the License.
michael@0 6 * You may obtain a copy of the License at
michael@0 7 *
michael@0 8 * http://www.apache.org/licenses/LICENSE-2.0
michael@0 9 *
michael@0 10 * Unless required by applicable law or agreed to in writing, software
michael@0 11 * distributed under the License is distributed on an "AS IS" BASIS,
michael@0 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
michael@0 13 * See the License for the specific language governing permissions and
michael@0 14 * limitations under the License.
michael@0 15 */
michael@0 16
michael@0 17 //
michael@0 18
michael@0 19 // Pixel formats used across the system.
michael@0 20 // These formats might not all be supported by all renderers, for instance
michael@0 21 // skia or SurfaceFlinger are not required to support all of these formats
michael@0 22 // (either as source or destination)
michael@0 23
michael@0 24 // XXX: we should consolidate these formats and skia's
michael@0 25
michael@0 26 #ifndef UI_PIXELFORMAT_H
michael@0 27 #define UI_PIXELFORMAT_H
michael@0 28
michael@0 29 #include <stdint.h>
michael@0 30 #include <sys/types.h>
michael@0 31 #include <utils/Errors.h>
michael@0 32 #include <pixelflinger/format.h>
michael@0 33 #include <hardware/hardware.h>
michael@0 34
michael@0 35 namespace android {
michael@0 36
michael@0 37 enum {
michael@0 38 //
michael@0 39 // these constants need to match those
michael@0 40 // in graphics/PixelFormat.java & pixelflinger/format.h
michael@0 41 //
michael@0 42 PIXEL_FORMAT_UNKNOWN = 0,
michael@0 43 PIXEL_FORMAT_NONE = 0,
michael@0 44
michael@0 45 // logical pixel formats used by the SurfaceFlinger -----------------------
michael@0 46 PIXEL_FORMAT_CUSTOM = -4,
michael@0 47 // Custom pixel-format described by a PixelFormatInfo structure
michael@0 48
michael@0 49 PIXEL_FORMAT_TRANSLUCENT = -3,
michael@0 50 // System chooses a format that supports translucency (many alpha bits)
michael@0 51
michael@0 52 PIXEL_FORMAT_TRANSPARENT = -2,
michael@0 53 // System chooses a format that supports transparency
michael@0 54 // (at least 1 alpha bit)
michael@0 55
michael@0 56 PIXEL_FORMAT_OPAQUE = -1,
michael@0 57 // System chooses an opaque format (no alpha bits required)
michael@0 58
michael@0 59 // real pixel formats supported for rendering -----------------------------
michael@0 60
michael@0 61 PIXEL_FORMAT_RGBA_8888 = HAL_PIXEL_FORMAT_RGBA_8888, // 4x8-bit RGBA
michael@0 62 PIXEL_FORMAT_RGBX_8888 = HAL_PIXEL_FORMAT_RGBX_8888, // 4x8-bit RGB0
michael@0 63 PIXEL_FORMAT_RGB_888 = HAL_PIXEL_FORMAT_RGB_888, // 3x8-bit RGB
michael@0 64 PIXEL_FORMAT_RGB_565 = HAL_PIXEL_FORMAT_RGB_565, // 16-bit RGB
michael@0 65 PIXEL_FORMAT_BGRA_8888 = HAL_PIXEL_FORMAT_BGRA_8888, // 4x8-bit BGRA
michael@0 66 PIXEL_FORMAT_RGBA_5551 = HAL_PIXEL_FORMAT_RGBA_5551, // 16-bit ARGB
michael@0 67 PIXEL_FORMAT_RGBA_4444 = HAL_PIXEL_FORMAT_RGBA_4444, // 16-bit ARGB
michael@0 68 PIXEL_FORMAT_A_8 = GGL_PIXEL_FORMAT_A_8, // 8-bit A
michael@0 69 PIXEL_FORMAT_L_8 = GGL_PIXEL_FORMAT_L_8, // 8-bit L (R=G=B=L)
michael@0 70 PIXEL_FORMAT_LA_88 = GGL_PIXEL_FORMAT_LA_88, // 16-bit LA
michael@0 71 PIXEL_FORMAT_RGB_332 = GGL_PIXEL_FORMAT_RGB_332, // 8-bit RGB
michael@0 72
michael@0 73 // New formats can be added if they're also defined in
michael@0 74 // pixelflinger/format.h
michael@0 75 };
michael@0 76
michael@0 77 typedef int32_t PixelFormat;
michael@0 78
michael@0 79 struct PixelFormatInfo
michael@0 80 {
michael@0 81 enum {
michael@0 82 INDEX_ALPHA = 0,
michael@0 83 INDEX_RED = 1,
michael@0 84 INDEX_GREEN = 2,
michael@0 85 INDEX_BLUE = 3
michael@0 86 };
michael@0 87
michael@0 88 enum { // components
michael@0 89 ALPHA = 1,
michael@0 90 RGB = 2,
michael@0 91 RGBA = 3,
michael@0 92 LUMINANCE = 4,
michael@0 93 LUMINANCE_ALPHA = 5,
michael@0 94 OTHER = 0xFF
michael@0 95 };
michael@0 96
michael@0 97 struct szinfo {
michael@0 98 uint8_t h;
michael@0 99 uint8_t l;
michael@0 100 };
michael@0 101
michael@0 102 inline PixelFormatInfo() : version(sizeof(PixelFormatInfo)) { }
michael@0 103 size_t getScanlineSize(unsigned int width) const;
michael@0 104 size_t getSize(size_t ci) const {
michael@0 105 return (ci <= 3) ? (cinfo[ci].h - cinfo[ci].l) : 0;
michael@0 106 }
michael@0 107 size_t version;
michael@0 108 PixelFormat format;
michael@0 109 size_t bytesPerPixel;
michael@0 110 size_t bitsPerPixel;
michael@0 111 union {
michael@0 112 szinfo cinfo[4];
michael@0 113 struct {
michael@0 114 uint8_t h_alpha;
michael@0 115 uint8_t l_alpha;
michael@0 116 uint8_t h_red;
michael@0 117 uint8_t l_red;
michael@0 118 uint8_t h_green;
michael@0 119 uint8_t l_green;
michael@0 120 uint8_t h_blue;
michael@0 121 uint8_t l_blue;
michael@0 122 };
michael@0 123 };
michael@0 124 uint8_t components;
michael@0 125 uint8_t reserved0[3];
michael@0 126 uint32_t reserved1;
michael@0 127 };
michael@0 128
michael@0 129 // Consider caching the results of these functions are they're not
michael@0 130 // guaranteed to be fast.
michael@0 131 ssize_t bytesPerPixel(PixelFormat format);
michael@0 132 ssize_t bitsPerPixel(PixelFormat format);
michael@0 133 status_t getPixelFormatInfo(PixelFormat format, PixelFormatInfo* info);
michael@0 134
michael@0 135 }; // namespace android
michael@0 136
michael@0 137 #endif // UI_PIXELFORMAT_H

mercurial