Removed old drawing program cache
This commit is contained in:
parent
19f8c99b66
commit
9845d14a83
7 changed files with 8 additions and 68 deletions
|
|
@ -36,10 +36,6 @@ DrawingProgram::DrawingProgram(World& initWorld):
|
|||
{
|
||||
drawTool = DrawingProgramToolBase::allocate_tool_type(*this, DrawingProgramToolType::BRUSH);
|
||||
|
||||
components.updateCallback = [&]() {
|
||||
if(&world == world.main.world.get())
|
||||
world.main.drawProgCache.refresh = true;
|
||||
};
|
||||
components.clientInsertCallback = [&](const CollabListType::ObjectInfoPtr& c) {
|
||||
if(addToCompCacheOnInsert)
|
||||
compCache.add_component(c);
|
||||
|
|
@ -579,26 +575,15 @@ void DrawingProgram::draw(SkCanvas* canvas, const DrawData& drawData) {
|
|||
}
|
||||
}
|
||||
else {
|
||||
if(world.main.drawProgCache.disableDrawCache) {
|
||||
parallel_loop_all_components([&](auto& c) {
|
||||
c->obj->calculate_draw_transform(drawData);
|
||||
});
|
||||
for(auto& c : components.client_list()) {
|
||||
c->obj->draw(canvas, drawData);
|
||||
c->obj->drawSetupData.shouldDraw = false;
|
||||
}
|
||||
}
|
||||
else {
|
||||
SkCanvas* drawProgCacheCanvas = world.main.drawProgCache.surface->getCanvas();
|
||||
drawProgCacheCanvas->clear(SkColor4f{0.0f, 0.0f, 0.0f, 0.0f});
|
||||
canvas->saveLayer(nullptr, nullptr);
|
||||
canvas->clear(SkColor4f{0.0f, 0.0f, 0.0f, 0.0f});
|
||||
compCache.refresh_all_draw_cache(drawData);
|
||||
compCache.draw_components_to_canvas(drawProgCacheCanvas, drawData);
|
||||
drawProgCacheCanvas->saveLayerAlphaf(nullptr, 1.0f);
|
||||
selection.draw_components(drawProgCacheCanvas, drawData);
|
||||
drawProgCacheCanvas->restore();
|
||||
canvas->drawImage(world.main.drawProgCache.surface->makeTemporaryImage(), 0, 0);
|
||||
selection.draw_gui(canvas, drawData);
|
||||
}
|
||||
compCache.draw_components_to_canvas(canvas, drawData);
|
||||
canvas->saveLayer(nullptr, nullptr);
|
||||
selection.draw_components(canvas, drawData);
|
||||
canvas->restore();
|
||||
canvas->restore();
|
||||
selection.draw_gui(canvas, drawData);
|
||||
}
|
||||
|
||||
drawTool->draw(canvas, drawData);
|
||||
|
|
|
|||
|
|
@ -334,7 +334,6 @@ void DrawingProgramCache::refresh_draw_cache(const std::shared_ptr<DrawingProgra
|
|||
if(drawCache.invalidBounds) {
|
||||
auto& iBounds = drawCache.invalidBounds.value();
|
||||
WorldVec bDim = bvhNode->bounds.dim();
|
||||
//std::cout << "\niMin: " << iBounds.min.x() << " " << iBounds.min.y() << "\niMax: " << iBounds.max.x() << " " << iBounds.max.y() << "\nbMin: " << bvhNode->bounds.min.x() << " " << bvhNode->bounds.min.y() << "\nbMax: " << bvhNode->bounds.max.x() << " " << bvhNode->bounds.max.y() << "\nbDim: " << bDim.x() << " " << bDim.y();
|
||||
|
||||
Vector2f clipBoundMin{static_cast<float>((iBounds.min.x() - bvhNode->bounds.min.x()) / bDim.x()) * bvhNode->resolution.x(),
|
||||
static_cast<float>((iBounds.min.y() - bvhNode->bounds.min.y()) / bDim.y()) * bvhNode->resolution.y()};
|
||||
|
|
@ -352,7 +351,6 @@ void DrawingProgramCache::refresh_draw_cache(const std::shared_ptr<DrawingProgra
|
|||
bvhNode->coords.from_space(clipRectBoundAABB.max)
|
||||
};
|
||||
|
||||
//std::cout << "\ncMin: " << clipBoundMin.x() << " " << clipBoundMin.y() << "\ncMax: " << clipBoundMax.x() << " " << clipBoundMax.y() << std::endl;
|
||||
cacheCanvas->save();
|
||||
cacheCanvas->clipIRect(clipRect);
|
||||
cacheCanvas->clear(SkColor4f{0, 0, 0, 0});
|
||||
|
|
|
|||
|
|
@ -63,28 +63,6 @@ MainProgram::MainProgram():
|
|||
});
|
||||
}
|
||||
|
||||
void MainProgram::init_draw_program_cache() {
|
||||
if(window.size.x() < 0 || window.size.y() < 0)
|
||||
return;
|
||||
SkImageInfo imgInfo = SkImageInfo::MakeN32Premul(window.size.x(), window.size.y());
|
||||
#ifdef USE_SKIA_BACKEND_GRAPHITE
|
||||
drawProgCache.surface = SkSurfaces::RenderTarget(window.recorder(), imgInfo, skgpu::Mipmapped::kNo, window.defaultMSAASurfaceProps);
|
||||
#elif USE_SKIA_BACKEND_GANESH
|
||||
drawProgCache.surface = SkSurfaces::RenderTarget(window.ctx.get(), skgpu::Budgeted::kNo, imgInfo, window.defaultMSAASampleCount, &window.defaultMSAASurfaceProps);
|
||||
#endif
|
||||
if(!drawProgCache.surface)
|
||||
throw std::runtime_error("[MainProgram::init_draw_program_cache] Could not make surface");
|
||||
drawProgCache.canvas = drawProgCache.surface->getCanvas();
|
||||
|
||||
if(!drawProgCache.canvas)
|
||||
throw std::runtime_error("[MainProgram::init_draw_program_cache] Could not create canvas");
|
||||
|
||||
drawProgCache.canvas->clear(SkColor4f{0, 0, 0, 0});
|
||||
|
||||
drawProgCache.refresh = true;
|
||||
}
|
||||
|
||||
|
||||
void MainProgram::update() {
|
||||
while(std::chrono::duration_cast<std::chrono::duration<float>>(std::chrono::steady_clock::now() - lastFrameTime).count() < 1.0 / fpsLimit);
|
||||
lastFrameTime = std::chrono::steady_clock::now();
|
||||
|
|
@ -117,8 +95,6 @@ void MainProgram::update() {
|
|||
|
||||
std::shared_ptr<World> oldWorld = world;
|
||||
world = worlds[worldIndex];
|
||||
if(oldWorld != world)
|
||||
drawProgCache.refresh = true;
|
||||
|
||||
deltaTime.update_time_since();
|
||||
deltaTime.update_time_point();
|
||||
|
|
|
|||
|
|
@ -30,14 +30,6 @@ class MainProgram {
|
|||
|
||||
Vector3f userColor;
|
||||
|
||||
struct DrawingProgramImageCache {
|
||||
bool refresh = true;
|
||||
sk_sp<SkSurface> surface;
|
||||
std::shared_ptr<DrawComponent> firstCompUpdate = nullptr;
|
||||
SkCanvas* canvas;
|
||||
bool disableDrawCache = false;
|
||||
} drawProgCache;
|
||||
|
||||
struct Window {
|
||||
Vector2i size = {-1, -1};
|
||||
Vector2i pos = {-1, -1};
|
||||
|
|
@ -86,8 +78,6 @@ class MainProgram {
|
|||
void update();
|
||||
void draw(SkCanvas* canvas);
|
||||
|
||||
void init_draw_program_cache();
|
||||
|
||||
bool setToQuit = false;
|
||||
|
||||
void early_destroy();
|
||||
|
|
|
|||
|
|
@ -221,7 +221,6 @@ nlohmann::json Toolbar::get_config_json() {
|
|||
toRet["themeInUse"] = themeData.themeCurrentlyLoaded;
|
||||
toRet["velocityAffectsBrushWidth"] = velocityAffectsBrushWidth;
|
||||
toRet["jumpTransitionEasing"] = jumpTransitionEasing;
|
||||
toRet["disableDrawCache"] = main.drawProgCache.disableDrawCache;
|
||||
toRet["defaultCanvasBackgroundColor"] = main.defaultCanvasBackgroundColor;
|
||||
|
||||
json tablet;
|
||||
|
|
@ -273,7 +272,6 @@ void Toolbar::set_config_json(const nlohmann::json& j) {
|
|||
j.at("themeInUse").get_to(themeData.themeCurrentlyLoaded);
|
||||
j.at("velocityAffectsBrushWidth").get_to(velocityAffectsBrushWidth);
|
||||
j.at("jumpTransitionEasing").get_to(jumpTransitionEasing);
|
||||
j.at("disableDrawCache").get_to(main.drawProgCache.disableDrawCache);
|
||||
j.at("defaultCanvasBackgroundColor").get_to(main.defaultCanvasBackgroundColor);
|
||||
|
||||
j.at("tablet").at("pressureAffectsBrushWidth").get_to(tabletOptions.pressureAffectsBrushWidth);
|
||||
|
|
@ -1321,7 +1319,6 @@ void Toolbar::options_menu() {
|
|||
gui.text_label("Note: Requires restart to take effect. May cause bugs on Intel Graphics");
|
||||
gui.input_scalar_field("fps cap slider", "FPS cap", &main.fpsLimit, 3.0f, 10000.0f);
|
||||
#endif
|
||||
gui.checkbox_field("Disable Draw Cache", "Disable BVH Draw Cache", &main.drawProgCache.disableDrawCache);
|
||||
gui.pop_id();
|
||||
break;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,10 +31,6 @@ World::World(MainProgram& initMain, OpenWorldInfo& worldInfo):
|
|||
|
||||
netSource = worldInfo.netSource;
|
||||
|
||||
drawData.cam.changed = [&]() {
|
||||
main.drawProgCache.refresh = true;
|
||||
};
|
||||
|
||||
if(worldInfo.conType == CONNECTIONTYPE_CLIENT || worldInfo.conType == CONNECTIONTYPE_SERVER)
|
||||
NetLibrary::init();
|
||||
|
||||
|
|
|
|||
|
|
@ -286,8 +286,6 @@ void resize_window(MainStruct& mS) {
|
|||
throw std::runtime_error("[resize_window] No canvas made");
|
||||
|
||||
#endif
|
||||
|
||||
mS.m->init_draw_program_cache();
|
||||
}
|
||||
|
||||
#ifdef __EMSCRIPTEN__
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue