Added layer draw cache, and eraser works again
This commit is contained in:
parent
c2abccefc2
commit
7549ad23a1
29 changed files with 484 additions and 1434 deletions
|
|
@ -8,10 +8,25 @@ void DrawingProgramLayer::draw(SkCanvas* canvas, const DrawData& drawData) const
|
|||
p->obj->draw(canvas, drawData);
|
||||
}
|
||||
|
||||
void DrawingProgramLayer::set_component_list_callbacks(DrawingProgramLayerManager& layerMan) const {
|
||||
void DrawingProgramLayer::set_component_list_callbacks(DrawingProgramLayerListItem& layerListItem, DrawingProgramLayerManager& layerMan) const {
|
||||
components->set_insert_callback([&](const CanvasComponentContainer::ObjInfoSharedPtr& c) {
|
||||
c->obj->set_owner_obj_info(c);
|
||||
c->obj->parentLayer = &layerListItem;
|
||||
c->obj->commit_update(layerMan.drawP); // Run commit update on insert so that world bounds are calculated
|
||||
layerMan.drawP.drawCache.add_component(c);
|
||||
if(c->obj->get_comp().get_type() == CanvasComponentType::IMAGE)
|
||||
layerMan.drawP.updateableComponents.emplace(c);
|
||||
});
|
||||
components->set_erase_callback([&](const CanvasComponentContainer::ObjInfoSharedPtr& c) {
|
||||
layerMan.drawP.drawCache.erase_component(c);
|
||||
layerMan.drawP.drawTool->erase_component(c);
|
||||
std::erase_if(layerMan.drawP.droppedDownloadingFiles, [&c](auto& downloadingFile) {
|
||||
return downloadingFile.comp == c;
|
||||
});
|
||||
layerMan.drawP.updateableComponents.erase(c);
|
||||
});
|
||||
components->set_move_callback([&](const CanvasComponentContainer::ObjInfoSharedPtr& c, uint32_t oldPos) {
|
||||
layerMan.drawP.drawCache.invalidate_cache_at_aabb(c->obj->get_world_bounds());
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue