MCPcopy Create free account
hub / github.com/YACReader/yacreader / requestRange

Method requestRange

YACReader/continuous_page_provider.cpp:156–190  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

154}
155
156void ContinuousPageProvider::requestRange(int firstPage, int lastPage)
157{
158 if (!render || numPagesValue <= 0) {
159 return;
160 }
161
162 firstPage = qBound(0, firstPage, numPagesValue - 1);
163 lastPage = qBound(0, lastPage, numPagesValue - 1);
164 if (lastPage < firstPage) {
165 return;
166 }
167
168 requestedFirst = firstPage;
169 requestedLast = lastPage;
170
171 const int keepMin = std::max(0, firstPage - kEvictMargin);
172 const int keepMax = std::min(numPagesValue - 1, lastPage + kEvictMargin);
173
174 // Evict cached pages outside the kept window.
175 for (auto it = cache.begin(); it != cache.end();) {
176 if (it.key() < keepMin || it.key() > keepMax) {
177 it = cache.erase(it);
178 } else {
179 ++it;
180 }
181 }
182
183 // Schedule decode for requested pages whose raw bytes are loaded and that
184 // are not already decoded or in flight.
185 for (int i = firstPage; i <= lastPage; ++i) {
186 if (rawDataReady.contains(i) && !cache.contains(i) && !pending.contains(i)) {
187 scheduleDecode(i);
188 }
189 }
190}
191
192const QImage *ContinuousPageProvider::image(int pageIndex) const
193{

Callers 3

onNumPagesReadyMethod · 0.80
paintEventMethod · 0.80

Calls 1

containsMethod · 0.45

Tested by

no test coverage detected