Commit a5d583e9 by Lingfeng Yang Committed by Commit Bot

GLES1: state: Add crop rect / generate mipmap texparameters

GLES1 has at least two places where all texture objects can carry more state: - Crop rectangle, used with glDrawTex - Generate mipmap parameter, which lets the user auto-generate mipmaps for textures from a texture parameter This CL adds them to the Texture / TextureState classes. BUG=angleproject:2306 Change-Id: Ia43882d36f166b49a09434e77f8c288478e2a454 Reviewed-on: https://chromium-review.googlesource.com/909579Reviewed-by: 's avatarLingfeng Yang <lfy@google.com> Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org> Commit-Queue: Lingfeng Yang <lfy@google.com>
parent 56e9540a
......@@ -124,6 +124,8 @@ TextureState::TextureState(GLenum target)
mUsage(GL_NONE),
mImageDescs((IMPLEMENTATION_MAX_TEXTURE_LEVELS + 1) *
(target == GL_TEXTURE_CUBE_MAP ? 6 : 1)),
mCropRect(0, 0, 0, 0),
mGenerateMipmapHint(GL_FALSE),
mInitState(InitState::MayNeedInit)
{
}
......@@ -169,7 +171,7 @@ GLuint TextureState::getMipmapMaxLevel() const
GLuint expectedMipLevels = 0;
if (mTarget == GL_TEXTURE_3D)
{
const int maxDim = std::max(std::max(baseImageDesc.size.width, baseImageDesc.size.height),
const int maxDim = std::max(std::max(baseImageDesc.size.width, baseImageDesc.size.height),
baseImageDesc.size.depth);
expectedMipLevels = static_cast<GLuint>(log2(maxDim));
}
......@@ -232,6 +234,26 @@ bool TextureState::isCubeComplete() const
return true;
}
void TextureState::setCrop(const gl::Rectangle& rect)
{
mCropRect = rect;
}
const gl::Rectangle& TextureState::getCrop() const
{
return mCropRect;
}
void TextureState::setGenerateMipmapHint(GLenum hint)
{
mGenerateMipmapHint = hint;
}
GLenum TextureState::getGenerateMipmapHint() const
{
return mGenerateMipmapHint;
}
bool TextureState::computeSamplerCompleteness(const SamplerState &samplerState,
const ContextState &data) const
{
......@@ -1114,7 +1136,7 @@ Error Texture::copyTexture(const Context *context,
unpackFlipY, unpackPremultiplyAlpha, unpackUnmultiplyAlpha,
source));
const auto &sourceDesc = source->mState.getImageDesc(source->getTarget(), 0);
const auto &sourceDesc = source->mState.getImageDesc(source->getTarget(), 0);
const InternalFormat &internalFormatInfo = GetInternalFormatInfo(internalFormat, type);
mState.setImageDesc(
target, level,
......@@ -1394,6 +1416,26 @@ GLsizei Texture::getAttachmentSamples(const ImageIndex &imageIndex) const
return getSamples(imageIndex.target, 0);
}
void Texture::setCrop(const gl::Rectangle& rect)
{
mState.setCrop(rect);
}
const gl::Rectangle& Texture::getCrop() const
{
return mState.getCrop();
}
void Texture::setGenerateMipmapHint(GLenum hint)
{
mState.setGenerateMipmapHint(hint);
}
GLenum Texture::getGenerateMipmapHint() const
{
return mState.getGenerateMipmapHint();
}
void Texture::onAttach(const Context *context)
{
addRef();
......
......@@ -9,8 +9,8 @@
#ifndef LIBANGLE_TEXTURE_H_
#define LIBANGLE_TEXTURE_H_
#include <vector>
#include <map>
#include <vector>
#include "angle_gl.h"
#include "common/Optional.h"
......@@ -116,6 +116,14 @@ struct TextureState final : private angle::NonCopyable
GLenum getUsage() const { return mUsage; }
GLenum getDepthStencilTextureMode() const { return mDepthStencilTextureMode; }
// GLES1 emulation: For GL_OES_draw_texture
void setCrop(const gl::Rectangle& rect);
const gl::Rectangle& getCrop() const;
// GLES1 emulation: Auto-mipmap generation is a texparameter
void setGenerateMipmapHint(GLenum hint);
GLenum getGenerateMipmapHint() const;
private:
// Texture needs access to the ImageDesc functions.
friend class Texture;
......@@ -163,14 +171,21 @@ struct TextureState final : private angle::NonCopyable
GLenum mUsage;
std::vector<ImageDesc> mImageDescs;
// GLES1 emulation: Texture crop rectangle
// For GL_OES_draw_texture
gl::Rectangle mCropRect;
// GLES1 emulation: Generate-mipmap hint per texture
GLenum mGenerateMipmapHint;
InitState mInitState;
};
bool operator==(const TextureState &a, const TextureState &b);
bool operator!=(const TextureState &a, const TextureState &b);
class Texture final : public egl::ImageSibling,
public LabeledObject
class Texture final : public egl::ImageSibling, public LabeledObject
{
public:
Texture(rx::GLImplFactory *factory, GLuint id, GLenum target);
......@@ -366,6 +381,12 @@ class Texture final : public egl::ImageSibling,
const Format &getAttachmentFormat(GLenum binding, const ImageIndex &imageIndex) const override;
GLsizei getAttachmentSamples(const ImageIndex &imageIndex) const override;
// GLES1 emulation
void setCrop(const gl::Rectangle& rect);
const gl::Rectangle& getCrop() const;
void setGenerateMipmapHint(GLenum generate);
GLenum getGenerateMipmapHint() const;
void onAttach(const Context *context) override;
void onDetach(const Context *context) override;
GLuint getId() const override;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment