Skip to content

Commit

Permalink
Change the consts in GLDefines.h from GL::XXX to GL_XXX. (#137)
Browse files Browse the repository at this point in the history
  • Loading branch information
domchen authored Feb 24, 2022
1 parent 66e558d commit f7093c3
Show file tree
Hide file tree
Showing 32 changed files with 1,064 additions and 1,062 deletions.
2 changes: 1 addition & 1 deletion src/platform/android/VideoSurface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ bool VideoSurface::attachToContext(JNIEnv* env, tgfx::Context* context) {
}
auto gl = tgfx::GLContext::Unwrap(context);
tgfx::GLSampler sampler = {};
sampler.target = GL::TEXTURE_EXTERNAL_OES;
sampler.target = GL_TEXTURE_EXTERNAL_OES;
sampler.format = tgfx::PixelFormat::RGBA_8888;
gl->genTextures(1, &sampler.id);
if (sampler.id == 0) {
Expand Down
2 changes: 1 addition & 1 deletion src/platform/web/VideoSequenceReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ std::shared_ptr<tgfx::Texture> VideoSequenceReader::readTexture(Frame targetFram
if (texture == nullptr) {
texture = tgfx::GLTexture::MakeRGBA(cache->getContext(), width, height);
}
auto& glInfo = std::static_pointer_cast<tgfx::GLTexture>(texture)->getGLInfo();
auto& glInfo = std::static_pointer_cast<tgfx::GLTexture>(texture)->glSampler();
videoReader.call<void>("renderToTexture", val::module_property("GL"), glInfo.id);
lastFrame = targetFrame;
return texture;
Expand Down
10 changes: 5 additions & 5 deletions src/rendering/filters/CornerPinFilter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -143,15 +143,15 @@ void CornerPinFilter::bindVertices(const tgfx::GLInterface* gl, const FilterSour
if (filterProgram->vertexArray > 0) {
gl->bindVertexArray(filterProgram->vertexArray);
}
gl->bindBuffer(GL::ARRAY_BUFFER, filterProgram->vertexBuffer);
gl->bufferData(GL::ARRAY_BUFFER, vertices.size() * sizeof(float), &vertices[0], GL::STREAM_DRAW);
gl->vertexAttribPointer(static_cast<unsigned>(positionHandle), 2, GL::FLOAT, GL::FALSE,
gl->bindBuffer(GL_ARRAY_BUFFER, filterProgram->vertexBuffer);
gl->bufferData(GL_ARRAY_BUFFER, vertices.size() * sizeof(float), &vertices[0], GL_STREAM_DRAW);
gl->vertexAttribPointer(static_cast<unsigned>(positionHandle), 2, GL_FLOAT, GL_FALSE,
5 * sizeof(float), static_cast<void*>(0));
gl->enableVertexAttribArray(static_cast<unsigned>(positionHandle));

gl->vertexAttribPointer(textureCoordHandle, 3, GL::FLOAT, GL::FALSE, 5 * sizeof(float),
gl->vertexAttribPointer(textureCoordHandle, 3, GL_FLOAT, GL_FALSE, 5 * sizeof(float),
reinterpret_cast<void*>(2 * sizeof(float)));
gl->enableVertexAttribArray(textureCoordHandle);
gl->bindBuffer(GL::ARRAY_BUFFER, 0);
gl->bindBuffer(GL_ARRAY_BUFFER, 0);
}
} // namespace pag
2 changes: 1 addition & 1 deletion src/rendering/filters/DisplacementMapFilter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ void DisplacementMapFilter::onUpdateParams(const tgfx::GLInterface* gl,
const tgfx::Rect& contentBounds, const tgfx::Point&) {
auto* pagEffect = reinterpret_cast<const DisplacementMapEffect*>(effect);
auto mapTextureID = GetTextureID(mapSurface->getTexture().get());
ActiveGLTexture(gl, GL::TEXTURE1, GL::TEXTURE_2D, mapTextureID);
ActiveGLTexture(gl, GL_TEXTURE1, GL_TEXTURE_2D, mapTextureID);
gl->uniform2f(useForDisplacementHandle,
pagEffect->useForHorizontalDisplacement->getValueAt(layerFrame),
pagEffect->useForVerticalDisplacement->getValueAt(layerFrame));
Expand Down
30 changes: 15 additions & 15 deletions src/rendering/filters/LayerFilter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -205,13 +205,13 @@ void LayerFilter::update(Frame frame, const tgfx::Rect& inputBounds, const tgfx:

static void EnableMultisample(const tgfx::GLInterface* gl, bool usesMSAA) {
if (usesMSAA && gl->caps->multisampleDisableSupport) {
gl->enable(GL::MULTISAMPLE);
gl->enable(GL_MULTISAMPLE);
}
}

static void DisableMultisample(const tgfx::GLInterface* gl, bool usesMSAA) {
if (usesMSAA && gl->caps->multisampleDisableSupport) {
gl->disable(GL::MULTISAMPLE);
gl->disable(GL_MULTISAMPLE);
}
}

Expand All @@ -226,19 +226,19 @@ void LayerFilter::draw(tgfx::Context* context, const FilterSource* source,
auto gl = tgfx::GLContext::Unwrap(context);
EnableMultisample(gl, needsMSAA());
gl->useProgram(filterProgram->program);
gl->enable(GL::BLEND);
gl->blendEquation(GL::FUNC_ADD);
gl->blendFunc(GL::ONE, GL::ONE_MINUS_SRC_ALPHA);
gl->bindFramebuffer(GL::FRAMEBUFFER, target->frameBufferID);
gl->enable(GL_BLEND);
gl->blendEquation(GL_FUNC_ADD);
gl->blendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
gl->bindFramebuffer(GL_FRAMEBUFFER, target->frameBufferID);
gl->viewport(0, 0, target->width, target->height);

ActiveGLTexture(gl, GL::TEXTURE0, GL::TEXTURE_2D, source->textureID);
gl->uniformMatrix3fv(vertexMatrixHandle, 1, GL::FALSE, target->vertexMatrix.data());
gl->uniformMatrix3fv(textureMatrixHandle, 1, GL::FALSE, source->textureMatrix.data());
ActiveGLTexture(gl, GL_TEXTURE0, GL_TEXTURE_2D, source->textureID);
gl->uniformMatrix3fv(vertexMatrixHandle, 1, GL_FALSE, target->vertexMatrix.data());
gl->uniformMatrix3fv(textureMatrixHandle, 1, GL_FALSE, source->textureMatrix.data());
onUpdateParams(gl, contentBounds, filterScale);
auto vertices = computeVertices(contentBounds, transformedBounds, filterScale);
bindVertices(gl, source, target, vertices);
gl->drawArrays(GL::TRIANGLE_STRIP, 0, 4);
gl->drawArrays(GL_TRIANGLE_STRIP, 0, 4);
if (filterProgram->vertexArray > 0) {
gl->bindVertexArray(0);
}
Expand Down Expand Up @@ -280,16 +280,16 @@ void LayerFilter::bindVertices(const tgfx::GLInterface* gl, const FilterSource*
if (filterProgram->vertexArray > 0) {
gl->bindVertexArray(filterProgram->vertexArray);
}
gl->bindBuffer(GL::ARRAY_BUFFER, filterProgram->vertexBuffer);
gl->bufferData(GL::ARRAY_BUFFER, vertices.size() * sizeof(float), &vertices[0], GL::STREAM_DRAW);
gl->vertexAttribPointer(static_cast<unsigned>(positionHandle), 2, GL::FLOAT, GL::FALSE,
gl->bindBuffer(GL_ARRAY_BUFFER, filterProgram->vertexBuffer);
gl->bufferData(GL_ARRAY_BUFFER, vertices.size() * sizeof(float), &vertices[0], GL_STREAM_DRAW);
gl->vertexAttribPointer(static_cast<unsigned>(positionHandle), 2, GL_FLOAT, GL_FALSE,
4 * sizeof(float), static_cast<void*>(0));
gl->enableVertexAttribArray(static_cast<unsigned>(positionHandle));

gl->vertexAttribPointer(textureCoordHandle, 2, GL::FLOAT, GL::FALSE, 4 * sizeof(float),
gl->vertexAttribPointer(textureCoordHandle, 2, GL_FLOAT, GL_FALSE, 4 * sizeof(float),
reinterpret_cast<void*>(2 * sizeof(float)));
gl->enableVertexAttribArray(textureCoordHandle);
gl->bindBuffer(GL::ARRAY_BUFFER, 0);
gl->bindBuffer(GL_ARRAY_BUFFER, 0);
}

bool LayerFilter::needsMSAA() const {
Expand Down
4 changes: 2 additions & 2 deletions src/rendering/filters/MotionBlurFilter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,8 @@ void MotionBlurFilter::onUpdateParams(const tgfx::GLInterface* gl, const tgfx::R
auto scaling = (previousMatrix.getScaleX() != currentMatrix.getScaleX() ||
previousMatrix.getScaleY() != currentMatrix.getScaleY());

gl->uniformMatrix3fv(prevTransformHandle, 1, GL::FALSE, previousGLMatrix.data());
gl->uniformMatrix3fv(transformHandle, 1, GL::FALSE, currentGLMatrix.data());
gl->uniformMatrix3fv(prevTransformHandle, 1, GL_FALSE, previousGLMatrix.data());
gl->uniformMatrix3fv(transformHandle, 1, GL_FALSE, currentGLMatrix.data());
gl->uniform1f(velCenterHandle, scaling ? 0.0f : 0.5f);
gl->uniform1f(maxDistanceHandle, (MOTION_BLUR_SCALE_FACTOR - 1.0) * 0.5f);
}
Expand Down
2 changes: 1 addition & 1 deletion src/rendering/filters/glow/GlowMergeFilter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,6 @@ void GlowMergeFilter::onUpdateParams(const tgfx::GLInterface* gl, const tgfx::Re
// TODO(domrjchen): 下面这行之前写成了 gl->uniform1i(progressHandle, 1), 会导致 glError,
// 暂时注释掉。目前的发光效果跟 AE 也没有对齐,后面重写发光效果时时再修复。
// gl->uniform1i(blurTextureHandle, 1);
ActiveGLTexture(gl, GL::TEXTURE1, GL::TEXTURE_2D, blurTextureID);
ActiveGLTexture(gl, GL_TEXTURE1, GL_TEXTURE_2D, blurTextureID);
}
} // namespace pag
1 change: 1 addition & 0 deletions sync_deps.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,4 @@ for TOOL in ${NODE_REQUIRED_TOOLS[@]}; do
done

depsync
git lfs prune > /dev/null
12 changes: 6 additions & 6 deletions test/GLUtilTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ std::vector<std::pair<std::string, GLVendor>> vendors = {
{"Imagination Technologies", GLVendor::Imagination},
};
const unsigned char* glGetStringMock(unsigned name) {
if (name == GL::VENDOR) {
if (name == GL_VENDOR) {
return reinterpret_cast<const unsigned char*>(vendors[i].first.c_str());
} else if (name == GL::VERSION) {
} else if (name == GL_VERSION) {
if (i != 0) {
return reinterpret_cast<const unsigned char*>("2.0");
} else {
Expand All @@ -49,20 +49,20 @@ const unsigned char* glGetStringMock(unsigned name) {
}

void getIntegervMock(unsigned pname, int* params) {
if (pname == GL::MAX_TEXTURE_SIZE) {
if (pname == GL_MAX_TEXTURE_SIZE) {
*params = 1024;
}
}

void glGetInternalformativMock(unsigned target, unsigned, unsigned pname, int, int* params) {
if (target != GL::RENDERBUFFER) {
if (target != GL_RENDERBUFFER) {
return;
}
if (pname == GL::NUM_SAMPLE_COUNTS) {
if (pname == GL_NUM_SAMPLE_COUNTS) {
*params = 2;
return;
}
if (pname == GL::SAMPLES) {
if (pname == GL_SAMPLES) {
params[0] = 4;
params[1] = 8;
}
Expand Down
3 changes: 2 additions & 1 deletion tgfx/src/core/vectors/web/WebMask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include "WebMask.h"
#include "WebTextBlob.h"
#include "WebTypeface.h"
#include "gpu/opengl/GLContext.h"
#include "gpu/opengl/GLTexture.h"

using namespace emscripten;
Expand All @@ -41,7 +42,7 @@ std::shared_ptr<Texture> WebMask::makeTexture(Context* context) const {
if (texture == nullptr) {
return nullptr;
}
auto& glInfo = std::static_pointer_cast<GLTexture>(texture)->getGLInfo();
auto& glInfo = std::static_pointer_cast<GLTexture>(texture)->glSampler();
const auto* gl = GLContext::Unwrap(context);
gl->bindTexture(glInfo.target, glInfo.id);
webMask.call<void>("update", val::module_property("GL"));
Expand Down
4 changes: 2 additions & 2 deletions tgfx/src/gpu/opengl/GLAssembledWebGLInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@

namespace tgfx {
static unsigned GetErrorFake() {
return GL::NO_ERROR;
return GL_NO_ERROR;
}

static unsigned CheckFramebufferStatusFake(unsigned) {
return GL::FRAMEBUFFER_COMPLETE;
return GL_FRAMEBUFFER_COMPLETE;
}

static void InitVertexArray(const GLProcGetter* getter, GLInterface* interface,
Expand Down
50 changes: 25 additions & 25 deletions tgfx/src/gpu/opengl/GLBlend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -345,21 +345,21 @@ static void HandleBlendModes(FragmentShaderBuilder* fsBuilder, const std::string
}

static constexpr std::pair<BlendMode, std::pair<unsigned, unsigned>> kBlendCoeffMap[] = {
{BlendMode::Clear, {GL::ZERO, GL::ZERO}},
{BlendMode::Src, {GL::ONE, GL::ZERO}},
{BlendMode::Dst, {GL::ZERO, GL::ONE}},
{BlendMode::SrcOver, {GL::ONE, GL::ONE_MINUS_SRC_ALPHA}},
{BlendMode::DstOver, {GL::ONE_MINUS_DST_ALPHA, GL::ONE}},
{BlendMode::SrcIn, {GL::DST_ALPHA, GL::ZERO}},
{BlendMode::DstIn, {GL::ZERO, GL::SRC_ALPHA}},
{BlendMode::SrcOut, {GL::ONE_MINUS_DST_ALPHA, GL::ZERO}},
{BlendMode::DstOut, {GL::ZERO, GL::ONE_MINUS_SRC_ALPHA}},
{BlendMode::SrcATop, {GL::DST_ALPHA, GL::ONE_MINUS_SRC_ALPHA}},
{BlendMode::DstATop, {GL::ONE_MINUS_DST_ALPHA, GL::SRC_ALPHA}},
{BlendMode::Xor, {GL::ONE_MINUS_DST_ALPHA, GL::ONE_MINUS_SRC_ALPHA}},
{BlendMode::Plus, {GL::ONE, GL::ONE}},
{BlendMode::Modulate, {GL::ZERO, GL::SRC_COLOR}},
{BlendMode::Screen, {GL::ONE, GL::ONE_MINUS_SRC_COLOR}}};
{BlendMode::Clear, {GL_ZERO, GL_ZERO}},
{BlendMode::Src, {GL_ONE, GL_ZERO}},
{BlendMode::Dst, {GL_ZERO, GL_ONE}},
{BlendMode::SrcOver, {GL_ONE, GL_ONE_MINUS_SRC_ALPHA}},
{BlendMode::DstOver, {GL_ONE_MINUS_DST_ALPHA, GL_ONE}},
{BlendMode::SrcIn, {GL_DST_ALPHA, GL_ZERO}},
{BlendMode::DstIn, {GL_ZERO, GL_SRC_ALPHA}},
{BlendMode::SrcOut, {GL_ONE_MINUS_DST_ALPHA, GL_ZERO}},
{BlendMode::DstOut, {GL_ZERO, GL_ONE_MINUS_SRC_ALPHA}},
{BlendMode::SrcATop, {GL_DST_ALPHA, GL_ONE_MINUS_SRC_ALPHA}},
{BlendMode::DstATop, {GL_ONE_MINUS_DST_ALPHA, GL_SRC_ALPHA}},
{BlendMode::Xor, {GL_ONE_MINUS_DST_ALPHA, GL_ONE_MINUS_SRC_ALPHA}},
{BlendMode::Plus, {GL_ONE, GL_ONE}},
{BlendMode::Modulate, {GL_ZERO, GL_SRC_COLOR}},
{BlendMode::Screen, {GL_ONE, GL_ONE_MINUS_SRC_COLOR}}};

bool BlendAsCoeff(BlendMode blendMode, unsigned* first, unsigned* second) {
for (const auto& pair : kBlendCoeffMap) {
Expand Down Expand Up @@ -423,20 +423,20 @@ using CoeffHandler = void (*)(FragmentShaderBuilder* fsBuilder, const char* srcC
const char* dstColorName);

static constexpr std::pair<unsigned, CoeffHandler> kCoeffHandleMap[] = {
{GL::ONE, CoeffHandler_ONE},
{GL::SRC_COLOR, CoeffHandler_SRC_COLOR},
{GL::ONE_MINUS_SRC_COLOR, CoeffHandler_ONE_MINUS_SRC_COLOR},
{GL::DST_COLOR, CoeffHandler_DST_COLOR},
{GL::ONE_MINUS_DST_COLOR, CoeffHandler_ONE_MINUS_DST_COLOR},
{GL::SRC_ALPHA, CoeffHandler_SRC_ALPHA},
{GL::ONE_MINUS_SRC_ALPHA, CoeffHandler_ONE_MINUS_SRC_ALPHA},
{GL::DST_ALPHA, CoeffHandler_DST_ALPHA},
{GL::ONE_MINUS_DST_ALPHA, CoeffHandler_ONE_MINUS_DST_ALPHA}};
{GL_ONE, CoeffHandler_ONE},
{GL_SRC_COLOR, CoeffHandler_SRC_COLOR},
{GL_ONE_MINUS_SRC_COLOR, CoeffHandler_ONE_MINUS_SRC_COLOR},
{GL_DST_COLOR, CoeffHandler_DST_COLOR},
{GL_ONE_MINUS_DST_COLOR, CoeffHandler_ONE_MINUS_DST_COLOR},
{GL_SRC_ALPHA, CoeffHandler_SRC_ALPHA},
{GL_ONE_MINUS_SRC_ALPHA, CoeffHandler_ONE_MINUS_SRC_ALPHA},
{GL_DST_ALPHA, CoeffHandler_DST_ALPHA},
{GL_ONE_MINUS_DST_ALPHA, CoeffHandler_ONE_MINUS_DST_ALPHA}};

static bool AppendPorterDuffTerm(FragmentShaderBuilder* fsBuilder, unsigned coeff,
const std::string& colorName, const std::string& srcColorName,
const std::string& dstColorName, bool hasPrevious) {
if (GL::ZERO == coeff) {
if (GL_ZERO == coeff) {
return hasPrevious;
} else {
if (hasPrevious) {
Expand Down
8 changes: 4 additions & 4 deletions tgfx/src/gpu/opengl/GLBuffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,10 @@ std::shared_ptr<GLBuffer> GLBuffer::Make(Context* context, const uint16_t* buffe
glBuffer = Resource::Wrap(context, new GLBuffer(buffer, length));
gl->genBuffers(1, &glBuffer->_bufferID);
if (buffer) {
gl->bindBuffer(GL::ELEMENT_ARRAY_BUFFER, glBuffer->_bufferID);
gl->bufferData(GL::ELEMENT_ARRAY_BUFFER, static_cast<GLsizeiptr>(sizeof(uint16_t) * length),
buffer, GL::STATIC_DRAW);
gl->bindBuffer(GL::ELEMENT_ARRAY_BUFFER, 0);
gl->bindBuffer(GL_ELEMENT_ARRAY_BUFFER, glBuffer->_bufferID);
gl->bufferData(GL_ELEMENT_ARRAY_BUFFER, static_cast<GLsizeiptr>(sizeof(uint16_t) * length),
buffer, GL_STATIC_DRAW);
gl->bindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
}
return glBuffer;
}
Expand Down
Loading

0 comments on commit f7093c3

Please sign in to comment.