From b8d02a8ee9545dc69b2eb0844b09bd23d04cc7ed Mon Sep 17 00:00:00 2001 From: Hparty <420024556@qq.com> Date: Tue, 29 Oct 2024 19:22:34 +0800 Subject: [PATCH] Fix the compilation errors in the demo and resolve the issue of the plusdarker program failing to compile in WebGL. --- include/tgfx/layers/ImageLayer.h | 1 - include/tgfx/layers/Layer.h | 1 - src/gpu/opengl/GLBlend.cpp | 4 ++-- src/layers/ImageLayer.cpp | 1 + 4 files changed, 3 insertions(+), 4 deletions(-) diff --git a/include/tgfx/layers/ImageLayer.h b/include/tgfx/layers/ImageLayer.h index ac60e105..369692dc 100644 --- a/include/tgfx/layers/ImageLayer.h +++ b/include/tgfx/layers/ImageLayer.h @@ -18,7 +18,6 @@ #pragma once -#include "layers/contents/ImageContent.h" #include "tgfx/core/Image.h" #include "tgfx/layers/Layer.h" diff --git a/include/tgfx/layers/Layer.h b/include/tgfx/layers/Layer.h index 788e9251..9ee88f55 100644 --- a/include/tgfx/layers/Layer.h +++ b/include/tgfx/layers/Layer.h @@ -19,7 +19,6 @@ #pragma once #include -#include "core/utils/UniqueID.h" #include "tgfx/core/BlendMode.h" #include "tgfx/core/Canvas.h" #include "tgfx/core/ImageFilter.h" diff --git a/src/gpu/opengl/GLBlend.cpp b/src/gpu/opengl/GLBlend.cpp index 2e80fe31..53385c14 100644 --- a/src/gpu/opengl/GLBlend.cpp +++ b/src/gpu/opengl/GLBlend.cpp @@ -315,9 +315,9 @@ static void BlendHandler_PlusDarker(FragmentShaderBuilder* fsBuilder, const char const char* dstColor, const char* outputColor) { // MAX(0, (1 - ((Da * (1 - Dc) + Sa * (1 - Sc))) // https://developer.apple.com/documentation/coregraphics/cgblendmode/kcgblendmodeplusdarker - fsBuilder->codeAppendf("%s.rgb = clamp(1.0 + %s.rgb + %s.rgb - %s.a - %s.a, 0, 1);", outputColor, + fsBuilder->codeAppendf("%s.rgb = clamp(1.0 + %s.rgb + %s.rgb - %s.a - %s.a, 0.0, 1.0);", outputColor, srcColor, dstColor, dstColor, srcColor); - fsBuilder->codeAppendf("%s.rgb *= (%s.a != 0.0) ? 1.0 : 0.0;", outputColor, outputColor); + fsBuilder->codeAppendf("%s.rgb *= (%s.a > 0.0) ? 1.0 : 0.0;", outputColor, outputColor); } using BlendHandler = void (*)(FragmentShaderBuilder* fsBuilder, const char* srcColor, diff --git a/src/layers/ImageLayer.cpp b/src/layers/ImageLayer.cpp index 0ce3f3af..2c219342 100644 --- a/src/layers/ImageLayer.cpp +++ b/src/layers/ImageLayer.cpp @@ -16,6 +16,7 @@ // ///////////////////////////////////////////////////////////////////////////////////////////////// +#include "layers/contents/ImageContent.h" #include "tgfx/layers/ImageLayer.h" namespace tgfx {