这是indexloc提供的服务,不要输入任何密码
Skip to content

Conversation

@MrStevns
Copy link
Member

closes #1496

The PR includes another bugfix, related to when you removed a frame, the canvas would not be updated either.

@MrStevns MrStevns changed the title Fix cache moving frames Fix canvas showing wrong content after moving frames Nov 16, 2020
@scribblemaniac scribblemaniac added 🔹 Minor PR (only one reviewer required) Bug labels Nov 18, 2020
- Also fixed a cache bug when using actioncommand shortcuts

Additionally the swap logic has been reworked. A swap can only occur now when two frames exist, otherwise nothing will happen. So to get the same behavior as before, where the frame would be moved anyway, i've added individual via the new moveKeyFrame and removed moveForward/moveBackward as a result of it.
@MrStevns
Copy link
Member Author

MrStevns commented Nov 21, 2020

Update:
Alright I went with your simple suggestion, now we simply update selected frames before and after moving. You're right that it will likely always be faster to update moving frames than having to restore a lot of cache, especially if the canvas is big and yes smooth playback should be considered very important.

I've also reworked the swapKeyframe logic to make it behave more consistently, so that now a swap can only happen if two keyframes exist where as before one frame could be removed and moved regardless. Of course the result will be the same, the move keyframe logic has just been moved into a new moveKeyFrame function, which replace the moveFrameforward/backwards.

This got me reminded of the move keyframes shortcuts which also did not update cache, so that's also fixed now.

Copy link
Member

@scribblemaniac scribblemaniac left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the move to a more general moveKeyframe function over moveKeyframeForward/Backward, and I'm alright with swapKeyframe failing if both frames don't exit, but this implementation using a temporary selection for single frame moving opens a whole new can of worms. This is going to need either some discussion of how we want the move keyframe actions to work with a selection, or modifications to make it behave like it did before these changes.

@MrStevns MrStevns force-pushed the 1496-fix-cache-moving-frames branch from 536adc1 to dbbfb39 Compare December 20, 2020 13:41
@MrStevns
Copy link
Member Author

Ready to be reviewed again.

update();
}

void ScribbleArea::updateDirtyFrames()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the purpose of this function and the dirty frame tracking in general? To me it seems like an unnecessary extra step before removing cached frames.

Copy link
Member Author

@MrStevns MrStevns Dec 21, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You say that but also say that it's important that we update the cache for the frame before and after moving, so I don't think it's an unnecessary step. By all means if you have a better way of doing, do say so, cause I'm running out of ideas.

This way is imo. much better than making it up to the caller to update the frames it's modifying properly.

The name of the function may not be right but the intention is to make it up to scribblearea to clear the cache for the frames that has been modified or can be considered dirty on the currently layer.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let me clarify, I think updating the cache for the frame before and after moving is very important and not unnecessary. What I think is unnecessary is having the QList of frames that you are effectively delaying removing them from the cache. Why not just remove them from the cache right away?

Copy link
Member Author

@MrStevns MrStevns Dec 22, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They are being removed at the next frame update, which should happen right after the move, though it could potentially be delayed. it's the least coupled implementation I have come up with and it does the job. I'm not sure how to make it happen right away without involving scribblearea in the process, do you have any ideas? Maybe if we move the list of qpixmapcache into the layer model, then I would be able to clear it right away. What do you think about that?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think part of my confusion came from not paying attention to what was in Layer vs ScribbleArea. I see now that you don't have access to ScribbleArea in Layer and it indeed wouldn't be good to couple that.

As for alternative approaches, the qpixmapcache is for caching rendered+composited frames, so it would not be good to have that in each layer. It also wouldn't work because it needs access to the output of the CanvasPainter, which Layer does not have. It's a tricky problem. I thought maybe you could make a signal and connect the layers to Editor when they are created/loaded, but looking at the code I see that it's really object that's managing the layers, not layermanager, so that wouldn't really work. I have my worries that we might make some change or come across some corner-case where removeCacheForDirtyFrames does not get called, but your solution might be the best thing short of doing some major architectural changes.

@MrStevns MrStevns force-pushed the 1496-fix-cache-moving-frames branch from 1ca6d28 to 1af8f94 Compare December 21, 2020 20:49
Copy link
Member

@scribblemaniac scribblemaniac left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your patience. This is ready to be merged now I think.

@MrStevns MrStevns merged commit 0659130 into pencil2d:master Dec 26, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🔹 Minor PR (only one reviewer required)

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

Canvas showing incorrect content after moving frames.

2 participants