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

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/media/omx-plugin/include/ics/ui/PixelFormat.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,137 @@
     1.4 +/*
     1.5 + * Copyright (C) 2005 The Android Open Source Project
     1.6 + *
     1.7 + * Licensed under the Apache License, Version 2.0 (the "License");
     1.8 + * you may not use this file except in compliance with the License.
     1.9 + * You may obtain a copy of the License at
    1.10 + *
    1.11 + *      http://www.apache.org/licenses/LICENSE-2.0
    1.12 + *
    1.13 + * Unless required by applicable law or agreed to in writing, software
    1.14 + * distributed under the License is distributed on an "AS IS" BASIS,
    1.15 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    1.16 + * See the License for the specific language governing permissions and
    1.17 + * limitations under the License.
    1.18 + */
    1.19 +
    1.20 +//
    1.21 +
    1.22 +// Pixel formats used across the system.
    1.23 +// These formats might not all be supported by all renderers, for instance
    1.24 +// skia or SurfaceFlinger are not required to support all of these formats
    1.25 +// (either as source or destination)
    1.26 +
    1.27 +// XXX: we should consolidate these formats and skia's
    1.28 +
    1.29 +#ifndef UI_PIXELFORMAT_H
    1.30 +#define UI_PIXELFORMAT_H
    1.31 +
    1.32 +#include <stdint.h>
    1.33 +#include <sys/types.h>
    1.34 +#include <utils/Errors.h>
    1.35 +#include <pixelflinger/format.h>
    1.36 +#include <hardware/hardware.h>
    1.37 +
    1.38 +namespace android {
    1.39 +
    1.40 +enum {
    1.41 +    //
    1.42 +    // these constants need to match those
    1.43 +    // in graphics/PixelFormat.java & pixelflinger/format.h
    1.44 +    //
    1.45 +    PIXEL_FORMAT_UNKNOWN    =   0,
    1.46 +    PIXEL_FORMAT_NONE       =   0,
    1.47 +
    1.48 +    // logical pixel formats used by the SurfaceFlinger -----------------------
    1.49 +    PIXEL_FORMAT_CUSTOM         = -4,
    1.50 +        // Custom pixel-format described by a PixelFormatInfo structure
    1.51 +
    1.52 +    PIXEL_FORMAT_TRANSLUCENT    = -3,
    1.53 +        // System chooses a format that supports translucency (many alpha bits)
    1.54 +
    1.55 +    PIXEL_FORMAT_TRANSPARENT    = -2,
    1.56 +        // System chooses a format that supports transparency
    1.57 +        // (at least 1 alpha bit)
    1.58 +
    1.59 +    PIXEL_FORMAT_OPAQUE         = -1,
    1.60 +        // System chooses an opaque format (no alpha bits required)
    1.61 +
    1.62 +    // real pixel formats supported for rendering -----------------------------
    1.63 +
    1.64 +    PIXEL_FORMAT_RGBA_8888   = HAL_PIXEL_FORMAT_RGBA_8888,  // 4x8-bit RGBA
    1.65 +    PIXEL_FORMAT_RGBX_8888   = HAL_PIXEL_FORMAT_RGBX_8888,  // 4x8-bit RGB0
    1.66 +    PIXEL_FORMAT_RGB_888     = HAL_PIXEL_FORMAT_RGB_888,    // 3x8-bit RGB
    1.67 +    PIXEL_FORMAT_RGB_565     = HAL_PIXEL_FORMAT_RGB_565,    // 16-bit RGB
    1.68 +    PIXEL_FORMAT_BGRA_8888   = HAL_PIXEL_FORMAT_BGRA_8888,  // 4x8-bit BGRA
    1.69 +    PIXEL_FORMAT_RGBA_5551   = HAL_PIXEL_FORMAT_RGBA_5551,  // 16-bit ARGB
    1.70 +    PIXEL_FORMAT_RGBA_4444   = HAL_PIXEL_FORMAT_RGBA_4444,  // 16-bit ARGB
    1.71 +    PIXEL_FORMAT_A_8         = GGL_PIXEL_FORMAT_A_8,        // 8-bit A
    1.72 +    PIXEL_FORMAT_L_8         = GGL_PIXEL_FORMAT_L_8,        // 8-bit L (R=G=B=L)
    1.73 +    PIXEL_FORMAT_LA_88       = GGL_PIXEL_FORMAT_LA_88,      // 16-bit LA
    1.74 +    PIXEL_FORMAT_RGB_332     = GGL_PIXEL_FORMAT_RGB_332,    // 8-bit RGB
    1.75 +
    1.76 +    // New formats can be added if they're also defined in
    1.77 +    // pixelflinger/format.h
    1.78 +};
    1.79 +
    1.80 +typedef int32_t PixelFormat;
    1.81 +
    1.82 +struct PixelFormatInfo
    1.83 +{
    1.84 +    enum {
    1.85 +        INDEX_ALPHA   = 0,
    1.86 +        INDEX_RED     = 1,
    1.87 +        INDEX_GREEN   = 2,
    1.88 +        INDEX_BLUE    = 3
    1.89 +    };
    1.90 +
    1.91 +    enum { // components
    1.92 +        ALPHA               = 1,
    1.93 +        RGB                 = 2,
    1.94 +        RGBA                = 3,
    1.95 +        LUMINANCE           = 4,
    1.96 +        LUMINANCE_ALPHA     = 5,
    1.97 +        OTHER               = 0xFF
    1.98 +    };
    1.99 +
   1.100 +    struct szinfo {
   1.101 +        uint8_t h;
   1.102 +        uint8_t l;
   1.103 +    };
   1.104 +
   1.105 +    inline PixelFormatInfo() : version(sizeof(PixelFormatInfo)) { }
   1.106 +    size_t getScanlineSize(unsigned int width) const;
   1.107 +    size_t getSize(size_t ci) const {
   1.108 +        return (ci <= 3) ? (cinfo[ci].h - cinfo[ci].l) : 0;
   1.109 +    }
   1.110 +    size_t      version;
   1.111 +    PixelFormat format;
   1.112 +    size_t      bytesPerPixel;
   1.113 +    size_t      bitsPerPixel;
   1.114 +    union {
   1.115 +        szinfo      cinfo[4];
   1.116 +        struct {
   1.117 +            uint8_t     h_alpha;
   1.118 +            uint8_t     l_alpha;
   1.119 +            uint8_t     h_red;
   1.120 +            uint8_t     l_red;
   1.121 +            uint8_t     h_green;
   1.122 +            uint8_t     l_green;
   1.123 +            uint8_t     h_blue;
   1.124 +            uint8_t     l_blue;
   1.125 +        };
   1.126 +    };
   1.127 +    uint8_t     components;
   1.128 +    uint8_t     reserved0[3];
   1.129 +    uint32_t    reserved1;
   1.130 +};
   1.131 +
   1.132 +// Consider caching the results of these functions are they're not
   1.133 +// guaranteed to be fast.
   1.134 +ssize_t     bytesPerPixel(PixelFormat format);
   1.135 +ssize_t     bitsPerPixel(PixelFormat format);
   1.136 +status_t    getPixelFormatInfo(PixelFormat format, PixelFormatInfo* info);
   1.137 +
   1.138 +}; // namespace android
   1.139 +
   1.140 +#endif // UI_PIXELFORMAT_H

mercurial