void RenderCache::Render(DisplayModel *dm, int pageNo, RenderingCallback *callback) { TilePosition tile = { GetTileRes(dm, pageNo), 0, 0 }; Render(dm, pageNo, tile, true, callback); // render both tiles of the first row when splitting a page in four // (which always happens on larger displays for Fit Width) if (tile.res == 1 && !IsRenderQueueFull()) { tile.col = 1; Render(dm, pageNo, tile, false); } }
void RenderCache::RequestRendering(DisplayModel* dm, int pageNo) { TilePosition tile(GetTileRes(dm, pageNo), 0, 0); // only honor the request if there's a good chance that the // rendered tile will actually be used if (tile.res > 1) return; RequestRendering(dm, pageNo, tile); // render both tiles of the first row when splitting a page in four // (which always happens on larger displays for Fit Width) if (tile.res == 1 && !IsRenderQueueFull()) { tile.col = 1; RequestRendering(dm, pageNo, tile, false); } }
// TODO: conceptually, RenderCache is not the right place for code that paints // (this is the only place that knows about Tiles, though) UINT RenderCache::PaintTile(HDC hdc, RectI bounds, DisplayModel *dm, int pageNo, TilePosition tile, RectI tileOnScreen, bool renderMissing, bool *renderOutOfDateCue, bool *renderedReplacement) { BitmapCacheEntry *entry = Find(dm, pageNo, dm->Rotation(), dm->ZoomReal(), &tile); UINT renderDelay = 0; if (!entry) { if (!isRemoteSession) { if (renderedReplacement) *renderedReplacement = true; entry = Find(dm, pageNo, dm->Rotation(), INVALID_ZOOM, &tile); } renderDelay = GetRenderDelay(dm, pageNo, tile); if (renderMissing && RENDER_DELAY_UNDEFINED == renderDelay && !IsRenderQueueFull()) Render(dm, pageNo, tile); } RenderedBitmap *renderedBmp = entry ? entry->bitmap : NULL; HBITMAP hbmp = renderedBmp ? renderedBmp->GetBitmap() : NULL; if (!hbmp) { if (entry && !(renderedBmp && ReduceTileSize())) renderDelay = RENDER_DELAY_FAILED; else if (0 == renderDelay) renderDelay = 1; if (entry) DropCacheEntry(entry); return renderDelay; } HDC bmpDC = CreateCompatibleDC(hdc); if (bmpDC) { SizeI bmpSize = renderedBmp->Size(); int xSrc = -min(tileOnScreen.x, 0); int ySrc = -min(tileOnScreen.y, 0); float factor = min(1.0f * bmpSize.dx / tileOnScreen.dx, 1.0f * bmpSize.dy / tileOnScreen.dy); SelectObject(bmpDC, hbmp); if (factor != 1.0f) StretchBlt(hdc, bounds.x, bounds.y, bounds.dx, bounds.dy, bmpDC, (int)(xSrc * factor), (int)(ySrc * factor), (int)(bounds.dx * factor), (int)(bounds.dy * factor), SRCCOPY); else BitBlt(hdc, bounds.x, bounds.y, bounds.dx, bounds.dy, bmpDC, xSrc, ySrc, SRCCOPY); DeleteDC(bmpDC); #ifdef DEBUG_TILE_LAYOUT HPEN pen = CreatePen(PS_SOLID, 1, RGB(0xff, 0xff, 0x00)); HGDIOBJ oldPen = SelectObject(hdc, pen); PaintRect(hdc, bounds); DeletePen(SelectObject(hdc, oldPen)); #endif } if (renderOutOfDateCue) *renderOutOfDateCue = renderedBmp->outOfDate; DropCacheEntry(entry); return 0; }