2018-11-30 22:52:05 +03:00
|
|
|
/* -*- Mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 4; -*- */
|
2013-12-03 22:44:38 +04:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
|
|
|
#ifndef GLUploadHelpers_h_
|
|
|
|
#define GLUploadHelpers_h_
|
|
|
|
|
|
|
|
#include "GLDefs.h"
|
|
|
|
#include "mozilla/gfx/Types.h"
|
|
|
|
#include "nsPoint.h"
|
2015-11-04 19:49:49 +03:00
|
|
|
#include "nsRegionFwd.h"
|
2013-12-03 22:44:38 +04:00
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
|
|
|
|
namespace gfx {
|
|
|
|
class DataSourceSurface;
|
2015-07-13 18:25:42 +03:00
|
|
|
} // namespace gfx
|
2013-12-03 22:44:38 +04:00
|
|
|
|
|
|
|
namespace gl {
|
|
|
|
|
|
|
|
class GLContext;
|
|
|
|
|
|
|
|
/**
|
2016-10-21 15:27:41 +03:00
|
|
|
* Uploads image data to an OpenGL texture, initializing the texture
|
|
|
|
* first if necessary.
|
|
|
|
*
|
|
|
|
* \param gl The GL Context to use.
|
|
|
|
* \param aData Start of image data of surface to upload.
|
|
|
|
* Corresponds to the first pixel of the texture.
|
2018-04-06 16:01:17 +03:00
|
|
|
* \param aDataSize The image data's size.
|
2016-10-21 15:27:41 +03:00
|
|
|
* \param aStride The image data's stride.
|
|
|
|
* \param aFormat The image data's format.
|
|
|
|
* \param aDstRegion Region of the texture to upload.
|
|
|
|
* \param aTexture The OpenGL texture to use. Must refer to a valid texture.
|
|
|
|
* \param aSize The full size of the texture.
|
|
|
|
* \param aOutUploadSize If set, the number of bytes the texture requires will
|
|
|
|
* be returned here.
|
|
|
|
* \param aNeedInit Indicates whether a new texture must be allocated.
|
|
|
|
* \param aTextureUnit The texture unit used temporarily to upload the surface.
|
|
|
|
* This may be overridden, so clients should not rely on
|
|
|
|
* the aTexture being bound to aTextureUnit after this call,
|
|
|
|
* or even on aTextureUnit being active.
|
|
|
|
* \param aTextureTarget The texture target to use.
|
|
|
|
* \return Surface format of this texture.
|
|
|
|
*/
|
2013-12-03 22:44:38 +04:00
|
|
|
gfx::SurfaceFormat UploadImageDataToTexture(
|
2018-04-06 16:01:17 +03:00
|
|
|
GLContext* gl, unsigned char* aData, const gfx::IntSize& aDataSize,
|
2021-06-17 16:24:05 +03:00
|
|
|
const gfx::IntPoint& aDstOffset,
|
2013-12-03 22:44:38 +04:00
|
|
|
int32_t aStride, gfx::SurfaceFormat aFormat, const nsIntRegion& aDstRegion,
|
2016-10-21 15:27:41 +03:00
|
|
|
GLuint aTexture, const gfx::IntSize& aSize,
|
2016-01-27 00:03:37 +03:00
|
|
|
size_t* aOutUploadSize = nullptr, bool aNeedInit = false,
|
2013-12-03 22:44:38 +04:00
|
|
|
GLenum aTextureUnit = LOCAL_GL_TEXTURE0,
|
|
|
|
GLenum aTextureTarget = LOCAL_GL_TEXTURE_2D);
|
|
|
|
|
|
|
|
/**
|
2016-10-21 15:27:41 +03:00
|
|
|
* Convenience wrapper around UploadImageDataToTexture for
|
|
|
|
* gfx::DataSourceSurface's.
|
|
|
|
*
|
|
|
|
* \param aSurface The surface from which to upload image data.
|
|
|
|
* \param aSrcPoint Offset into aSurface where this texture's data begins.
|
|
|
|
*/
|
2013-12-03 22:44:38 +04:00
|
|
|
gfx::SurfaceFormat UploadSurfaceToTexture(
|
2016-06-11 04:37:07 +03:00
|
|
|
GLContext* gl, gfx::DataSourceSurface* aSurface,
|
2013-12-03 22:44:38 +04:00
|
|
|
const nsIntRegion& aDstRegion, GLuint aTexture, const gfx::IntSize& aSize,
|
2016-01-27 00:03:37 +03:00
|
|
|
size_t* aOutUploadSize = nullptr, bool aNeedInit = false,
|
2021-06-17 16:24:05 +03:00
|
|
|
const gfx::IntPoint& aSrcOffset = gfx::IntPoint(0, 0),
|
|
|
|
const gfx::IntPoint& aDstOffset = gfx::IntPoint(0, 0),
|
2013-12-10 20:11:58 +04:00
|
|
|
GLenum aTextureUnit = LOCAL_GL_TEXTURE0,
|
|
|
|
GLenum aTextureTarget = LOCAL_GL_TEXTURE_2D);
|
2013-12-03 22:44:38 +04:00
|
|
|
|
2021-06-17 16:24:05 +03:00
|
|
|
bool ShouldUploadSubTextures(GLContext* gl);
|
2013-12-03 22:44:38 +04:00
|
|
|
bool CanUploadNonPowerOfTwo(GLContext* gl);
|
2013-12-03 22:44:38 +04:00
|
|
|
|
2015-07-13 18:25:42 +03:00
|
|
|
} // namespace gl
|
|
|
|
} // namespace mozilla
|
2013-12-03 22:44:38 +04:00
|
|
|
|
|
|
|
#endif
|