Skip to content

Commit

Permalink
Fix issues while create program with the same samplerTexture
Browse files Browse the repository at this point in the history
  • Loading branch information
Hparty committed Jan 8, 2025
1 parent b9a42bf commit 588c633
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 18 deletions.
9 changes: 7 additions & 2 deletions src/core/ImageFilter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include "gpu/OpContext.h"
#include "gpu/TPArgs.h"
#include "gpu/processors/FragmentProcessor.h"
#include "gpu/processors/TextureEffect.h"
#include "gpu/processors/TiledTextureEffect.h"
#include "gpu/proxies/RenderTargetProxy.h"

Expand Down Expand Up @@ -92,7 +93,11 @@ std::unique_ptr<FragmentProcessor> ImageFilter::makeFPFromTextureProxy(
if (uvMatrix != nullptr) {
fpMatrix.preConcat(*uvMatrix);
}
return TiledTextureEffect::Make(std::move(textureProxy), TileMode::Decal, TileMode::Decal,
sampling, &fpMatrix, isAlphaOnly);
if (dstBounds.contains(clipBounds)) {
return TextureEffect::Make(std::move(textureProxy), sampling, &fpMatrix, isAlphaOnly);
} else {
return TiledTextureEffect::Make(std::move(textureProxy), TileMode::Decal, TileMode::Decal,
sampling, &fpMatrix, isAlphaOnly);
}
}
} // namespace tgfx
10 changes: 3 additions & 7 deletions src/gpu/UniformHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,8 @@
namespace tgfx {
SamplerHandle UniformHandler::addSampler(const tgfx::TextureSampler* sampler,
const std::string& name) {
auto result = samplerMap.find(sampler);
if (result != samplerMap.end()) {
return result->second;
}
auto handle = internalAddSampler(sampler, name);
samplerMap[sampler] = handle;
return handle;
// The same sampler can be added multiple times with different names because the same handler of
// the program can be used with different samplers.
return internalAddSampler(sampler, name);
}
} // namespace tgfx
2 changes: 0 additions & 2 deletions src/gpu/UniformHandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,6 @@ class UniformHandler {
ProgramBuilder* programBuilder;

private:
std::unordered_map<const TextureSampler*, SamplerHandle> samplerMap = {};

virtual const ShaderVar& samplerVariable(SamplerHandle samplerHandle) const = 0;

virtual const Swizzle& samplerSwizzle(SamplerHandle samplerHandle) const = 0;
Expand Down
14 changes: 7 additions & 7 deletions test/baseline/version.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
"rasterized": "5a971dd",
"rasterized_mipmap": "5a971dd",
"rasterized_scale_up": "5a971dd",
"saveLayer": "013cbe7",
"saveLayer": "b9a42bf",
"shape": "bc64712",
"text_shape": "b062b9a",
"tile_mode_normal": "8cb853c",
Expand All @@ -64,21 +64,21 @@
"GridBackground": "2ae64df",
"ImageWithMipmap": "5a1fb11",
"ImageWithShadow": "72edd24",
"SimpleLayerTreeDrawer": "013cbe7",
"SimpleLayerTreeDrawer": "4513df8",
"SimpleText": "b062b9a"
},
"FilterTest": {
"AlphaThreshold": "5012d73",
"AlphaThreshold_empty": "5012d73",
"ComposeColorFilter": "f710e29",
"ComposeImageFilter": "2028a1b",
"ComposeImageFilter2": "013cbe7",
"EmptyShadowTest": "013cbe7",
"ComposeImageFilter2": "2028a1b",
"EmptyShadowTest": "b9a42bf",
"ImageFilterShader": "2028a1b",
"InnerShadowBadCase": "013cbe7",
"InnerShadowBadCase": "b9a42bf",
"ModeColorFilter": "c2b0b18",
"RuntimeEffect": "013cbe7",
"blur": "013cbe7",
"RuntimeEffect": "d93c573",
"blur": "4d6ab20",
"dropShadow": "a30de8b",
"greyColorMatrix": "a30de8b",
"identityMatrix": "a30de8b",
Expand Down

0 comments on commit 588c633

Please sign in to comment.