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

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/media/omx-plugin/include/froyo/ui/GraphicBuffer.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,143 @@
     1.4 +/*
     1.5 + * Copyright (C) 2007 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 +#ifndef ANDROID_GRAPHIC_BUFFER_H
    1.21 +#define ANDROID_GRAPHIC_BUFFER_H
    1.22 +
    1.23 +#include <stdint.h>
    1.24 +#include <sys/types.h>
    1.25 +
    1.26 +#include <ui/android_native_buffer.h>
    1.27 +#include <ui/PixelFormat.h>
    1.28 +#include <ui/Rect.h>
    1.29 +#include <utils/Flattenable.h>
    1.30 +#include <pixelflinger/pixelflinger.h>
    1.31 +
    1.32 +struct android_native_buffer_t;
    1.33 +
    1.34 +namespace android {
    1.35 +
    1.36 +class GraphicBufferMapper;
    1.37 +
    1.38 +// ===========================================================================
    1.39 +// GraphicBuffer
    1.40 +// ===========================================================================
    1.41 +
    1.42 +class GraphicBuffer
    1.43 +    : public EGLNativeBase<
    1.44 +        android_native_buffer_t, 
    1.45 +        GraphicBuffer, 
    1.46 +        LightRefBase<GraphicBuffer> >, public Flattenable
    1.47 +{
    1.48 +public:
    1.49 +
    1.50 +    enum {
    1.51 +        USAGE_SW_READ_NEVER     = GRALLOC_USAGE_SW_READ_NEVER,
    1.52 +        USAGE_SW_READ_RARELY    = GRALLOC_USAGE_SW_READ_RARELY,
    1.53 +        USAGE_SW_READ_OFTEN     = GRALLOC_USAGE_SW_READ_OFTEN,
    1.54 +        USAGE_SW_READ_MASK      = GRALLOC_USAGE_SW_READ_MASK,
    1.55 +        
    1.56 +        USAGE_SW_WRITE_NEVER    = GRALLOC_USAGE_SW_WRITE_NEVER,
    1.57 +        USAGE_SW_WRITE_RARELY   = GRALLOC_USAGE_SW_WRITE_RARELY,
    1.58 +        USAGE_SW_WRITE_OFTEN    = GRALLOC_USAGE_SW_WRITE_OFTEN,
    1.59 +        USAGE_SW_WRITE_MASK     = GRALLOC_USAGE_SW_WRITE_MASK,
    1.60 +        
    1.61 +        USAGE_SOFTWARE_MASK     = USAGE_SW_READ_MASK|USAGE_SW_WRITE_MASK,
    1.62 +        
    1.63 +        USAGE_HW_TEXTURE        = GRALLOC_USAGE_HW_TEXTURE,
    1.64 +        USAGE_HW_RENDER         = GRALLOC_USAGE_HW_RENDER,
    1.65 +        USAGE_HW_2D             = GRALLOC_USAGE_HW_2D,
    1.66 +        USAGE_HW_MASK           = GRALLOC_USAGE_HW_MASK
    1.67 +    };
    1.68 +
    1.69 +    GraphicBuffer();
    1.70 +
    1.71 +    // creates w * h buffer
    1.72 +    GraphicBuffer(uint32_t w, uint32_t h, PixelFormat format, uint32_t usage);
    1.73 +
    1.74 +    // create a buffer from an existing handle
    1.75 +    GraphicBuffer(uint32_t w, uint32_t h, PixelFormat format, uint32_t usage,
    1.76 +            uint32_t stride, native_handle_t* handle, bool keepOwnership);
    1.77 +
    1.78 +    // return status
    1.79 +    status_t initCheck() const;
    1.80 +
    1.81 +    uint32_t getWidth() const           { return width; }
    1.82 +    uint32_t getHeight() const          { return height; }
    1.83 +    uint32_t getStride() const          { return stride; }
    1.84 +    uint32_t getUsage() const           { return usage; }
    1.85 +    PixelFormat getPixelFormat() const  { return format; }
    1.86 +    Rect getBounds() const              { return Rect(width, height); }
    1.87 +    
    1.88 +    status_t reallocate(uint32_t w, uint32_t h, PixelFormat f, uint32_t usage);
    1.89 +
    1.90 +    status_t lock(uint32_t usage, void** vaddr);
    1.91 +    status_t lock(uint32_t usage, const Rect& rect, void** vaddr);
    1.92 +    status_t lock(GGLSurface* surface, uint32_t usage);
    1.93 +    status_t unlock();
    1.94 +    
    1.95 +    android_native_buffer_t* getNativeBuffer() const;
    1.96 +    
    1.97 +    void setIndex(int index);
    1.98 +    int getIndex() const;
    1.99 +    void setVerticalStride(uint32_t vstride);
   1.100 +    uint32_t getVerticalStride() const;
   1.101 +
   1.102 +protected:
   1.103 +    virtual ~GraphicBuffer();
   1.104 +
   1.105 +    enum {
   1.106 +        ownNone   = 0,
   1.107 +        ownHandle = 1,
   1.108 +        ownData   = 2,
   1.109 +    };
   1.110 +
   1.111 +    inline const GraphicBufferMapper& getBufferMapper() const { return mBufferMapper; }
   1.112 +    inline GraphicBufferMapper& getBufferMapper() { return mBufferMapper; }
   1.113 +    uint8_t mOwner;
   1.114 +
   1.115 +private:
   1.116 +    friend class Surface;
   1.117 +    friend class BpSurface;
   1.118 +    friend class BnSurface;
   1.119 +    friend class LightRefBase<GraphicBuffer>;
   1.120 +    GraphicBuffer(const GraphicBuffer& rhs);
   1.121 +    GraphicBuffer& operator = (const GraphicBuffer& rhs);
   1.122 +    const GraphicBuffer& operator = (const GraphicBuffer& rhs) const;
   1.123 +
   1.124 +    status_t initSize(uint32_t w, uint32_t h, PixelFormat format, 
   1.125 +            uint32_t usage);
   1.126 +
   1.127 +    void free_handle();
   1.128 +
   1.129 +    // Flattenable interface
   1.130 +    size_t getFlattenedSize() const;
   1.131 +    size_t getFdCount() const;
   1.132 +    status_t flatten(void* buffer, size_t size,
   1.133 +            int fds[], size_t count) const;
   1.134 +    status_t unflatten(void const* buffer, size_t size,
   1.135 +            int fds[], size_t count);
   1.136 +
   1.137 +
   1.138 +    GraphicBufferMapper& mBufferMapper;
   1.139 +    ssize_t mInitCheck;
   1.140 +    uint32_t mVStride;
   1.141 +    int mIndex;
   1.142 +};
   1.143 +
   1.144 +}; // namespace android
   1.145 +
   1.146 +#endif // ANDROID_GRAPHIC_BUFFER_H

mercurial