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

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     1 /*
     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  */
    17 #ifndef ANDROID_GRAPHIC_BUFFER_H
    18 #define ANDROID_GRAPHIC_BUFFER_H
    20 #include <stdint.h>
    21 #include <sys/types.h>
    23 #include <ui/android_native_buffer.h>
    24 #include <ui/PixelFormat.h>
    25 #include <ui/Rect.h>
    26 #include <utils/Flattenable.h>
    27 #include <pixelflinger/pixelflinger.h>
    29 struct android_native_buffer_t;
    31 namespace android {
    33 class GraphicBufferMapper;
    35 // ===========================================================================
    36 // GraphicBuffer
    37 // ===========================================================================
    39 class GraphicBuffer
    40     : public EGLNativeBase<
    41         android_native_buffer_t, 
    42         GraphicBuffer, 
    43         LightRefBase<GraphicBuffer> >, public Flattenable
    44 {
    45 public:
    47     enum {
    48         USAGE_SW_READ_NEVER     = GRALLOC_USAGE_SW_READ_NEVER,
    49         USAGE_SW_READ_RARELY    = GRALLOC_USAGE_SW_READ_RARELY,
    50         USAGE_SW_READ_OFTEN     = GRALLOC_USAGE_SW_READ_OFTEN,
    51         USAGE_SW_READ_MASK      = GRALLOC_USAGE_SW_READ_MASK,
    53         USAGE_SW_WRITE_NEVER    = GRALLOC_USAGE_SW_WRITE_NEVER,
    54         USAGE_SW_WRITE_RARELY   = GRALLOC_USAGE_SW_WRITE_RARELY,
    55         USAGE_SW_WRITE_OFTEN    = GRALLOC_USAGE_SW_WRITE_OFTEN,
    56         USAGE_SW_WRITE_MASK     = GRALLOC_USAGE_SW_WRITE_MASK,
    58         USAGE_SOFTWARE_MASK     = USAGE_SW_READ_MASK|USAGE_SW_WRITE_MASK,
    60         USAGE_HW_TEXTURE        = GRALLOC_USAGE_HW_TEXTURE,
    61         USAGE_HW_RENDER         = GRALLOC_USAGE_HW_RENDER,
    62         USAGE_HW_2D             = GRALLOC_USAGE_HW_2D,
    63         USAGE_HW_MASK           = GRALLOC_USAGE_HW_MASK
    64     };
    66     GraphicBuffer();
    68     // creates w * h buffer
    69     GraphicBuffer(uint32_t w, uint32_t h, PixelFormat format, uint32_t usage);
    71     // create a buffer from an existing handle
    72     GraphicBuffer(uint32_t w, uint32_t h, PixelFormat format, uint32_t usage,
    73             uint32_t stride, native_handle_t* handle, bool keepOwnership);
    75     // return status
    76     status_t initCheck() const;
    78     uint32_t getWidth() const           { return width; }
    79     uint32_t getHeight() const          { return height; }
    80     uint32_t getStride() const          { return stride; }
    81     uint32_t getUsage() const           { return usage; }
    82     PixelFormat getPixelFormat() const  { return format; }
    83     Rect getBounds() const              { return Rect(width, height); }
    85     status_t reallocate(uint32_t w, uint32_t h, PixelFormat f, uint32_t usage);
    87     status_t lock(uint32_t usage, void** vaddr);
    88     status_t lock(uint32_t usage, const Rect& rect, void** vaddr);
    89     status_t lock(GGLSurface* surface, uint32_t usage);
    90     status_t unlock();
    92     android_native_buffer_t* getNativeBuffer() const;
    94     void setIndex(int index);
    95     int getIndex() const;
    96     void setVerticalStride(uint32_t vstride);
    97     uint32_t getVerticalStride() const;
    99 protected:
   100     virtual ~GraphicBuffer();
   102     enum {
   103         ownNone   = 0,
   104         ownHandle = 1,
   105         ownData   = 2,
   106     };
   108     inline const GraphicBufferMapper& getBufferMapper() const { return mBufferMapper; }
   109     inline GraphicBufferMapper& getBufferMapper() { return mBufferMapper; }
   110     uint8_t mOwner;
   112 private:
   113     friend class Surface;
   114     friend class BpSurface;
   115     friend class BnSurface;
   116     friend class LightRefBase<GraphicBuffer>;
   117     GraphicBuffer(const GraphicBuffer& rhs);
   118     GraphicBuffer& operator = (const GraphicBuffer& rhs);
   119     const GraphicBuffer& operator = (const GraphicBuffer& rhs) const;
   121     status_t initSize(uint32_t w, uint32_t h, PixelFormat format, 
   122             uint32_t usage);
   124     void free_handle();
   126     // Flattenable interface
   127     size_t getFlattenedSize() const;
   128     size_t getFdCount() const;
   129     status_t flatten(void* buffer, size_t size,
   130             int fds[], size_t count) const;
   131     status_t unflatten(void const* buffer, size_t size,
   132             int fds[], size_t count);
   135     GraphicBufferMapper& mBufferMapper;
   136     ssize_t mInitCheck;
   137     uint32_t mVStride;
   138     int mIndex;
   139 };
   141 }; // namespace android
   143 #endif // ANDROID_GRAPHIC_BUFFER_H

mercurial