Skip to content

Commit

Permalink
Hide the Resource class from tgfx's public APIs and use the GLResourc…
Browse files Browse the repository at this point in the history
…e instead.
  • Loading branch information
domchen committed Jan 6, 2024
1 parent 26c90cc commit e2013f1
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 12 deletions.
2 changes: 1 addition & 1 deletion DEPS
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
},
{
"url": "${PAG_GROUP}/tgfx.git",
"commit": "0492dac0b9af4b179617bce8cb87eaf360c5f9d5",
"commit": "17bed1f51dcf94445248f4e2830fe6260028bb21",
"dir": "third_party/tgfx"
},
{
Expand Down
7 changes: 4 additions & 3 deletions src/rendering/filters/LayerFilter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,17 +90,18 @@ std::shared_ptr<const FilterProgram> FilterProgram::Make(tgfx::Context* context,
if (program == 0) {
return nullptr;
}
auto filterProgram = new FilterProgram();
auto filterProgram = std::shared_ptr<FilterProgram>(new FilterProgram());
filterProgram->program = program;
if (gl->bindVertexArray != nullptr) {
gl->genVertexArrays(1, &filterProgram->vertexArray);
}
gl->genBuffers(1, &filterProgram->vertexBuffer);
return Resource::Wrap(context, filterProgram);
tgfx::GLResource::AttachToContext(context, filterProgram);
return filterProgram;
}

void FilterProgram::onReleaseGPU() {
auto gl = tgfx::GLFunctions::Get(context);
auto gl = tgfx::GLFunctions::Get(getContext());
if (program > 0) {
gl->deleteProgram(program);
program = 0;
Expand Down
13 changes: 5 additions & 8 deletions src/rendering/filters/LayerFilter.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,30 +22,27 @@
#include "pag/file.h"
#include "pag/pag.h"
#include "rendering/filters/utils/FilterHelper.h"
#include "tgfx/gpu/Resource.h"
#include "tgfx/opengl/GLResource.h"

namespace pag {
std::vector<tgfx::Point> ComputeVerticesForMotionBlurAndBulge(const tgfx::Rect& inputBounds,
const tgfx::Rect& outputBounds);

class FilterProgram : public tgfx::Resource {
class FilterProgram : public tgfx::GLResource {
public:
static std::shared_ptr<const FilterProgram> Make(tgfx::Context* context,
const std::string& vertex,
const std::string& fragment);

size_t memoryUsage() const override {
return 0;
}

unsigned program = 0;
unsigned int vertexArray = 0;
unsigned int vertexBuffer = 0;

protected:
void onReleaseGPU() override;

private:
FilterProgram() = default;

void onReleaseGPU() override;
};

class LayerFilter : public Filter {
Expand Down

0 comments on commit e2013f1

Please sign in to comment.