diff options
author | commit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2014-03-14 18:23:12 +0000 |
---|---|---|
committer | commit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2014-03-14 18:23:12 +0000 |
commit | 1ab85c8719ef46a8f2de9912b3f84f387bddf0d1 (patch) | |
tree | f43e6468e0a7801ff73ca7e7554d007f1978950f /tools | |
parent | 118252962f89a80db661a0544f1bd61cbaab6321 (diff) |
Proposed SkCanvas API for preLoading textures to VRAM v2.0
This is an update to (Proposed SkCanvas API for preLoading textures to VRAM - https://codereview.chromium.org/192853002/). It takes into account in-person feedback on the initial proposal. The main feedback was to land this closer to where we will ultimately wind up with the reordered rendering capability (and don't have an SkCanvas entry point (yet)).
R=reed@google.com, bsalomon@google.com
Author: robertphillips@google.com
Review URL: https://codereview.chromium.org/197123003
git-svn-id: http://skia.googlecode.com/svn/trunk@13810 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'tools')
-rw-r--r-- | tools/PictureRenderer.cpp | 13 | ||||
-rw-r--r-- | tools/PictureRenderer.h | 4 | ||||
-rw-r--r-- | tools/render_pictures_main.cpp | 9 |
3 files changed, 19 insertions, 7 deletions
diff --git a/tools/PictureRenderer.cpp b/tools/PictureRenderer.cpp index ebac9ca46d..466e31d28e 100644 --- a/tools/PictureRenderer.cpp +++ b/tools/PictureRenderer.cpp @@ -570,20 +570,19 @@ void TiledPictureRenderer::setupPowerOf2Tiles() { } /** - * Draw the specified playback to the canvas translated to rectangle provided, so that this mini + * Draw the specified picture to the canvas translated to rectangle provided, so that this mini * canvas represents the rectangle's portion of the overall picture. * Saves and restores so that the initial clip and matrix return to their state before this function * is called. */ -template<class T> -static void DrawTileToCanvas(SkCanvas* canvas, const SkRect& tileRect, T* playback) { +static void draw_tile_to_canvas(SkCanvas* canvas, const SkRect& tileRect, SkPicture* picture) { int saveCount = canvas->save(); // Translate so that we draw the correct portion of the picture. // Perform a postTranslate so that the scaleFactor does not interfere with the positioning. SkMatrix mat(canvas->getTotalMatrix()); mat.postTranslate(-tileRect.fLeft, -tileRect.fTop); canvas->setMatrix(mat); - playback->draw(canvas); + canvas->drawPicture(*picture); canvas->restoreToCount(saveCount); canvas->flush(); } @@ -621,7 +620,7 @@ bool TiledPictureRenderer::nextTile(int &i, int &j) { void TiledPictureRenderer::drawCurrentTile() { SkASSERT(fCurrentTileOffset >= 0 && fCurrentTileOffset < fTileRects.count()); - DrawTileToCanvas(fCanvas, fTileRects[fCurrentTileOffset], fPicture); + draw_tile_to_canvas(fCanvas, fTileRects[fCurrentTileOffset], fPicture); } bool TiledPictureRenderer::render(const SkString* path, SkBitmap** out) { @@ -638,7 +637,7 @@ bool TiledPictureRenderer::render(const SkString* path, SkBitmap** out) { } bool success = true; for (int i = 0; i < fTileRects.count(); ++i) { - DrawTileToCanvas(fCanvas, fTileRects[i], fPicture); + draw_tile_to_canvas(fCanvas, fTileRects[i], fPicture); if (NULL != path) { success &= writeAppendNumber(fCanvas, path, i, fJsonSummaryPtr); } @@ -722,7 +721,7 @@ public: } for (int i = fStart; i < fEnd; i++) { - DrawTileToCanvas(fCanvas, fRects[i], fClone); + draw_tile_to_canvas(fCanvas, fRects[i], fClone); if ((fPath != NULL) && !writeAppendNumber(fCanvas, fPath, i, fJsonSummaryPtr) && fSuccess != NULL) { *fSuccess = false; diff --git a/tools/PictureRenderer.h b/tools/PictureRenderer.h index c3438c912f..010aadf05f 100644 --- a/tools/PictureRenderer.h +++ b/tools/PictureRenderer.h @@ -309,6 +309,10 @@ public: } } + SkCanvas* getCanvas() { + return fCanvas; + } + SkGLContextHelper* getGLContext() { GrContextFactory::GLContextType glContextType = GrContextFactory::kNull_GLContextType; diff --git a/tools/render_pictures_main.cpp b/tools/render_pictures_main.cpp index f0609c94fa..245f995382 100644 --- a/tools/render_pictures_main.cpp +++ b/tools/render_pictures_main.cpp @@ -44,6 +44,8 @@ DEFINE_bool(validate, false, "Verify that the rendered image contains the same p DEFINE_bool(bench_record, false, "If true, drop into an infinite loop of recording the picture."); +DEFINE_bool(preprocess, false, "If true, perform device specific preprocessing before rendering."); + static void make_output_filepath(SkString* path, const SkString& dir, const SkString& name) { sk_tools::make_filepath(path, dir, name); @@ -188,6 +190,13 @@ static bool render_picture_internal(const SkString& inputPath, const SkString* o inputPath.c_str()); renderer.init(picture); + + if (FLAGS_preprocess) { + if (NULL != renderer.getCanvas()) { + renderer.getCanvas()->EXPERIMENTAL_optimize(picture); + } + } + renderer.setup(); SkString* outputPath = NULL; |