Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upTile cleanup #84
Tile cleanup #84
Conversation
It's unclear whether LayerBuffers will always represent the contents of one Tile and there's only one implementation of this trait.
| id: 0, | ||
| target: TextureTarget2D, | ||
| weak: true, | ||
| id: 0, |
This comment has been minimized.
This comment has been minimized.
| id: *gl2::gen_textures(1).get(0), | ||
| target: target, | ||
| weak: false, | ||
| id: *gl2::gen_textures(1).get(0), |
This comment has been minimized.
This comment has been minimized.
| id: 0, | ||
| target: TextureTarget2D, | ||
| weak: true, | ||
| flip: NoFlip, | ||
| } |
This comment has been minimized.
This comment has been minimized.
| id: *gl2::gen_textures(1).get(0), | ||
| target: target, | ||
| weak: false, | ||
| flip: NoFlip, | ||
| }; |
This comment has been minimized.
This comment has been minimized.
|
|
||
| pub struct Tile { | ||
| /// The buffer displayed by this tile. | ||
| buffer: Option<Box<LayerBuffer>>, |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
mrobinson
Jul 16, 2014
Author
Member
In the next patch set the Tile will be created with a None buffer after the first buffer request and before it returns.
This comment has been minimized.
This comment has been minimized.
zwarich
Jul 16, 2014
Contributor
I see. When we double-buffer, the Tile will have to hold on to both the front and back buffers itself, even when they are being rendered into by the render task.
This comment has been minimized.
This comment has been minimized.
mrobinson
Jul 16, 2014
Author
Member
Sounds reasonable, especially when the TileGrid is creating its own buffers.
|
|
||
| // The size of tiles in this grid in device pixels. | ||
| tile_size: uint, | ||
|
|
||
| // Tiles that are currently unused or outside the last-known visible rectangle. | ||
| unused_tiles: Vec<Box<LayerBuffer>>, | ||
| unused_buffers: Vec<Box<LayerBuffer>>, |
This comment has been minimized.
This comment has been minimized.
zwarich
Jul 16, 2014
Contributor
You probably want to change the comment here to refer to buffers rather than tiles, and get rid of the 'last-known visible rectangle' part, since buffers are now independent of tiles.
| @@ -77,14 +137,14 @@ impl TileGrid { | |||
|
|
|||
| for tile_index in tile_indexes_to_take.iter() { | |||
| match self.tiles.pop(tile_index) { | |||
| Some(tile) => self.unused_tiles.push(tile), | |||
| Some(ref mut tile) => self.add_unused_buffer(tile.buffer.take()), | |||
This comment has been minimized.
This comment has been minimized.
zwarich
Jul 16, 2014
Contributor
If the tiles field of TileGrid is a HashMap<Point2D<uint>, Tile>, why does this need to be ref mut tile? Can't you just have a Some(tile)?
This comment has been minimized.
This comment has been minimized.
mrobinson
Jul 16, 2014
Author
Member
I believe this was necessary because tile.buffer.take() requires a mutable borrow of tile, since buffer.take() mutates buffer.
This comment has been minimized.
This comment has been minimized.
zwarich
Jul 16, 2014
Contributor
Since pop actually transfers ownership, I think it would make more sense to have this be a Some(tile) and then use an &mut tile for the call. I think this better reflects what's going on.
This comment has been minimized.
This comment has been minimized.
mrobinson
Jul 16, 2014
Author
Member
I get this, but perhaps I'm doing it incorrectly:
src/support/layers/rust-layers/tiling.rs:140:60: 140:64 error: cannot borrow immutable local variable `tile` as mutable
src/support/layers/rust-layers/tiling.rs:140 Some(tile) => self.add_unused_buffer((&mut tile).buffer.take()),
This comment has been minimized.
This comment has been minimized.
zwarich
Jul 16, 2014
Contributor
Oops, you would need a Some(mut tile), which makes it uglier. I guess the current thing in your patch is best.
| buffer: Option<Box<LayerBuffer>>, | ||
|
|
||
| /// A handle to the GPU texture. | ||
| pub texture: Texture, |
This comment has been minimized.
This comment has been minimized.
zwarich
Jul 16, 2014
Contributor
When buffer is None what is texture? Should it have a type that reflects that it is sometimes empty?
This comment has been minimized.
This comment has been minimized.
mrobinson
Jul 16, 2014
Author
Member
Tile has a builtin None instance provided by the Zero trait. I think that's the best thing to use since it already exists.
This will allow the TileGrid to better track the state of each Tile.
This allows Layers to create their own textures instead of relying on Servo to do the job. Textures now track whether or not they should be flipped by passing the buffer to the factory method.
This way each Tile can be responsible for creating its own Textures.
mrobinson commentedJul 16, 2014
Tiles textures are maintained inside the TileGrid alongside buffers and Servo is no longer involved in the creation of Textures.