Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tile cleanup #84

Merged
merged 4 commits into from Jul 16, 2014
Merged

Tile cleanup #84

merged 4 commits into from Jul 16, 2014

Conversation

@mrobinson
Copy link
Member

mrobinson commented Jul 16, 2014

Tiles textures are maintained inside the TileGrid alongside buffers and Servo is no longer involved in the creation of Textures.

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.

@zwarich

zwarich Jul 16, 2014

Contributor

Bad indentation here.

id: *gl2::gen_textures(1).get(0),
target: target,
weak: false,
id: *gl2::gen_textures(1).get(0),

This comment has been minimized.

@zwarich

zwarich Jul 16, 2014

Contributor

Bad indentation here.

id: 0,
target: TextureTarget2D,
weak: true,
flip: NoFlip,
}

This comment has been minimized.

@zwarich

zwarich Jul 16, 2014

Contributor

The fields should be indented from the constructor.

id: *gl2::gen_textures(1).get(0),
target: target,
weak: false,
flip: NoFlip,
};

This comment has been minimized.

@zwarich

zwarich Jul 16, 2014

Contributor

The fields should be indented from the constructor.


pub struct Tile {
/// The buffer displayed by this tile.
buffer: Option<Box<LayerBuffer>>,

This comment has been minimized.

@zwarich

zwarich Jul 16, 2014

Contributor

When does buffer ever take None?

This comment has been minimized.

@mrobinson

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.

@zwarich

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.

@mrobinson

mrobinson Jul 16, 2014

Author Member

Sounds reasonable, especially when the TileGrid is creating its own buffers.

tiling.rs Outdated

// 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.

@zwarich

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.

@zwarich

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.

@mrobinson

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.

@zwarich

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.

@mrobinson

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.

@zwarich

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.

@zwarich

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.

@mrobinson

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.

mrobinson added 3 commits Jul 15, 2014
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.
zwarich pushed a commit that referenced this pull request Jul 16, 2014
@zwarich zwarich merged commit eebf3ac into servo:master Jul 16, 2014
@mrobinson mrobinson deleted the mrobinson:tile-cleanup branch Jul 18, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

2 participants
You can’t perform that action at this time.