Removed the TileInfo struct used in TiledPictureRenderer.

Review URL: https://codereview.appspot.com/6443153

git-svn-id: http://skia.googlecode.com/svn/trunk@5206 2bbb7eff-a529-9590-31e7-b0007b416f81
This commit is contained in:
keyar@chromium.org 2012-08-20 22:04:07 +00:00
parent 436411b013
commit da652c2ad5
2 changed files with 13 additions and 20 deletions

View File

@ -179,18 +179,19 @@ TiledPictureRenderer::~TiledPictureRenderer() {
this->deleteTiles();
}
void TiledPictureRenderer::clipTile(const TileInfo& tile) {
void TiledPictureRenderer::clipTile(SkCanvas* tile) {
SkRect clip = SkRect::MakeWH(SkIntToScalar(fPicture->width()),
SkIntToScalar(fPicture->height()));
tile.fCanvas->clipRect(clip);
tile->clipRect(clip);
}
void TiledPictureRenderer::addTile(int tile_x_start, int tile_y_start) {
TileInfo* tile = fTiles.push();
SkCanvas* tile = this->setupCanvas(fTileWidth, fTileHeight);
tile->fCanvas = this->setupCanvas(fTileWidth, fTileHeight);
tile->fCanvas->translate(SkIntToScalar(-tile_x_start), SkIntToScalar(-tile_y_start));
this->clipTile(*tile);
tile->translate(SkIntToScalar(-tile_x_start), SkIntToScalar(-tile_y_start));
this->clipTile(tile);
fTiles.push(tile);
}
void TiledPictureRenderer::setupTiles() {
@ -205,7 +206,7 @@ void TiledPictureRenderer::setupTiles() {
void TiledPictureRenderer::deleteTiles() {
for (int i = 0; i < fTiles.count(); ++i) {
SkDELETE(fTiles[i].fCanvas);
SkDELETE(fTiles[i]);
}
fTiles.reset();
@ -213,13 +214,13 @@ void TiledPictureRenderer::deleteTiles() {
void TiledPictureRenderer::drawTiles() {
for (int i = 0; i < fTiles.count(); ++i) {
fTiles[i].fCanvas->drawPicture(*(fPicture));
fTiles[i]->drawPicture(*(fPicture));
}
}
void TiledPictureRenderer::finishDraw() {
for (int i = 0; i < fTiles.count(); ++i) {
fTiles[i].fCanvas->flush();
fTiles[i]->flush();
}
#if SK_SUPPORT_GPU
@ -244,7 +245,7 @@ void TiledPictureRenderer::copyTilesToCanvas() {
for (int tile_x_start = 0; tile_x_start < fPicture->width();
tile_x_start += fTileWidth) {
SkASSERT(tile_index < fTiles.count());
SkBitmap source = fTiles[tile_index].fCanvas->getDevice()->accessBitmap(false);
SkBitmap source = fTiles[tile_index]->getDevice()->accessBitmap(false);
fCanvas->drawBitmap(source,
SkIntToScalar(tile_x_start),
SkIntToScalar(tile_y_start));

View File

@ -156,28 +156,20 @@ protected:
virtual void finishDraw();
private:
struct TileInfo {
SkBitmap* fBitmap;
SkCanvas* fCanvas;
};
int fTileWidth;
int fTileHeight;
double fTileWidthPercentage;
double fTileHeightPercentage;
SkTDArray<TileInfo> fTiles;
SkTDArray<SkCanvas*> fTiles;
// Clips the tile to an area that is completely in what the SkPicture says is the
// drawn-to area. This is mostly important for tiles on the right and bottom edges
// as they may go over this area and the picture may have some commands that
// draw outside of this area and so should not actually be written.
void clipTile(const TileInfo& tile);
void clipTile(SkCanvas* tile);
void addTile(int tile_x_start, int tile_y_start);
void setupTiles();
// We manually delete the tiles instead of having a destructor on TileInfo as
// the destructor on TileInfo will be during a realloc. This would result in
// the canvases and bitmaps being prematurely deleted.
void deleteTiles();
void copyTilesToCanvas();