| 793 | } |
| 794 | |
| 795 | void DisplayList::drawScreenTasks(std::vector<DrawTask> screenTasks, Surface* surface, |
| 796 | bool autoClear) const { |
| 797 | // Sort tasks by surface index to ensure they are drawn in batches. |
| 798 | std::sort(screenTasks.begin(), screenTasks.end(), |
| 799 | [](const DrawTask& a, const DrawTask& b) { return a.sourceIndex() < b.sourceIndex(); }); |
| 800 | auto canvas = surface->getCanvas(); |
| 801 | AutoCanvasRestore autoRestore(canvas); |
| 802 | Paint paint = {}; |
| 803 | paint.setAntiAlias(false); |
| 804 | if (autoClear) { |
| 805 | paint.setBlendMode(BlendMode::Src); |
| 806 | } |
| 807 | static SamplingOptions sampling(FilterMode::Nearest, MipmapMode::None); |
| 808 | canvas->setMatrix(Matrix::MakeTrans(_contentOffset.x, _contentOffset.y)); |
| 809 | for (auto& task : screenTasks) { |
| 810 | auto surfaceCache = surfaceCaches[task.sourceIndex()]; |
| 811 | DEBUG_ASSERT(surfaceCache != nullptr); |
| 812 | auto image = surfaceCache->makeImageSnapshot(); |
| 813 | canvas->drawImageRect(image, task.sourceRect(), task.tileRect(), sampling, &paint, |
| 814 | SrcRectConstraint::Strict); |
| 815 | } |
| 816 | } |
| 817 | |
| 818 | void DisplayList::renderDirtyRegions(Canvas* canvas, std::vector<Rect> dirtyRegions) { |
| 819 | if (lastDirtyRegions.empty()) { |
nothing calls this directly
no test coverage detected