preface

After a few days of idle work, the whole frame of the page-turning animation has been completed, and the rest of the optimization will enter the next stage;

So let’s get straight to the effect:

Turn on Performance as agreed;

First, this is now a plain old ListView that simply provides the contents of each page:

After three steps, it becomes a reader for the page-turning animation:

(PS: The picture below is huge… Although the original MP4 has been played at double speed and the image size has been cut in half, this GIF is still 20 MB long… It’s not too late to run.

Two steps later comes the reader that overrides the page:

It seems that even the part of the page-turning animation, in Debug mode, can barely reach 16ms? I don’t think we need to optimize, right?

The part that is treated differently

Although the idea is basically the same as the previous implementation, but some details and implementation methods are different:

  • Since we used canvas to draw text, and converted canvas to picture cache; This time I’m going to do it directly with the paintChild, no more converting and caching, and for the ListView, I don’t care about the contents of the child; At the moment, this approach doesn’t seem to introduce any performance issues;

  • For the same reason, only the first page is processed instead of the second page.

  • The sequence of steps has been adjusted. PaintChild paints the whole thing first, and then paints the shaded parts first. This saves a lot of clipping work, because the upturned parts have to be covered up

  • Adjust the calculation rules by turning up the part, avoid the introduction of matrix and other mathematical factors, and use the API of Canvas to deal with it.

  • I’m not going to draw a shadow, I’m going to draw a drawShadow;

At the end

Now, at first glance, you don’t need to do anything about performance tuning, but it’s barely okay?

Then the next part of the core ———— novel content of chapter and subsection calculation;

See if textPainter has improved after two years, or if there is any other elegant way to handle it.