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) ...@@ -124,6 +124,8 @@ TextureState::TextureState(GLenum target)
mUsage(GL_NONE), mUsage(GL_NONE),
mImageDescs((IMPLEMENTATION_MAX_TEXTURE_LEVELS + 1) * mImageDescs((IMPLEMENTATION_MAX_TEXTURE_LEVELS + 1) *
(target == GL_TEXTURE_CUBE_MAP ? 6 : 1)), (target == GL_TEXTURE_CUBE_MAP ? 6 : 1)),
mCropRect(0, 0, 0, 0),
mGenerateMipmapHint(GL_FALSE),
mInitState(InitState::MayNeedInit) mInitState(InitState::MayNeedInit)
{ {
} }
...@@ -232,6 +234,26 @@ bool TextureState::isCubeComplete() const ...@@ -232,6 +234,26 @@ bool TextureState::isCubeComplete() const
return true; 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, bool TextureState::computeSamplerCompleteness(const SamplerState &samplerState,
const ContextState &data) const const ContextState &data) const
{ {
...@@ -1394,6 +1416,26 @@ GLsizei Texture::getAttachmentSamples(const ImageIndex &imageIndex) const ...@@ -1394,6 +1416,26 @@ GLsizei Texture::getAttachmentSamples(const ImageIndex &imageIndex) const
return getSamples(imageIndex.target, 0); 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) void Texture::onAttach(const Context *context)
{ {
addRef(); addRef();
......
...@@ -9,8 +9,8 @@ ...@@ -9,8 +9,8 @@
#ifndef LIBANGLE_TEXTURE_H_ #ifndef LIBANGLE_TEXTURE_H_
#define LIBANGLE_TEXTURE_H_ #define LIBANGLE_TEXTURE_H_
#include <vector>
#include <map> #include <map>
#include <vector>
#include "angle_gl.h" #include "angle_gl.h"
#include "common/Optional.h" #include "common/Optional.h"
...@@ -116,6 +116,14 @@ struct TextureState final : private angle::NonCopyable ...@@ -116,6 +116,14 @@ struct TextureState final : private angle::NonCopyable
GLenum getUsage() const { return mUsage; } GLenum getUsage() const { return mUsage; }
GLenum getDepthStencilTextureMode() const { return mDepthStencilTextureMode; } 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: private:
// Texture needs access to the ImageDesc functions. // Texture needs access to the ImageDesc functions.
friend class Texture; friend class Texture;
...@@ -163,14 +171,21 @@ struct TextureState final : private angle::NonCopyable ...@@ -163,14 +171,21 @@ struct TextureState final : private angle::NonCopyable
GLenum mUsage; GLenum mUsage;
std::vector<ImageDesc> mImageDescs; 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; InitState mInitState;
}; };
bool operator==(const TextureState &a, const TextureState &b); bool operator==(const TextureState &a, const TextureState &b);
bool operator!=(const TextureState &a, const TextureState &b); bool operator!=(const TextureState &a, const TextureState &b);
class Texture final : public egl::ImageSibling, class Texture final : public egl::ImageSibling, public LabeledObject
public LabeledObject
{ {
public: public:
Texture(rx::GLImplFactory *factory, GLuint id, GLenum target); Texture(rx::GLImplFactory *factory, GLuint id, GLenum target);
...@@ -366,6 +381,12 @@ class Texture final : public egl::ImageSibling, ...@@ -366,6 +381,12 @@ class Texture final : public egl::ImageSibling,
const Format &getAttachmentFormat(GLenum binding, const ImageIndex &imageIndex) const override; const Format &getAttachmentFormat(GLenum binding, const ImageIndex &imageIndex) const override;
GLsizei getAttachmentSamples(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 onAttach(const Context *context) override;
void onDetach(const Context *context) override; void onDetach(const Context *context) override;
GLuint getId() const 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