2012-08-20 21:02:49 +00:00
|
|
|
/*
|
|
|
|
* Copyright 2012 Google Inc.
|
|
|
|
*
|
|
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
|
|
* found in the LICENSE file.
|
|
|
|
*/
|
|
|
|
|
2012-07-26 17:27:57 +00:00
|
|
|
#include "PictureRenderer.h"
|
2012-08-31 16:15:22 +00:00
|
|
|
#include "picture_utils.h"
|
2012-07-26 17:27:57 +00:00
|
|
|
#include "SamplePipeControllers.h"
|
|
|
|
#include "SkCanvas.h"
|
|
|
|
#include "SkDevice.h"
|
|
|
|
#include "SkGPipe.h"
|
2012-08-31 16:15:22 +00:00
|
|
|
#if SK_SUPPORT_GPU
|
|
|
|
#include "SkGpuDevice.h"
|
|
|
|
#endif
|
|
|
|
#include "SkGraphics.h"
|
|
|
|
#include "SkImageEncoder.h"
|
2012-08-23 15:24:13 +00:00
|
|
|
#include "SkMatrix.h"
|
2012-07-26 17:27:57 +00:00
|
|
|
#include "SkPicture.h"
|
2012-08-23 15:24:13 +00:00
|
|
|
#include "SkScalar.h"
|
2012-08-21 19:05:08 +00:00
|
|
|
#include "SkString.h"
|
2012-08-31 16:15:22 +00:00
|
|
|
#include "SkTemplates.h"
|
2012-07-26 17:27:57 +00:00
|
|
|
#include "SkTDArray.h"
|
2012-08-31 16:15:22 +00:00
|
|
|
#include "SkThreadUtils.h"
|
2012-07-26 17:27:57 +00:00
|
|
|
#include "SkTypes.h"
|
2012-08-20 15:03:29 +00:00
|
|
|
|
2012-07-26 17:27:57 +00:00
|
|
|
namespace sk_tools {
|
|
|
|
|
|
|
|
enum {
|
|
|
|
kDefaultTileWidth = 256,
|
|
|
|
kDefaultTileHeight = 256
|
|
|
|
};
|
|
|
|
|
2012-08-07 17:11:33 +00:00
|
|
|
void PictureRenderer::init(SkPicture* pict) {
|
2012-08-20 15:03:44 +00:00
|
|
|
SkASSERT(NULL == fPicture);
|
|
|
|
SkASSERT(NULL == fCanvas.get());
|
|
|
|
if (fPicture != NULL || NULL != fCanvas.get()) {
|
2012-08-07 17:11:33 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
SkASSERT(pict != NULL);
|
2012-08-20 15:03:44 +00:00
|
|
|
if (NULL == pict) {
|
2012-08-07 17:11:33 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
fPicture = pict;
|
2012-08-20 15:03:57 +00:00
|
|
|
fCanvas.reset(this->setupCanvas());
|
|
|
|
}
|
|
|
|
|
|
|
|
SkCanvas* PictureRenderer::setupCanvas() {
|
|
|
|
return this->setupCanvas(fPicture->width(), fPicture->height());
|
|
|
|
}
|
|
|
|
|
|
|
|
SkCanvas* PictureRenderer::setupCanvas(int width, int height) {
|
2012-08-20 15:03:29 +00:00
|
|
|
switch(fDeviceType) {
|
|
|
|
case kBitmap_DeviceType: {
|
|
|
|
SkBitmap bitmap;
|
2012-08-20 15:03:57 +00:00
|
|
|
sk_tools::setup_bitmap(&bitmap, width, height);
|
|
|
|
return SkNEW_ARGS(SkCanvas, (bitmap));
|
2012-08-20 15:03:29 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
#if SK_SUPPORT_GPU
|
|
|
|
case kGPU_DeviceType: {
|
|
|
|
SkAutoTUnref<SkGpuDevice> device(SkNEW_ARGS(SkGpuDevice,
|
2012-08-20 15:03:33 +00:00
|
|
|
(fGrContext, SkBitmap::kARGB_8888_Config,
|
2012-08-20 15:03:57 +00:00
|
|
|
width, height)));
|
|
|
|
return SkNEW_ARGS(SkCanvas, (device.get()));
|
2012-08-20 15:03:29 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
default:
|
|
|
|
SkASSERT(0);
|
|
|
|
}
|
2012-08-20 15:03:57 +00:00
|
|
|
|
|
|
|
return NULL;
|
2012-08-07 17:11:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void PictureRenderer::end() {
|
2012-08-20 15:03:47 +00:00
|
|
|
this->resetState();
|
2012-08-07 17:11:33 +00:00
|
|
|
fPicture = NULL;
|
|
|
|
fCanvas.reset(NULL);
|
|
|
|
}
|
|
|
|
|
2012-08-20 15:03:47 +00:00
|
|
|
void PictureRenderer::resetState() {
|
2012-08-20 15:04:12 +00:00
|
|
|
#if SK_SUPPORT_GPU
|
2012-08-20 15:03:47 +00:00
|
|
|
if (this->isUsingGpuDevice()) {
|
|
|
|
SkGLContext* glContext = fGrContextFactory.getGLContext(
|
|
|
|
GrContextFactory::kNative_GLContextType);
|
2012-08-20 15:04:15 +00:00
|
|
|
|
|
|
|
SkASSERT(glContext != NULL);
|
|
|
|
if (NULL == glContext) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-09-07 15:21:18 +00:00
|
|
|
fGrContext->flush();
|
2012-08-20 15:03:47 +00:00
|
|
|
SK_GL(*glContext, Finish());
|
|
|
|
}
|
2012-08-20 15:04:12 +00:00
|
|
|
#endif
|
2012-08-20 15:03:47 +00:00
|
|
|
}
|
|
|
|
|
2012-08-21 19:05:08 +00:00
|
|
|
bool PictureRenderer::write(const SkString& path) const {
|
|
|
|
SkASSERT(fCanvas.get() != NULL);
|
|
|
|
SkASSERT(fPicture != NULL);
|
|
|
|
if (NULL == fCanvas.get() || NULL == fPicture) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
SkBitmap bitmap;
|
|
|
|
sk_tools::setup_bitmap(&bitmap, fPicture->width(), fPicture->height());
|
|
|
|
|
|
|
|
fCanvas->readPixels(&bitmap, 0, 0);
|
|
|
|
sk_tools::force_all_opaque(bitmap);
|
|
|
|
|
|
|
|
return SkImageEncoder::EncodeFile(path.c_str(), bitmap, SkImageEncoder::kPNG_Type, 100);
|
|
|
|
}
|
|
|
|
|
2012-09-07 15:21:18 +00:00
|
|
|
void RecordPictureRenderer::render(bool doExtraWorkToDrawToBaseCanvas) {
|
|
|
|
SkPicture replayer;
|
|
|
|
SkCanvas* recorder = replayer.beginRecording(fPicture->width(), fPicture->height());
|
|
|
|
fPicture->draw(recorder);
|
|
|
|
replayer.endRecording();
|
|
|
|
}
|
|
|
|
|
|
|
|
void PipePictureRenderer::render(bool doExtraWorkToDrawToBaseCanvas) {
|
2012-08-07 17:11:33 +00:00
|
|
|
SkASSERT(fCanvas.get() != NULL);
|
|
|
|
SkASSERT(fPicture != NULL);
|
2012-08-20 15:03:44 +00:00
|
|
|
if (NULL == fCanvas.get() || NULL == fPicture) {
|
2012-08-07 17:11:33 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
PipeController pipeController(fCanvas.get());
|
2012-07-26 17:27:57 +00:00
|
|
|
SkGPipeWriter writer;
|
|
|
|
SkCanvas* pipeCanvas = writer.startRecording(&pipeController);
|
2012-08-07 17:11:33 +00:00
|
|
|
pipeCanvas->drawPicture(*fPicture);
|
2012-07-26 17:27:57 +00:00
|
|
|
writer.endRecording();
|
2012-09-07 15:21:18 +00:00
|
|
|
fCanvas->flush();
|
2012-07-26 17:27:57 +00:00
|
|
|
}
|
|
|
|
|
2012-09-07 15:21:18 +00:00
|
|
|
void SimplePictureRenderer::render(bool doExtraWorkToDrawToBaseCanvas) {
|
2012-08-07 17:11:33 +00:00
|
|
|
SkASSERT(fCanvas.get() != NULL);
|
|
|
|
SkASSERT(fPicture != NULL);
|
2012-08-20 15:03:44 +00:00
|
|
|
if (NULL == fCanvas.get() || NULL == fPicture) {
|
2012-08-07 17:11:33 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
fCanvas->drawPicture(*fPicture);
|
2012-09-07 15:21:18 +00:00
|
|
|
fCanvas->flush();
|
2012-07-26 17:27:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
TiledPictureRenderer::TiledPictureRenderer()
|
2012-08-31 16:15:22 +00:00
|
|
|
: fMultiThreaded(false)
|
|
|
|
, fUsePipe(false)
|
|
|
|
, fTileWidth(kDefaultTileWidth)
|
2012-08-29 17:35:07 +00:00
|
|
|
, fTileHeight(kDefaultTileHeight)
|
2012-09-10 19:01:38 +00:00
|
|
|
, fTileWidthPercentage(0.0)
|
2012-08-29 17:35:07 +00:00
|
|
|
, fTileHeightPercentage(0.0)
|
2012-09-10 19:01:38 +00:00
|
|
|
, fTileMinPowerOf2Width(0) { }
|
2012-07-26 17:27:57 +00:00
|
|
|
|
2012-08-07 17:11:33 +00:00
|
|
|
void TiledPictureRenderer::init(SkPicture* pict) {
|
|
|
|
SkASSERT(pict != NULL);
|
2012-08-20 15:03:44 +00:00
|
|
|
SkASSERT(0 == fTiles.count());
|
|
|
|
if (NULL == pict || fTiles.count() != 0) {
|
2012-08-07 17:11:33 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
this->INHERITED::init(pict);
|
2012-07-27 20:09:26 +00:00
|
|
|
|
|
|
|
if (fTileWidthPercentage > 0) {
|
2012-08-15 14:36:41 +00:00
|
|
|
fTileWidth = sk_float_ceil2int(float(fTileWidthPercentage * fPicture->width() / 100));
|
2012-07-27 20:09:26 +00:00
|
|
|
}
|
|
|
|
if (fTileHeightPercentage > 0) {
|
2012-08-15 14:36:41 +00:00
|
|
|
fTileHeight = sk_float_ceil2int(float(fTileHeightPercentage * fPicture->height() / 100));
|
2012-07-27 20:09:26 +00:00
|
|
|
}
|
|
|
|
|
2012-08-23 20:53:25 +00:00
|
|
|
if (fTileMinPowerOf2Width > 0) {
|
|
|
|
this->setupPowerOf2Tiles();
|
|
|
|
} else {
|
|
|
|
this->setupTiles();
|
|
|
|
}
|
2012-07-26 17:27:57 +00:00
|
|
|
}
|
|
|
|
|
2012-09-07 15:21:18 +00:00
|
|
|
void TiledPictureRenderer::render(bool doExtraWorkToDrawToBaseCanvas) {
|
2012-08-07 17:11:33 +00:00
|
|
|
SkASSERT(fCanvas.get() != NULL);
|
|
|
|
SkASSERT(fPicture != NULL);
|
2012-08-20 15:03:44 +00:00
|
|
|
if (NULL == fCanvas.get() || NULL == fPicture) {
|
2012-08-07 17:11:33 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
this->drawTiles();
|
2012-09-07 15:21:18 +00:00
|
|
|
if (doExtraWorkToDrawToBaseCanvas) {
|
|
|
|
this->copyTilesToCanvas();
|
|
|
|
}
|
2012-08-07 17:11:33 +00:00
|
|
|
}
|
2012-07-26 17:27:57 +00:00
|
|
|
|
2012-08-07 17:11:33 +00:00
|
|
|
void TiledPictureRenderer::end() {
|
|
|
|
this->deleteTiles();
|
|
|
|
this->INHERITED::end();
|
2012-07-26 17:27:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
TiledPictureRenderer::~TiledPictureRenderer() {
|
2012-08-07 17:11:33 +00:00
|
|
|
this->deleteTiles();
|
2012-07-26 17:27:57 +00:00
|
|
|
}
|
|
|
|
|
2012-08-20 22:04:07 +00:00
|
|
|
void TiledPictureRenderer::clipTile(SkCanvas* tile) {
|
2012-08-07 17:11:33 +00:00
|
|
|
SkRect clip = SkRect::MakeWH(SkIntToScalar(fPicture->width()),
|
|
|
|
SkIntToScalar(fPicture->height()));
|
2012-08-20 22:04:07 +00:00
|
|
|
tile->clipRect(clip);
|
2012-07-26 17:27:57 +00:00
|
|
|
}
|
|
|
|
|
2012-08-23 20:53:25 +00:00
|
|
|
void TiledPictureRenderer::addTile(int tile_x_start, int tile_y_start, int width, int height) {
|
|
|
|
SkCanvas* tile = this->setupCanvas(width, height);
|
2012-07-26 17:27:57 +00:00
|
|
|
|
2012-08-20 22:04:07 +00:00
|
|
|
tile->translate(SkIntToScalar(-tile_x_start), SkIntToScalar(-tile_y_start));
|
|
|
|
this->clipTile(tile);
|
|
|
|
|
|
|
|
fTiles.push(tile);
|
2012-07-26 17:27:57 +00:00
|
|
|
}
|
|
|
|
|
2012-08-07 17:11:33 +00:00
|
|
|
void TiledPictureRenderer::setupTiles() {
|
|
|
|
for (int tile_y_start = 0; tile_y_start < fPicture->height();
|
2012-07-26 17:27:57 +00:00
|
|
|
tile_y_start += fTileHeight) {
|
2012-08-07 17:11:33 +00:00
|
|
|
for (int tile_x_start = 0; tile_x_start < fPicture->width();
|
2012-07-26 17:27:57 +00:00
|
|
|
tile_x_start += fTileWidth) {
|
2012-08-23 20:53:25 +00:00
|
|
|
this->addTile(tile_x_start, tile_y_start, fTileWidth, fTileHeight);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// The goal of the powers of two tiles is to minimize the amount of wasted tile
|
|
|
|
// space in the width-wise direction and then minimize the number of tiles. The
|
|
|
|
// constraints are that every tile must have a pixel width that is a power of
|
|
|
|
// two and also be of some minimal width (that is also a power of two).
|
|
|
|
//
|
2012-08-31 16:15:22 +00:00
|
|
|
// This is solved by first taking our picture size and rounding it up to the
|
2012-08-23 20:53:25 +00:00
|
|
|
// multiple of the minimal width. The binary representation of this rounded
|
|
|
|
// value gives us the tiles we need: a bit of value one means we need a tile of
|
|
|
|
// that size.
|
|
|
|
void TiledPictureRenderer::setupPowerOf2Tiles() {
|
|
|
|
int rounded_value = fPicture->width();
|
|
|
|
if (fPicture->width() % fTileMinPowerOf2Width != 0) {
|
|
|
|
rounded_value = fPicture->width() - (fPicture->width() % fTileMinPowerOf2Width)
|
|
|
|
+ fTileMinPowerOf2Width;
|
|
|
|
}
|
|
|
|
|
2012-09-06 18:43:21 +00:00
|
|
|
int num_bits = SkScalarCeilToInt(SkScalarLog2(SkIntToScalar(fPicture->width())));
|
2012-08-23 20:53:25 +00:00
|
|
|
int largest_possible_tile_size = 1 << num_bits;
|
|
|
|
|
|
|
|
// The tile height is constant for a particular picture.
|
|
|
|
for (int tile_y_start = 0; tile_y_start < fPicture->height(); tile_y_start += fTileHeight) {
|
|
|
|
int tile_x_start = 0;
|
|
|
|
int current_width = largest_possible_tile_size;
|
|
|
|
|
|
|
|
while (current_width >= fTileMinPowerOf2Width) {
|
|
|
|
// It is very important this is a bitwise AND.
|
|
|
|
if (current_width & rounded_value) {
|
|
|
|
this->addTile(tile_x_start, tile_y_start, current_width, fTileHeight);
|
|
|
|
tile_x_start += current_width;
|
|
|
|
}
|
|
|
|
|
|
|
|
current_width >>= 1;
|
2012-07-26 17:27:57 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void TiledPictureRenderer::deleteTiles() {
|
|
|
|
for (int i = 0; i < fTiles.count(); ++i) {
|
2012-08-20 22:04:07 +00:00
|
|
|
SkDELETE(fTiles[i]);
|
2012-07-26 17:27:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
fTiles.reset();
|
|
|
|
}
|
|
|
|
|
2012-08-31 16:15:22 +00:00
|
|
|
///////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Draw using Pipe
|
|
|
|
|
|
|
|
struct TileData {
|
2012-08-31 16:25:46 +00:00
|
|
|
TileData(SkCanvas* canvas, ThreadSafePipeController* controller);
|
2012-08-31 16:15:22 +00:00
|
|
|
SkCanvas* fCanvas;
|
2012-08-31 16:25:46 +00:00
|
|
|
ThreadSafePipeController* fController;
|
2012-08-31 16:15:22 +00:00
|
|
|
SkThread fThread;
|
|
|
|
};
|
|
|
|
|
|
|
|
static void DrawTile(void* data) {
|
|
|
|
SkGraphics::SetTLSFontCacheLimit(1 * 1024 * 1024);
|
|
|
|
TileData* tileData = static_cast<TileData*>(data);
|
|
|
|
tileData->fController->playback(tileData->fCanvas);
|
2012-09-07 15:21:18 +00:00
|
|
|
tileData->fCanvas->flush();
|
2012-08-31 16:15:22 +00:00
|
|
|
}
|
|
|
|
|
2012-08-31 16:25:46 +00:00
|
|
|
TileData::TileData(SkCanvas* canvas, ThreadSafePipeController* controller)
|
2012-08-31 16:15:22 +00:00
|
|
|
: fCanvas(canvas)
|
|
|
|
, fController(controller)
|
|
|
|
, fThread(&DrawTile, static_cast<void*>(this)) {}
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Draw using Picture
|
|
|
|
|
|
|
|
struct CloneData {
|
|
|
|
CloneData(SkCanvas* target, SkPicture* original);
|
|
|
|
SkCanvas* fCanvas;
|
|
|
|
SkPicture* fClone;
|
|
|
|
SkThread fThread;
|
|
|
|
};
|
|
|
|
|
|
|
|
static void DrawClonedTile(void* data) {
|
|
|
|
SkGraphics::SetTLSFontCacheLimit(1 * 1024 * 1024);
|
|
|
|
CloneData* cloneData = static_cast<CloneData*>(data);
|
|
|
|
cloneData->fCanvas->drawPicture(*cloneData->fClone);
|
2012-09-07 15:21:18 +00:00
|
|
|
cloneData->fCanvas->flush();
|
2012-08-31 16:15:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
CloneData::CloneData(SkCanvas* target, SkPicture* clone)
|
|
|
|
: fCanvas(target)
|
|
|
|
, fClone(clone)
|
|
|
|
, fThread(&DrawClonedTile, static_cast<void*>(this)) {}
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2012-08-07 17:11:33 +00:00
|
|
|
void TiledPictureRenderer::drawTiles() {
|
2012-08-31 16:15:22 +00:00
|
|
|
if (fMultiThreaded) {
|
|
|
|
if (fUsePipe) {
|
|
|
|
// First, draw into a pipe controller
|
|
|
|
SkGPipeWriter writer;
|
2012-08-31 16:25:46 +00:00
|
|
|
ThreadSafePipeController controller(fTiles.count());
|
2012-08-31 16:15:22 +00:00
|
|
|
SkCanvas* pipeCanvas = writer.startRecording(&controller,
|
|
|
|
SkGPipeWriter::kSimultaneousReaders_Flag);
|
|
|
|
pipeCanvas->drawPicture(*(fPicture));
|
|
|
|
writer.endRecording();
|
|
|
|
|
|
|
|
// Create and start the threads.
|
2012-08-31 18:34:09 +00:00
|
|
|
TileData** tileData = SkNEW_ARRAY(TileData*, fTiles.count());
|
|
|
|
SkAutoTDeleteArray<TileData*> deleteTileData(tileData);
|
2012-08-31 16:15:22 +00:00
|
|
|
for (int i = 0; i < fTiles.count(); i++) {
|
|
|
|
tileData[i] = SkNEW_ARGS(TileData, (fTiles[i], &controller));
|
|
|
|
if (!tileData[i]->fThread.start()) {
|
|
|
|
SkDebugf("could not start thread %i\n", i);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
for (int i = 0; i < fTiles.count(); i++) {
|
|
|
|
tileData[i]->fThread.join();
|
|
|
|
SkDELETE(tileData[i]);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
SkPicture* clones = SkNEW_ARRAY(SkPicture, fTiles.count());
|
|
|
|
SkAutoTDeleteArray<SkPicture> autodelete(clones);
|
|
|
|
fPicture->clone(clones, fTiles.count());
|
2012-08-31 18:34:09 +00:00
|
|
|
CloneData** cloneData = SkNEW_ARRAY(CloneData*, fTiles.count());
|
|
|
|
SkAutoTDeleteArray<CloneData*> deleteCloneData(cloneData);
|
2012-08-31 16:15:22 +00:00
|
|
|
for (int i = 0; i < fTiles.count(); i++) {
|
|
|
|
cloneData[i] = SkNEW_ARGS(CloneData, (fTiles[i], &clones[i]));
|
|
|
|
if (!cloneData[i]->fThread.start()) {
|
|
|
|
SkDebugf("Could not start picture thread %i\n", i);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
for (int i = 0; i < fTiles.count(); i++) {
|
|
|
|
cloneData[i]->fThread.join();
|
|
|
|
SkDELETE(cloneData[i]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
for (int i = 0; i < fTiles.count(); ++i) {
|
|
|
|
fTiles[i]->drawPicture(*(fPicture));
|
2012-09-07 15:21:18 +00:00
|
|
|
fTiles[i]->flush();
|
2012-08-31 16:15:22 +00:00
|
|
|
}
|
2012-08-01 17:53:29 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-08-07 17:11:33 +00:00
|
|
|
void TiledPictureRenderer::copyTilesToCanvas() {
|
2012-08-23 15:24:13 +00:00
|
|
|
for (int i = 0; i < fTiles.count(); ++i) {
|
|
|
|
// Since SkPicture performs a save and restore when being drawn to a
|
|
|
|
// canvas, we can be confident that the transform matrix of the canvas
|
|
|
|
// is what we set when creating the tiles.
|
|
|
|
SkMatrix matrix = fTiles[i]->getTotalMatrix();
|
|
|
|
SkScalar tile_x_start = matrix.getTranslateX();
|
|
|
|
SkScalar tile_y_start = matrix.getTranslateY();
|
|
|
|
|
|
|
|
SkBitmap source = fTiles[i]->getDevice()->accessBitmap(false);
|
|
|
|
|
|
|
|
fCanvas->drawBitmap(source, -tile_x_start, -tile_y_start);
|
2012-07-26 17:27:57 +00:00
|
|
|
}
|
2012-09-07 15:21:18 +00:00
|
|
|
fCanvas->flush();
|
|
|
|
}
|
|
|
|
|
|
|
|
void PlaybackCreationRenderer::setup() {
|
|
|
|
SkCanvas* recorder = fReplayer.beginRecording(fPicture->width(), fPicture->height());
|
|
|
|
fPicture->draw(recorder);
|
|
|
|
}
|
|
|
|
|
|
|
|
void PlaybackCreationRenderer::render(bool doExtraWorkToDrawToBaseCanvas) {
|
|
|
|
fReplayer.endRecording();
|
2012-07-26 17:27:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|