gfx/layers/GrallocImages.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/gfx/layers/GrallocImages.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,109 @@
     1.4 +/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 2 -*-
     1.5 + * This Source Code Form is subject to the terms of the Mozilla Public
     1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.8 +
     1.9 +#ifndef GRALLOCIMAGES_H
    1.10 +#define GRALLOCIMAGES_H
    1.11 +
    1.12 +#ifdef MOZ_WIDGET_GONK
    1.13 +
    1.14 +#include "ImageLayers.h"
    1.15 +#include "ImageContainer.h"
    1.16 +#include "mozilla/gfx/Point.h"
    1.17 +#include "mozilla/layers/AtomicRefCountedWithFinalize.h"
    1.18 +#include "mozilla/layers/FenceUtils.h"
    1.19 +#include "mozilla/layers/LayersSurfaces.h"
    1.20 +
    1.21 +#include <ui/GraphicBuffer.h>
    1.22 +
    1.23 +namespace mozilla {
    1.24 +namespace layers {
    1.25 +
    1.26 +class GrallocTextureClientOGL;
    1.27 +
    1.28 +/**
    1.29 + * The YUV format supported by Android HAL
    1.30 + *
    1.31 + * 4:2:0 - CbCr width and height is half that of Y.
    1.32 + *
    1.33 + * This format assumes
    1.34 + * - an even width
    1.35 + * - an even height
    1.36 + * - a horizontal stride multiple of 16 pixels
    1.37 + * - a vertical stride equal to the height
    1.38 + *
    1.39 + * y_size = stride * height
    1.40 + * c_size = ALIGN(stride/2, 16) * height/2
    1.41 + * size = y_size + c_size * 2
    1.42 + * cr_offset = y_size
    1.43 + * cb_offset = y_size + c_size
    1.44 + *
    1.45 + * The Image that is rendered is the picture region defined by
    1.46 + * mPicX, mPicY and mPicSize. The size of the rendered image is
    1.47 + * mPicSize, not mYSize or mCbCrSize.
    1.48 + */
    1.49 +class GrallocImage : public PlanarYCbCrImage
    1.50 +                   , public ISharedImage
    1.51 +{
    1.52 +  typedef PlanarYCbCrData Data;
    1.53 +  static uint32_t sColorIdMap[];
    1.54 +public:
    1.55 +  struct GrallocData {
    1.56 +    nsRefPtr<TextureClient> mGraphicBuffer;
    1.57 +    gfx::IntSize mPicSize;
    1.58 +  };
    1.59 +
    1.60 +  GrallocImage();
    1.61 +
    1.62 +  virtual ~GrallocImage();
    1.63 +
    1.64 +  /**
    1.65 +   * This makes a copy of the data buffers, in order to support functioning
    1.66 +   * in all different layer managers.
    1.67 +   */
    1.68 +  virtual void SetData(const Data& aData);
    1.69 +
    1.70 +  /**
    1.71 +   *  Share the SurfaceDescriptor without making the copy, in order
    1.72 +   *  to support functioning in all different layer managers.
    1.73 +   */
    1.74 +  virtual void SetData(const GrallocData& aData);
    1.75 +
    1.76 +  // From [android 4.0.4]/hardware/msm7k/libgralloc-qsd8k/gralloc_priv.h
    1.77 +  enum {
    1.78 +    /* OEM specific HAL formats */
    1.79 +    HAL_PIXEL_FORMAT_YCbCr_422_P            = 0x102,
    1.80 +    HAL_PIXEL_FORMAT_YCbCr_420_P            = 0x103,
    1.81 +    HAL_PIXEL_FORMAT_YCbCr_420_SP           = 0x109,
    1.82 +    HAL_PIXEL_FORMAT_YCrCb_420_SP_ADRENO    = 0x10A,
    1.83 +    HAL_PIXEL_FORMAT_YCbCr_420_SP_TILED     = 0x7FA30C03,
    1.84 +    HAL_PIXEL_FORMAT_YCbCr_420_SP_VENUS     = 0x7FA30C04,
    1.85 +  };
    1.86 +
    1.87 +  virtual TemporaryRef<gfx::SourceSurface> GetAsSourceSurface() MOZ_OVERRIDE;
    1.88 +
    1.89 +  android::sp<android::GraphicBuffer> GetGraphicBuffer() const;
    1.90 +
    1.91 +  void* GetNativeBuffer();
    1.92 +
    1.93 +  virtual bool IsValid() { return !!mTextureClient; }
    1.94 +
    1.95 +  virtual ISharedImage* AsSharedImage() MOZ_OVERRIDE { return this; }
    1.96 +
    1.97 +  virtual TextureClient* GetTextureClient(CompositableClient* aClient) MOZ_OVERRIDE;
    1.98 +
    1.99 +  virtual uint8_t* GetBuffer()
   1.100 +  {
   1.101 +    return static_cast<uint8_t*>(GetNativeBuffer());
   1.102 +  }
   1.103 +
   1.104 +private:
   1.105 +  RefPtr<GrallocTextureClientOGL> mTextureClient;
   1.106 +};
   1.107 +
   1.108 +} // namespace layers
   1.109 +} // namespace mozilla
   1.110 +#endif
   1.111 +
   1.112 +#endif /* GRALLOCIMAGES_H */

mercurial