aboutsummaryrefslogtreecommitdiffhomepage
path: root/tools
diff options
context:
space:
mode:
authorGravatar mtklein <mtklein@chromium.org>2014-06-27 12:34:44 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2014-06-27 12:34:44 -0700
commitd3e474e20c6f0f24ddb6b2643e92975d60190daa (patch)
treef2e39eab8d338bc80f524904de5ab15bd4e0df5e /tools
parent67ec1f8eecfb48bc0a6ba04c0057f103c1c9696f (diff)
Deprecate SkPicture::clone().
Chrome will need -DSK_SUPPORT_LEGACY_PICTURE_CLONE. This removes the modes from our tools that use clone(). No bots run these. DM used clone() in a way that we can just share the picture now. I plan to bring back the ability to test multithreaded picture rendering soon. BUG=skia:2378 R=robertphillips@google.com, mtklein@google.com, bsalomon@google.com Author: mtklein@chromium.org Review URL: https://codereview.chromium.org/338633011
Diffstat (limited to 'tools')
-rw-r--r--tools/PictureRenderer.cpp205
-rw-r--r--tools/PictureRenderer.h38
-rw-r--r--tools/PictureRenderingFlags.cpp45
-rw-r--r--tools/bench_pictures_main.cpp5
-rw-r--r--tools/render_pictures_main.cpp12
5 files changed, 0 insertions, 305 deletions
diff --git a/tools/PictureRenderer.cpp b/tools/PictureRenderer.cpp
index d337a5ebb7..acc7878230 100644
--- a/tools/PictureRenderer.cpp
+++ b/tools/PictureRenderer.cpp
@@ -698,188 +698,6 @@ SkString TiledPictureRenderer::getConfigNameInternal() {
///////////////////////////////////////////////////////////////////////////////////////////////
-// Holds all of the information needed to draw a set of tiles.
-class CloneData : public SkRunnable {
-
-public:
- CloneData(SkPicture* clone, SkCanvas* canvas, SkTDArray<SkRect>& rects, int start, int end,
- SkRunnable* done, ImageResultsAndExpectations* jsonSummaryPtr,
- bool useChecksumBasedFilenames, bool enableWrites)
- : fClone(clone)
- , fCanvas(canvas)
- , fEnableWrites(enableWrites)
- , fRects(rects)
- , fStart(start)
- , fEnd(end)
- , fSuccess(NULL)
- , fDone(done)
- , fJsonSummaryPtr(jsonSummaryPtr)
- , fUseChecksumBasedFilenames(useChecksumBasedFilenames) {
- SkASSERT(fDone != NULL);
- }
-
- virtual void run() SK_OVERRIDE {
- SkGraphics::SetTLSFontCacheLimit(1024 * 1024);
-
- SkBitmap bitmap;
- if (fBitmap != NULL) {
- // All tiles are the same size.
- setup_bitmap(&bitmap, SkScalarFloorToInt(fRects[0].width()), SkScalarFloorToInt(fRects[0].height()));
- }
-
- for (int i = fStart; i < fEnd; i++) {
- draw_tile_to_canvas(fCanvas, fRects[i], fClone);
- if (fEnableWrites) {
- if (!write(fCanvas, fWritePath, fMismatchPath, fInputFilename, fJsonSummaryPtr,
- fUseChecksumBasedFilenames, &i)
- && fSuccess != NULL) {
- *fSuccess = false;
- // If one tile fails to write to a file, do not continue drawing the rest.
- break;
- }
- if (fBitmap != NULL) {
- if (fCanvas->readPixels(&bitmap, 0, 0)) {
- SkAutoLockPixels alp(*fBitmap);
- bitmapCopyAtOffset(bitmap, fBitmap, SkScalarFloorToInt(fRects[i].left()),
- SkScalarFloorToInt(fRects[i].top()));
- } else {
- *fSuccess = false;
- // If one tile fails to read pixels, do not continue drawing the rest.
- break;
- }
- }
- }
- }
- fDone->run();
- }
-
- void setPathsAndSuccess(const SkString& writePath, const SkString& mismatchPath,
- const SkString& inputFilename, bool* success) {
- fWritePath.set(writePath);
- fMismatchPath.set(mismatchPath);
- fInputFilename.set(inputFilename);
- fSuccess = success;
- }
-
- void setBitmap(SkBitmap* bitmap) {
- fBitmap = bitmap;
- }
-
-private:
- // All pointers unowned.
- SkPicture* fClone; // Picture to draw from. Each CloneData has a unique one which
- // is threadsafe.
- SkCanvas* fCanvas; // Canvas to draw to. Reused for each tile.
- bool fEnableWrites; // TODO(epoger): Temporary hack; see declaration of
- // fEnableWrites in PictureRenderer.h.
- SkString fWritePath; // If not empty, write all results into this directory.
- SkString fMismatchPath; // If not empty, write all unexpected results into this dir.
- SkString fInputFilename; // Filename of input SkPicture file.
- SkTDArray<SkRect>& fRects; // All tiles of the picture.
- const int fStart; // Range of tiles drawn by this thread.
- const int fEnd;
- bool* fSuccess; // Only meaningful if path is non-null. Shared by all threads,
- // and only set to false upon failure to write to a PNG.
- SkRunnable* fDone;
- SkBitmap* fBitmap;
- ImageResultsAndExpectations* fJsonSummaryPtr;
- bool fUseChecksumBasedFilenames;
-};
-
-MultiCorePictureRenderer::MultiCorePictureRenderer(int threadCount)
-: fNumThreads(threadCount)
-, fThreadPool(threadCount)
-, fCountdown(threadCount) {
- // Only need to create fNumThreads - 1 clones, since one thread will use the base
- // picture.
- fPictureClones = SkNEW_ARRAY(SkPicture, fNumThreads - 1);
- fCloneData = SkNEW_ARRAY(CloneData*, fNumThreads);
-}
-
-void MultiCorePictureRenderer::init(SkPicture *pict, const SkString* writePath,
- const SkString* mismatchPath, const SkString* inputFilename,
- bool useChecksumBasedFilenames) {
- // Set fPicture and the tiles.
- this->INHERITED::init(pict, writePath, mismatchPath, inputFilename, useChecksumBasedFilenames);
- for (int i = 0; i < fNumThreads; ++i) {
- *fCanvasPool.append() = this->setupCanvas(this->getTileWidth(), this->getTileHeight());
- }
- // Only need to create fNumThreads - 1 clones, since one thread will use the base picture.
- fPicture->clone(fPictureClones, fNumThreads - 1);
- // Populate each thread with the appropriate data.
- // Group the tiles into nearly equal size chunks, rounding up so we're sure to cover them all.
- const int chunkSize = (fTileRects.count() + fNumThreads - 1) / fNumThreads;
-
- for (int i = 0; i < fNumThreads; i++) {
- SkPicture* pic;
- if (i == fNumThreads-1) {
- // The last set will use the original SkPicture.
- pic = fPicture;
- } else {
- pic = &fPictureClones[i];
- }
- const int start = i * chunkSize;
- const int end = SkMin32(start + chunkSize, fTileRects.count());
- fCloneData[i] = SkNEW_ARGS(CloneData,
- (pic, fCanvasPool[i], fTileRects, start, end, &fCountdown,
- fJsonSummaryPtr, useChecksumBasedFilenames, fEnableWrites));
- }
-}
-
-bool MultiCorePictureRenderer::render(SkBitmap** out) {
- bool success = true;
- if (!fWritePath.isEmpty() || !fMismatchPath.isEmpty()) {
- for (int i = 0; i < fNumThreads-1; i++) {
- fCloneData[i]->setPathsAndSuccess(fWritePath, fMismatchPath, fInputFilename, &success);
- }
- }
-
- if (NULL != out) {
- *out = SkNEW(SkBitmap);
- setup_bitmap(*out, fPicture->width(), fPicture->height());
- for (int i = 0; i < fNumThreads; i++) {
- fCloneData[i]->setBitmap(*out);
- }
- } else {
- for (int i = 0; i < fNumThreads; i++) {
- fCloneData[i]->setBitmap(NULL);
- }
- }
-
- fCountdown.reset(fNumThreads);
- for (int i = 0; i < fNumThreads; i++) {
- fThreadPool.add(fCloneData[i]);
- }
- fCountdown.wait();
-
- return success;
-}
-
-void MultiCorePictureRenderer::end() {
- for (int i = 0; i < fNumThreads - 1; i++) {
- SkDELETE(fCloneData[i]);
- fCloneData[i] = NULL;
- }
-
- fCanvasPool.unrefAll();
-
- this->INHERITED::end();
-}
-
-MultiCorePictureRenderer::~MultiCorePictureRenderer() {
- // Each individual CloneData was deleted in end.
- SkDELETE_ARRAY(fCloneData);
- SkDELETE_ARRAY(fPictureClones);
-}
-
-SkString MultiCorePictureRenderer::getConfigNameInternal() {
- SkString name = this->INHERITED::getConfigNameInternal();
- name.appendf("_multi_%i_threads", fNumThreads);
- return name;
-}
-
-///////////////////////////////////////////////////////////////////////////////////////////////
-
void PlaybackCreationRenderer::setup() {
SkAutoTDelete<SkBBHFactory> factory(this->getFactory());
fRecorder.reset(SkNEW(SkPictureRecorder));
@@ -941,27 +759,4 @@ PictureRenderer* CreateGatherPixelRefsRenderer() {
return SkNEW(GatherRenderer);
}
-///////////////////////////////////////////////////////////////////////////////
-
-class PictureCloneRenderer : public PictureRenderer {
-public:
- virtual bool render(SkBitmap** out = NULL) SK_OVERRIDE {
- for (int i = 0; i < 100; ++i) {
- SkPicture* clone = fPicture->clone();
- SkSafeUnref(clone);
- }
-
- return (fWritePath.isEmpty()); // we don't have anything to write
- }
-
-private:
- virtual SkString getConfigNameInternal() SK_OVERRIDE {
- return SkString("picture_clone");
- }
-};
-
-PictureRenderer* CreatePictureCloneRenderer() {
- return SkNEW(PictureCloneRenderer);
-}
-
} // namespace sk_tools
diff --git a/tools/PictureRenderer.h b/tools/PictureRenderer.h
index e6f4020dfd..13b60ecb09 100644
--- a/tools/PictureRenderer.h
+++ b/tools/PictureRenderer.h
@@ -9,7 +9,6 @@
#define PictureRenderer_DEFINED
#include "SkCanvas.h"
-#include "SkCountdown.h"
#include "SkDrawFilter.h"
#include "SkJSONCPP.h"
#include "SkMath.h"
@@ -18,10 +17,8 @@
#include "SkPictureRecorder.h"
#include "SkRect.h"
#include "SkRefCnt.h"
-#include "SkRunnable.h"
#include "SkString.h"
#include "SkTDArray.h"
-#include "SkThreadPool.h"
#include "SkTypes.h"
#if SK_SUPPORT_GPU
@@ -543,7 +540,6 @@ public:
* Renders to tiles, rather than a single canvas.
* If fWritePath was provided, a separate file is
* created for each tile, named "path0.png", "path1.png", etc.
- * Multithreaded mode currently does not support writing to a file.
*/
virtual bool render(SkBitmap** out = NULL) SK_OVERRIDE;
@@ -653,39 +649,6 @@ private:
typedef PictureRenderer INHERITED;
};
-class CloneData;
-
-class MultiCorePictureRenderer : public TiledPictureRenderer {
-public:
- explicit MultiCorePictureRenderer(int threadCount);
-
- ~MultiCorePictureRenderer();
-
- virtual void init(SkPicture* pict, const SkString* writePath, const SkString* mismatchPath,
- const SkString* inputFilename, bool useChecksumBasedFilenames) SK_OVERRIDE;
-
- /**
- * Behaves like TiledPictureRenderer::render(), only using multiple threads.
- */
- virtual bool render(SkBitmap** out = NULL) SK_OVERRIDE;
-
- virtual void end() SK_OVERRIDE;
-
- virtual bool supportsTimingIndividualTiles() SK_OVERRIDE { return false; }
-
-private:
- virtual SkString getConfigNameInternal() SK_OVERRIDE;
-
- const int fNumThreads;
- SkTDArray<SkCanvas*> fCanvasPool;
- SkThreadPool fThreadPool;
- SkPicture* fPictureClones;
- CloneData** fCloneData;
- SkCountdown fCountdown;
-
- typedef TiledPictureRenderer INHERITED;
-};
-
/**
* This class does not do any rendering, but its render function executes turning an SkPictureRecord
* into an SkPicturePlayback, which we want to time.
@@ -709,7 +672,6 @@ private:
};
extern PictureRenderer* CreateGatherPixelRefsRenderer();
-extern PictureRenderer* CreatePictureCloneRenderer();
}
diff --git a/tools/PictureRenderingFlags.cpp b/tools/PictureRenderingFlags.cpp
index 5acec267b0..3e7821819f 100644
--- a/tools/PictureRenderingFlags.cpp
+++ b/tools/PictureRenderingFlags.cpp
@@ -66,8 +66,6 @@ DEFINE_string(mode, "simple", "Run in the corresponding mode:\n"
"\tSkPicturePlayback.\n"
"rerecord: (Only in render_pictures) Record the picture as a new skp,\n"
"\twith the bitmaps PNG encoded.\n");
-DEFINE_int32(multi, 1, "Set the number of threads for multi threaded drawing. "
- "If > 1, requires tiled rendering.");
DEFINE_bool(pipe, false, "Use SkGPipe rendering. Currently incompatible with \"mode\".");
DEFINE_string2(readPath, r, "", "skp files or directories of skp files to process.");
DEFINE_double(scale, 1, "Set the scale factor.");
@@ -78,11 +76,6 @@ DEFINE_string(viewport, "", "width height: Set the viewport.");
sk_tools::PictureRenderer* parseRenderer(SkString& error, PictureTool tool) {
error.reset();
- if (FLAGS_multi <= 0) {
- error.printf("--multi must be > 0, was %i", FLAGS_multi);
- return NULL;
- }
-
bool useTiles = false;
const char* widthString = NULL;
const char* heightString = NULL;
@@ -97,9 +90,6 @@ sk_tools::PictureRenderer* parseRenderer(SkString& error, PictureTool tool) {
if (0 == strcmp(mode, "record")) {
renderer.reset(SkNEW(sk_tools::RecordPictureRenderer));
gridSupported = true;
- // undocumented
- } else if (0 == strcmp(mode, "clone")) {
- renderer.reset(sk_tools::CreatePictureCloneRenderer());
} else if (0 == strcmp(mode, "tile") || 0 == strcmp(mode, "pow2tile")
|| 0 == strcmp(mode, "copyTile")) {
useTiles = true;
@@ -170,9 +160,6 @@ sk_tools::PictureRenderer* parseRenderer(SkString& error, PictureTool tool) {
x = y = 4;
}
tiledRenderer.reset(SkNEW_ARGS(sk_tools::CopyTilesRenderer, (x, y)));
- } else if (FLAGS_multi > 1) {
- tiledRenderer.reset(SkNEW_ARGS(sk_tools::MultiCorePictureRenderer,
- (FLAGS_multi)));
} else {
tiledRenderer.reset(SkNEW(sk_tools::TiledPictureRenderer));
}
@@ -230,10 +217,6 @@ sk_tools::PictureRenderer* parseRenderer(SkString& error, PictureTool tool) {
}
} else { // useTiles
- if (FLAGS_multi > 1) {
- error.printf("Multithreaded drawing requires tiled rendering.\n");
- return NULL;
- }
if (FLAGS_pipe) {
if (renderer != NULL) {
error.printf("Pipe is incompatible with other modes.\n");
@@ -270,59 +253,31 @@ sk_tools::PictureRenderer* parseRenderer(SkString& error, PictureTool tool) {
#if SK_SUPPORT_GPU
else if (0 == strcmp(FLAGS_config[0], "gpu")) {
deviceType = sk_tools::PictureRenderer::kGPU_DeviceType;
- if (FLAGS_multi > 1) {
- error.printf("GPU not compatible with multithreaded tiling.\n");
- return NULL;
- }
}
else if (0 == strcmp(FLAGS_config[0], "msaa4")) {
deviceType = sk_tools::PictureRenderer::kGPU_DeviceType;
- if (FLAGS_multi > 1) {
- error.printf("GPU not compatible with multithreaded tiling.\n");
- return NULL;
- }
sampleCount = 4;
}
else if (0 == strcmp(FLAGS_config[0], "msaa16")) {
deviceType = sk_tools::PictureRenderer::kGPU_DeviceType;
- if (FLAGS_multi > 1) {
- error.printf("GPU not compatible with multithreaded tiling.\n");
- return NULL;
- }
sampleCount = 16;
}
else if (0 == strcmp(FLAGS_config[0], "nvprmsaa4")) {
deviceType = sk_tools::PictureRenderer::kNVPR_DeviceType;
- if (FLAGS_multi > 1) {
- error.printf("GPU not compatible with multithreaded tiling.\n");
- return NULL;
- }
sampleCount = 4;
}
else if (0 == strcmp(FLAGS_config[0], "nvprmsaa16")) {
deviceType = sk_tools::PictureRenderer::kNVPR_DeviceType;
- if (FLAGS_multi > 1) {
- error.printf("GPU not compatible with multithreaded tiling.\n");
- return NULL;
- }
sampleCount = 16;
}
#if SK_ANGLE
else if (0 == strcmp(FLAGS_config[0], "angle")) {
deviceType = sk_tools::PictureRenderer::kAngle_DeviceType;
- if (FLAGS_multi > 1) {
- error.printf("Angle not compatible with multithreaded tiling.\n");
- return NULL;
- }
}
#endif
#if SK_MESA
else if (0 == strcmp(FLAGS_config[0], "mesa")) {
deviceType = sk_tools::PictureRenderer::kMesa_DeviceType;
- if (FLAGS_multi > 1) {
- error.printf("Mesa not compatible with multithreaded tiling.\n");
- return NULL;
- }
}
#endif
#endif
diff --git a/tools/bench_pictures_main.cpp b/tools/bench_pictures_main.cpp
index 6073fe9f73..f6cd8e9bd7 100644
--- a/tools/bench_pictures_main.cpp
+++ b/tools/bench_pictures_main.cpp
@@ -42,7 +42,6 @@ DEFINE_string(logFile, "", "Destination for writing log output, in addition to s
DEFINE_bool(logPerIter, false, "Log each repeat timer instead of mean.");
DEFINE_string(jsonLog, "", "Destination for writing JSON data.");
DEFINE_bool(min, false, "Print the minimum times (instead of average).");
-DECLARE_int32(multi);
DECLARE_string(readPath);
DEFINE_int32(repeat, 1, "Set the number of times to repeat each test.");
DEFINE_bool(timeIndividualTiles, false, "Report times for drawing individual tiles, rather than "
@@ -336,10 +335,6 @@ static void setup_benchmark(sk_tools::PictureBenchmark* benchmark) {
}
if (FLAGS_timeIndividualTiles) {
- if (FLAGS_multi > 1) {
- gLogger.logError("Cannot time individual tiles with more than one thread.\n");
- exit(-1);
- }
sk_tools::TiledPictureRenderer* tiledRenderer = renderer->getTiledRenderer();
if (NULL == tiledRenderer) {
gLogger.logError("--timeIndividualTiles requires tiled rendering.\n");
diff --git a/tools/render_pictures_main.cpp b/tools/render_pictures_main.cpp
index 850053cfc6..c2c7875b28 100644
--- a/tools/render_pictures_main.cpp
+++ b/tools/render_pictures_main.cpp
@@ -26,7 +26,6 @@
#include "picture_utils.h"
// Flags used by this file, alphabetically:
-DEFINE_int32(clone, 0, "Clone the picture n times before rendering.");
DECLARE_bool(deferImageDecoding);
DEFINE_int32(maxComponentDiff, 256, "Maximum diff on a component, 0 - 256. Components that differ "
"by more than this amount are considered errors, though all diffs are reported. "
@@ -186,12 +185,6 @@ static bool render_picture_internal(const SkString& inputPath, const SkString* w
SkAutoTUnref<SkPicture> other(recorder.endRecording());
}
- for (int i = 0; i < FLAGS_clone; ++i) {
- SkPicture* clone = picture->clone();
- SkDELETE(picture);
- picture = clone;
- }
-
SkDebugf("drawing... [%i %i] %s\n", picture->width(), picture->height(),
inputPath.c_str());
@@ -424,11 +417,6 @@ int tool_main(int argc, char** argv) {
exit(-1);
}
- if (FLAGS_clone < 0) {
- SkDebugf("--clone must be >= 0. Was %i\n", FLAGS_clone);
- exit(-1);
- }
-
if (FLAGS_writeEncodedImages) {
if (FLAGS_writePath.isEmpty()) {
SkDebugf("--writeEncodedImages requires --writePath\n");