| 409 | } |
| 410 | |
| 411 | public void renderPage(final Matrix ctm, final Rect bbox, final boolean icc, final int antialias, final boolean invert, final boolean tint, final int tintBlack, final int tintWhite, final Cookie cookie, final OnException onException) { |
| 412 | worker.add(new Worker.Task() { |
| 413 | Pixmap pixmap = null; |
| 414 | Rect[] links = null; |
| 415 | String[] linkURIs = null; |
| 416 | Quad[][] hits = null; |
| 417 | public void work() { |
| 418 | Link[] pageLinks = page.getLinks(); |
| 419 | if (pageLinks == null) |
| 420 | { |
| 421 | links = new Rect[0]; |
| 422 | linkURIs = new String[0]; |
| 423 | } |
| 424 | else |
| 425 | { |
| 426 | int i = 0; |
| 427 | links = new Rect[pageLinks.length]; |
| 428 | linkURIs = new String[pageLinks.length]; |
| 429 | for (Link link: pageLinks) |
| 430 | { |
| 431 | links[i] = link.getBounds().transform(ctm); |
| 432 | linkURIs[i] = link.getURI(); |
| 433 | i++; |
| 434 | } |
| 435 | } |
| 436 | |
| 437 | if (currentPage.equals(searchHitPage)) |
| 438 | hits = page.search(searchNeedle); |
| 439 | if (hits == null) |
| 440 | hits = new Quad[0][]; |
| 441 | for (Quad[] hit : hits) |
| 442 | for (Quad q : hit) |
| 443 | q.transform(ctm); |
| 444 | |
| 445 | pixmap = new Pixmap(ColorSpace.DeviceBGR, bbox, true); |
| 446 | pixmap.clear(255); |
| 447 | |
| 448 | if (icc) |
| 449 | Context.enableICC(); |
| 450 | else |
| 451 | Context.disableICC(); |
| 452 | Context.setAntiAliasLevel(antialias); |
| 453 | |
| 454 | DrawDevice dev = new DrawDevice(pixmap); |
| 455 | page.run(dev, ctm, cookie); |
| 456 | dev.close(); |
| 457 | dev.destroy(); |
| 458 | |
| 459 | if (invert) { |
| 460 | pixmap.invertLuminance(); |
| 461 | pixmap.gamma(1 / 1.4f); |
| 462 | } |
| 463 | |
| 464 | if (tint) |
| 465 | pixmap.tint(tintBlack, tintWhite); |
| 466 | } |
| 467 | public void run() { |
| 468 | callback.onPageContentsChange(pixmap, links, linkURIs, hits); |