How do modern browsers do tiled rendering (particularly in Direct2D) efficiently?
Asked Answered
D

1

6

This question has to do with how browsers render an entire page as tiled images (and is not about rendering images within pages.) I'm most interested in the memory costs.

It is my understanding that a browser such as Chrome will layout the entire page but render sections of it as needed, in small square tiles. When the user scrolls the page, only tiles that do not exist are rendered. Tile generation typically happens in a background thread, but this question is not concerned with threading.

So the question is, what is the total memory usage of this approach?

Let's assume that the screen is 1024x768 and that a tile is 64x64 pixels. So the screen is 16x12 tiles. Further I'm assuming each tile is 32 bits per pixel, that Direct2D is the rendering platform, and a Direct2D SwapChainPanel is used for performance.

During a given render cycle, Only a fraction of the total (16x12) tiles is likely to be rendered. However, the number is likely to be more than one. Therefore

  1. It seems to me that a scratch bitmap of 1024x768 is most convenient to render the currently invalid tiles to.
  2. The valid portions are then copied onto actual tile bitmaps of size 64x64, for use in the next step and in future render cycles.
  3. The final bitmap to be rendered is composed by blitting the appropriate tiles, some of which may have been produced by an earlier render cycle, and some in this render cycle. This final bitmap is also 1024x768.

Thus, it appears that two 32bpp bitmaps of the full screen size (1024x768) are needed in addition to the tiles.

Questions:

  1. Do browsers in fact use 32 bits per pixel, or something lower?
  2. Is step (3) above needed, or is there a way to render the tiles directly without a final bitmap?
  3. Are there any additional main memory allocations that I may have missed (e.g. by the GPU)?

The number of intermediate copies is a subtlety that requires careful thought, so I'd really appreciate precise answers. No speculation, please.

Daft answered 20/12, 2014 at 20:11 Comment(0)
A
0

With Chrome i think it is not an implementation in the rendering engine but the frontend browser. I use CEF and have used Awesomium both using Chrome/Webkit/Blink. You just pass a bitmap where the data is rendered, therefore it is the frontend which has to decide the optimal strategy.

I don't think that anyone would implement tiles that small. I assume they are something like 256 x Width (unless width is especially large) stripes.

Ambassadress answered 15/1, 2016 at 19:21 Comment(1)
Why the downvote? It is just correct. what i wrote and the OP is confusing the "tile" in a browser implementation with the tiles in games.Ambassadress

© 2022 - 2024 — McMap. All rights reserved.