<commit_before>#include "gum/DTex.h"
#include "gum/RenderContext.h"
#include "gum/DTexC2Strategy.h"
#include "gum/ThreadPool.h"
#include "gum/SymbolPool.h"
#include "gum/ImagePool.h"
#include "gum/ImageSymbol.h"
#include "gum/ProxyImage.h"
#include "gum/Blackboard.h"

#include <logger.h>
#include <fs_file.h>
#include <bimp/ImportStream.h>
#include <timp/Package.h>
#include <timp/PkgMgr.h>
#include <timp/TextureLoader.h>
#include <simp/RelocateTexcoords.h>
#include <simp/PageVisitor.h>
#include <simp/RelocateTexcoords.h>
#include <simp/NodeFactory.h>
#include <simp/NodePicture.h>
#include <dtex2/RenderAPI.h>
#include <dtex2/ResourceAPI.h>
#include <dtex2/Package.h>
#include <dtex2/PkgMgr.h>
#include <dtex2/TextureRaw.h>
#include <dtex2/Cache.h>
#include <dtex2/CacheMgr.h>
#include <dtex2/CacheAPI.h>
#include <dtex2/CacheSymbol.h>
#include <dtex2/CS_Node.h>
#include <shaderlab/ShaderMgr.h>
#include <shaderlab/ShapeShader.h>
#include <shaderlab/Sprite2Shader.h>
#include <shaderlab/FilterShader.h>
#include <shaderlab/Blackboard.h>
#include <shaderlab/RenderContext.h>
#include <stat/StatImages.h>
#include <painting2/WindowContext.h>
#include <painting2/RenderScissor.h>
#include <painting2/PrimitiveDraw.h>
#include <painting2/Blackboard.h>
#include <painting2/RenderContext.h>
#include <sprite2/DrawNode.h>
#include <sprite2/Symbol.h>
#include <unirender/RenderContext.h>
#include <unirender/Blackboard.h>
#include <s2loader/ImageLoader.h>

#include <stack>
#include <memory>

#include <assert.h>

namespace dtex { class Package; }

namespace gum
{

CU_SINGLETON_DEFINITION(DTex);

static const int IMG_ID = -3;

static void (*DRAW_BEGIN)() = nullptr;
static void (*DRAW_END)() = nullptr;
static void (*ERROR_RELOAD)() = nullptr;

/************************************************************************/
/* draw                                                                 */
/************************************************************************/

static void 
clear_color_part(float xmin, float ymin, float xmax, float ymax)
{
	auto& ur_rc = ur::Blackboard::Instance()->GetRenderContext();
	ur_rc.EnableBlend(false);
//	glBlendFunc(GL_ONE, GL_ZERO);

	auto& shader_mgr = sl::Blackboard::Instance()->GetRenderContext().GetShaderMgr();
	shader_mgr.SetShader(sl::SHAPE2);
	sl::ShapeShader* shader = static_cast<sl::ShapeShader*>(shader_mgr.GetShader());
	
	shader->SetColor(0);
//	shader->SetColor(0xff0000ff);

	auto& wc = pt2::Blackboard::Instance()->GetWindowContext();
	int w = wc->GetScreenWidth(),
		h = wc->GetScreenHeight();
	xmin = w * 0.5f * (xmin - 1);
	xmax = w * 0.5f * (xmax - 1);
	ymin = h * 0.5f * (ymin + 1);
	ymax = h * 0.5f * (ymax + 1);

	CU_VEC<sm::vec2> triangles;
	triangles.resize(4);
	triangles[0].Set(xmin, ymin);
	triangles[1].Set(xmin, ymax);
	triangles[2].Set(xmax, ymin);
	triangles[3].Set(xmax, ymax);

	pt2::PrimitiveDraw::TriangleStrip(nullptr, triangles);

	shader->Commit();
// 	ShaderLab::Instance()->Flush();

//	glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
	ur_rc.EnableBlend(true);

	//////////////////////////////////////////////////////////////////////////

//	dtex_gl_clear_color(0, 0, 0, 0);
}

static void 
set_program()
{
	// todo
	sl::Blackboard::Instance()->GetRenderContext().GetShaderMgr().SetShader(sl::SPRITE2);
}

static void 
set_blend(int mode)
{
	// todo
	assert(0);

	assert(mode == 0);
//	ShaderMgr::Instance()->SetBlendMode(0);
}

static std::stack<std::shared_ptr<pt2::WindowContext>> wc_stack;

static void 
draw_begin()
{
	if (DRAW_BEGIN) 
	{
		DRAW_BEGIN();
	} 
	else 
	{
		wc_stack.push(pt2::Blackboard::Instance()->GetWindowContext());
		auto new_wc = std::make_shared<pt2::WindowContext>(2, 2, 0, 0);
		new_wc->Bind();
		wc_stack.push(new_wc);
	}

	auto& shader_mgr = sl::Blackboard::Instance()->GetRenderContext().GetShaderMgr();
	shader_mgr.SetShader(sl::SPRITE2);
	sl::Sprite2Shader* sl_shader = static_cast<sl::Sprite2Shader*>(shader_mgr.GetShader());
	sl_shader->SetColor(0xffffffff, 0);
	sl_shader->SetColorMap(0x000000ff, 0x0000ff00, 0x00ff0000);
}

static void 
draw(const float _vertices[8], const float _texcoords[8], int texid)
{
	sm::vec2 vertices[4], texcoords[4];
	for (int i = 0; i < 4; ++i) 
	{
		vertices[i].x  = _vertices[i * 2];
		vertices[i].y  = _vertices[i * 2 + 1];
		texcoords[i].x = _texcoords[i * 2];
		texcoords[i].y = _texcoords[i * 2 + 1];
	}

	auto& shader_mgr = sl::Blackboard::Instance()->GetRenderContext().GetShaderMgr();<commit_msg>fix compile warning<commit_after>#include "gum/DTex.h"
#include "gum/RenderContext.h"
#include "gum/DTexC2Strategy.h"
#include "gum/ThreadPool.h"
#include "gum/SymbolPool.h"
#include "gum/ImagePool.h"
#include "gum/ImageSymbol.h"
#include "gum/ProxyImage.h"
#include "gum/Blackboard.h"

#include <logger.h>
#include <fs_file.h>
#include <bimp/ImportStream.h>
#include <timp/Package.h>
#include <timp/PkgMgr.h>
#include <timp/TextureLoader.h>
#include <simp/RelocateTexcoords.h>
#include <simp/PageVisitor.h>
#include <simp/RelocateTexcoords.h>
#include <simp/NodeFactory.h>
#include <simp/NodePicture.h>
#include <dtex2/RenderAPI.h>
#include <dtex2/ResourceAPI.h>
#include <dtex2/Package.h>
#include <dtex2/PkgMgr.h>
#include <dtex2/TextureRaw.h>
#include <dtex2/Cache.h>
#include <dtex2/CacheMgr.h>
#include <dtex2/CacheAPI.h>
#include <dtex2/CacheSymbol.h>
#include <dtex2/CS_Node.h>
#include <shaderlab/ShaderMgr.h>
#include <shaderlab/ShapeShader.h>
#include <shaderlab/Sprite2Shader.h>
#include <shaderlab/FilterShader.h>
#include <shaderlab/Blackboard.h>
#include <shaderlab/RenderContext.h>
#include <stat/StatImages.h>
#include <painting2/WindowContext.h>
#include <painting2/RenderScissor.h>
#include <painting2/PrimitiveDraw.h>
#include <painting2/Blackboard.h>
#include <painting2/RenderContext.h>
#include <sprite2/DrawNode.h>
#include <sprite2/Symbol.h>
#include <unirender/RenderContext.h>
#include <unirender/Blackboard.h>
#include <s2loader/ImageLoader.h>

#include <stack>
#include <memory>

#include <assert.h>

namespace dtex { class Package; }

namespace gum
{

CU_SINGLETON_DEFINITION(DTex);

static const int IMG_ID = -3;

static void (*DRAW_BEGIN)() = nullptr;
static void (*DRAW_END)() = nullptr;
static void (*ERROR_RELOAD)() = nullptr;

/************************************************************************/
/* draw                                                                 */
/************************************************************************/

static void 
clear_color_part(float xmin, float ymin, float xmax, float ymax)
{
	auto& ur_rc = ur::Blackboard::Instance()->GetRenderContext();
	ur_rc.EnableBlend(false);
//	glBlendFunc(GL_ONE, GL_ZERO);

	auto& shader_mgr = sl::Blackboard::Instance()->GetRenderContext().GetShaderMgr();
	shader_mgr.SetShader(sl::SHAPE2);
	sl::ShapeShader* shader = static_cast<sl::ShapeShader*>(shader_mgr.GetShader());
	
	shader->SetColor(0);
//	shader->SetColor(0xff0000ff);

	auto& wc = pt2::Blackboard::Instance()->GetWindowContext();
	int w = wc->GetScreenWidth(),
		h = wc->GetScreenHeight();
	xmin = w * 0.5f * (xmin - 1);
	xmax = w * 0.5f * (xmax - 1);
	ymin = h * 0.5f * (ymin + 1);
	ymax = h * 0.5f * (ymax + 1);

	CU_VEC<sm::vec2> triangles;
	triangles.resize(4);
	triangles[0].Set(xmin, ymin);
	triangles[1].Set(xmin, ymax);
	triangles[2].Set(xmax, ymin);
	triangles[3].Set(xmax, ymax);

	pt2::PrimitiveDraw::TriangleStrip(nullptr, triangles);

	shader->Commit();
// 	ShaderLab::Instance()->Flush();

//	glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
	ur_rc.EnableBlend(true);

	//////////////////////////////////////////////////////////////////////////

//	dtex_gl_clear_color(0, 0, 0, 0);
}

static void 
set_program()
{
	// todo
	sl::Blackboard::Instance()->GetRenderContext().GetShaderMgr().SetShader(sl::SPRITE2);
}

static void 
set_blend(int mode)
{
	// todo
	assert(0);

	assert(mode == 0);
//	ShaderMgr::Instance()->SetBlendMode(0);
}

static std::stack<std::shared_ptr<pt2::WindowContext>> wc_stack;

static void 
draw_begin()
{
	if (DRAW_BEGIN) 
	{
		DRAW_BEGIN();
	} 
	else 
	{
		wc_stack.push(pt2::Blackboard::Instance()->GetWindowContext());
		auto new_wc = std::make_shared<pt2::WindowContext>(2.0f, 2.0f, 0, 0);
		new_wc->Bind();
		wc_stack.push(new_wc);
	}

	auto& shader_mgr = sl::Blackboard::Instance()->GetRenderContext().GetShaderMgr();
	shader_mgr.SetShader(sl::SPRITE2);
	sl::Sprite2Shader* sl_shader = static_cast<sl::Sprite2Shader*>(shader_mgr.GetShader());
	sl_shader->SetColor(0xffffffff, 0);
	sl_shader->SetColorMap(0x000000ff, 0x0000ff00, 0x00ff0000);
}

static void 
draw(const float _vertices[8], const float _texcoords[8], int texid)
{
	sm::vec2 vertices[4], texcoords[4];
	for (int i = 0; i < 4; ++i) 
	{
		vertices[i].x  = _vertices[i * 2];
		vertices[i].y  = _vertices[i * 2 + 1];
		texcoords[i].x = _texcoords[i * 2];
		texcoords[i].y = _texcoords[i * 2 + 1];
	}

	auto& shader_mgr = sl::Blackboard::Instance()->GetRenderContext().GetShaderMgr();
{'fraction_non_alphanumeric': 0.21439784705090828, 'fraction_numerical': 0.023099349629961876, 'mean_word_length': 4.871626069782752, 'pattern_counts': {'":': 0, '<': 99, '<?xml version=': 0, '>': 131, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 2, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3342657', 'n_tokens_mistral': 3561, 'n_tokens_neox': 3448, 'n_words': 565}