LCOV - code coverage report
Current view: top level - dom/canvas - TexUnpackBlob.h (source / functions) Hit Total Coverage
Test: output.info Lines: 0 5 0.0 %
Date: 2017-07-14 16:53:18 Functions: 0 8 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /* This Source Code Form is subject to the terms of the Mozilla Public
       3             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       4             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
       5             : 
       6             : #ifndef TEX_UNPACK_BLOB_H_
       7             : #define TEX_UNPACK_BLOB_H_
       8             : 
       9             : #include "GLContextTypes.h"
      10             : #include "mozilla/RefPtr.h"
      11             : #include "WebGLStrongTypes.h"
      12             : #include "WebGLTypes.h"
      13             : 
      14             : 
      15             : namespace mozilla {
      16             : 
      17             : class UniqueBuffer;
      18             : class WebGLContext;
      19             : class WebGLTexture;
      20             : 
      21             : namespace dom {
      22             : class Element;
      23             : class HTMLCanvasElement;
      24             : class HTMLVideoElement;
      25             : } // namespace dom
      26             : 
      27             : namespace gfx {
      28             : class DataSourceSurface;
      29             : } // namespace gfx
      30             : 
      31             : namespace layers {
      32             : class Image;
      33             : class ImageContainer;
      34             : } // namespace layers
      35             : 
      36             : namespace webgl {
      37             : 
      38             : struct PackingInfo;
      39             : struct DriverUnpackInfo;
      40             : 
      41             : class TexUnpackBlob
      42             : {
      43             : public:
      44             :     const uint32_t mAlignment;
      45             :     const uint32_t mRowLength;
      46             :     const uint32_t mImageHeight;
      47             :     const uint32_t mSkipPixels;
      48             :     const uint32_t mSkipRows;
      49             :     const uint32_t mSkipImages;
      50             :     const uint32_t mWidth;
      51             :     const uint32_t mHeight;
      52             :     const uint32_t mDepth;
      53             : 
      54             :     const gfxAlphaType mSrcAlphaType;
      55             : 
      56             :     bool mNeedsExactUpload;
      57             : 
      58             : protected:
      59             :     TexUnpackBlob(const WebGLContext* webgl, TexImageTarget target, uint32_t rowLength,
      60             :                   uint32_t width, uint32_t height, uint32_t depth,
      61             :                   gfxAlphaType srcAlphaType);
      62             : 
      63             : public:
      64           0 :     virtual ~TexUnpackBlob() { }
      65             : 
      66             : protected:
      67             :     bool ConvertIfNeeded(WebGLContext* webgl, const char* funcName,
      68             :                          const uint32_t rowLength, const uint32_t rowCount,
      69             :                          WebGLTexelFormat srcFormat,
      70             :                          const uint8_t* const srcBegin, const ptrdiff_t srcStride,
      71             :                          WebGLTexelFormat dstFormat, const ptrdiff_t dstStride,
      72             : 
      73             :                          const uint8_t** const out_begin,
      74             :                          UniqueBuffer* const out_anchoredBuffer) const;
      75             : 
      76             : public:
      77           0 :     virtual bool HasData() const { return true; }
      78             : 
      79             :     virtual bool Validate(WebGLContext* webgl, const char* funcName,
      80             :                           const webgl::PackingInfo& pi) = 0;
      81             : 
      82             :     // Returns false when we've generated a WebGL error.
      83             :     // Returns true but with a non-zero *out_error if we still need to generate a WebGL
      84             :     // error.
      85             :     virtual bool TexOrSubImage(bool isSubImage, bool needsRespec, const char* funcName,
      86             :                                WebGLTexture* tex, TexImageTarget target, GLint level,
      87             :                                const webgl::DriverUnpackInfo* dui, GLint xOffset,
      88             :                                GLint yOffset, GLint zOffset,
      89             :                                const webgl::PackingInfo& pi, GLenum* const out_error) const = 0;
      90             : };
      91             : 
      92           0 : class TexUnpackBytes final : public TexUnpackBlob
      93             : {
      94             : public:
      95             :     const bool mIsClientData;
      96             :     const uint8_t* const mPtr;
      97             :     const size_t mAvailBytes;
      98             : 
      99             :     TexUnpackBytes(const WebGLContext* webgl, TexImageTarget target, uint32_t width,
     100             :                    uint32_t height, uint32_t depth, bool isClientData, const uint8_t* ptr,
     101             :                    size_t availBytes);
     102             : 
     103           0 :     virtual bool HasData() const override { return !mIsClientData || bool(mPtr); }
     104             : 
     105             :     virtual bool Validate(WebGLContext* webgl, const char* funcName,
     106             :                           const webgl::PackingInfo& pi) override;
     107             :     virtual bool TexOrSubImage(bool isSubImage, bool needsRespec, const char* funcName,
     108             :                                WebGLTexture* tex, TexImageTarget target, GLint level,
     109             :                                const webgl::DriverUnpackInfo* dui, GLint xOffset,
     110             :                                GLint yOffset, GLint zOffset,
     111             :                                const webgl::PackingInfo& pi, GLenum* const out_error) const override;
     112             : };
     113             : 
     114             : class TexUnpackImage final : public TexUnpackBlob
     115             : {
     116             : public:
     117             :     const RefPtr<layers::Image> mImage;
     118             : 
     119             :     TexUnpackImage(const WebGLContext* webgl, TexImageTarget target, uint32_t width,
     120             :                    uint32_t height, uint32_t depth, layers::Image* image,
     121             :                    gfxAlphaType srcAlphaType);
     122             : 
     123             :     ~TexUnpackImage(); // Prevent needing to define layers::Image in the header.
     124             : 
     125             :     virtual bool Validate(WebGLContext* webgl, const char* funcName,
     126             :                           const webgl::PackingInfo& pi) override;
     127             :     virtual bool TexOrSubImage(bool isSubImage, bool needsRespec, const char* funcName,
     128             :                                WebGLTexture* tex, TexImageTarget target, GLint level,
     129             :                                const webgl::DriverUnpackInfo* dui, GLint xOffset,
     130             :                                GLint yOffset, GLint zOffset,
     131             :                                const webgl::PackingInfo& dstPI, GLenum* const out_error)  const override;
     132             : };
     133             : 
     134           0 : class TexUnpackSurface final : public TexUnpackBlob
     135             : {
     136             : public:
     137             :     const RefPtr<gfx::DataSourceSurface> mSurf;
     138             : 
     139             :     TexUnpackSurface(const WebGLContext* webgl, TexImageTarget target, uint32_t width,
     140             :                      uint32_t height, uint32_t depth, gfx::DataSourceSurface* surf,
     141             :                      gfxAlphaType srcAlphaType);
     142             : 
     143             :     virtual bool Validate(WebGLContext* webgl, const char* funcName,
     144             :                           const webgl::PackingInfo& pi) override;
     145             :     virtual bool TexOrSubImage(bool isSubImage, bool needsRespec, const char* funcName,
     146             :                                WebGLTexture* tex, TexImageTarget target, GLint level,
     147             :                                const webgl::DriverUnpackInfo* dui, GLint xOffset,
     148             :                                GLint yOffset, GLint zOffset,
     149             :                                const webgl::PackingInfo& dstPI, GLenum* const out_error) const override;
     150             : };
     151             : 
     152             : } // namespace webgl
     153             : } // namespace mozilla
     154             : 
     155             : #endif // TEX_UNPACK_BLOB_H_

Generated by: LCOV version 1.13