2012-11-06 21:29:16 +00:00
|
|
|
/*
|
2012-07-26 17:27:57 +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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef PictureRenderer_DEFINED
|
|
|
|
#define PictureRenderer_DEFINED
|
2012-11-02 21:28:12 +00:00
|
|
|
|
2013-03-04 16:41:06 +00:00
|
|
|
#include "SkCanvas.h"
|
2012-11-02 21:28:12 +00:00
|
|
|
#include "SkCountdown.h"
|
2012-11-06 21:26:13 +00:00
|
|
|
#include "SkDrawFilter.h"
|
2013-12-13 20:52:36 +00:00
|
|
|
#include "SkJSONCPP.h"
|
2012-08-23 20:53:25 +00:00
|
|
|
#include "SkMath.h"
|
2012-11-06 22:14:54 +00:00
|
|
|
#include "SkPaint.h"
|
2012-09-07 15:21:18 +00:00
|
|
|
#include "SkPicture.h"
|
2014-04-18 18:04:41 +00:00
|
|
|
#include "SkPictureRecorder.h"
|
2012-09-18 14:32:35 +00:00
|
|
|
#include "SkRect.h"
|
2012-07-26 17:27:57 +00:00
|
|
|
#include "SkRefCnt.h"
|
2012-11-02 21:28:12 +00:00
|
|
|
#include "SkRunnable.h"
|
2012-09-07 15:21:18 +00:00
|
|
|
#include "SkString.h"
|
2012-11-02 21:28:12 +00:00
|
|
|
#include "SkTDArray.h"
|
|
|
|
#include "SkThreadPool.h"
|
|
|
|
#include "SkTypes.h"
|
2012-07-26 17:27:57 +00:00
|
|
|
|
2012-08-20 15:03:33 +00:00
|
|
|
#if SK_SUPPORT_GPU
|
|
|
|
#include "GrContextFactory.h"
|
|
|
|
#include "GrContext.h"
|
|
|
|
#endif
|
|
|
|
|
2012-07-26 17:27:57 +00:00
|
|
|
class SkBitmap;
|
|
|
|
class SkCanvas;
|
2013-02-28 20:16:25 +00:00
|
|
|
class SkGLContextHelper;
|
2012-11-02 21:28:12 +00:00
|
|
|
class SkThread;
|
2012-07-26 17:27:57 +00:00
|
|
|
|
|
|
|
namespace sk_tools {
|
|
|
|
|
Provide an option to bench drawing individual tiles in bench_pictures.
Provides output like the following:
running bench [1236 12045] androidpolice.skp
tile_256x256: tile [0,0] out of [5,48]: msecs = 1.00
tile_256x256: tile [1,0] out of [5,48]: msecs = 1.50
tile_256x256: tile [2,0] out of [5,48]: msecs = 1.00
tile_256x256: tile [3,0] out of [5,48]: msecs = 1.50
tile_256x256: tile [4,0] out of [5,48]: msecs = 2.50
tile_256x256: tile [0,1] out of [5,48]: msecs = 2.00
tile_256x256: tile [1,1] out of [5,48]: msecs = 3.50
tile_256x256: tile [2,1] out of [5,48]: msecs = 3.50
tile_256x256: tile [3,1] out of [5,48]: msecs = 6.00
tile_256x256: tile [4,1] out of [5,48]: msecs = 2.50
tile_256x256: tile [0,2] out of [5,48]: msecs = 2.00
BUG=https://code.google.com/p/skia/issues/detail?id=1016
Review URL: https://codereview.appspot.com/6937047
git-svn-id: http://skia.googlecode.com/svn/trunk@6805 2bbb7eff-a529-9590-31e7-b0007b416f81
2012-12-13 22:09:28 +00:00
|
|
|
class TiledPictureRenderer;
|
|
|
|
|
2013-12-13 20:52:36 +00:00
|
|
|
/**
|
|
|
|
* Class for collecting image results (checksums) as we go.
|
|
|
|
*/
|
|
|
|
class ImageResultsSummary {
|
|
|
|
public:
|
2014-03-19 17:26:07 +00:00
|
|
|
/**
|
2014-04-10 15:39:02 +00:00
|
|
|
* Adds this image to the summary of results.
|
2014-03-19 17:26:07 +00:00
|
|
|
*
|
2014-04-10 15:39:02 +00:00
|
|
|
* @param sourceName name of the source file that generated this result
|
|
|
|
* @param fileName relative path to the image output file on local disk
|
2014-03-19 17:26:07 +00:00
|
|
|
* @param hash hash to store
|
2014-04-10 15:39:02 +00:00
|
|
|
* @param tileNumber if not NULL, ptr to tile number
|
2014-03-19 17:26:07 +00:00
|
|
|
*/
|
2014-04-10 15:39:02 +00:00
|
|
|
void add(const char *sourceName, const char *fileName, uint64_t hash,
|
|
|
|
const int *tileNumber=NULL);
|
2014-03-19 17:26:07 +00:00
|
|
|
|
2013-12-13 20:52:36 +00:00
|
|
|
/**
|
2014-04-10 15:39:02 +00:00
|
|
|
* Adds this image to the summary of results.
|
2013-12-13 20:52:36 +00:00
|
|
|
*
|
2014-04-10 15:39:02 +00:00
|
|
|
* @param sourceName name of the source file that generated this result
|
|
|
|
* @param fileName relative path to the image output file on local disk
|
2013-12-13 20:52:36 +00:00
|
|
|
* @param bitmap bitmap to store the hash of
|
2014-04-10 15:39:02 +00:00
|
|
|
* @param tileNumber if not NULL, ptr to tile number
|
2013-12-13 20:52:36 +00:00
|
|
|
*/
|
2014-04-10 15:39:02 +00:00
|
|
|
void add(const char *sourceName, const char *fileName, const SkBitmap& bitmap,
|
|
|
|
const int *tileNumber=NULL);
|
2013-12-13 20:52:36 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Writes the summary (as constructed so far) to a file.
|
|
|
|
*
|
|
|
|
* @param filename path to write the summary to
|
|
|
|
*/
|
|
|
|
void writeToFile(const char *filename);
|
|
|
|
|
|
|
|
private:
|
2014-04-10 15:39:02 +00:00
|
|
|
Json::Value fActualResults;
|
2013-12-13 20:52:36 +00:00
|
|
|
};
|
|
|
|
|
2012-07-26 17:27:57 +00:00
|
|
|
class PictureRenderer : public SkRefCnt {
|
Provide an option to bench drawing individual tiles in bench_pictures.
Provides output like the following:
running bench [1236 12045] androidpolice.skp
tile_256x256: tile [0,0] out of [5,48]: msecs = 1.00
tile_256x256: tile [1,0] out of [5,48]: msecs = 1.50
tile_256x256: tile [2,0] out of [5,48]: msecs = 1.00
tile_256x256: tile [3,0] out of [5,48]: msecs = 1.50
tile_256x256: tile [4,0] out of [5,48]: msecs = 2.50
tile_256x256: tile [0,1] out of [5,48]: msecs = 2.00
tile_256x256: tile [1,1] out of [5,48]: msecs = 3.50
tile_256x256: tile [2,1] out of [5,48]: msecs = 3.50
tile_256x256: tile [3,1] out of [5,48]: msecs = 6.00
tile_256x256: tile [4,1] out of [5,48]: msecs = 2.50
tile_256x256: tile [0,2] out of [5,48]: msecs = 2.00
BUG=https://code.google.com/p/skia/issues/detail?id=1016
Review URL: https://codereview.appspot.com/6937047
git-svn-id: http://skia.googlecode.com/svn/trunk@6805 2bbb7eff-a529-9590-31e7-b0007b416f81
2012-12-13 22:09:28 +00:00
|
|
|
|
2012-07-26 17:27:57 +00:00
|
|
|
public:
|
2012-08-20 15:04:04 +00:00
|
|
|
enum SkDeviceTypes {
|
2013-02-08 19:38:21 +00:00
|
|
|
#if SK_ANGLE
|
|
|
|
kAngle_DeviceType,
|
2014-01-06 18:37:24 +00:00
|
|
|
#endif
|
|
|
|
#if SK_MESA
|
|
|
|
kMesa_DeviceType,
|
2013-02-08 19:38:21 +00:00
|
|
|
#endif
|
2012-08-20 15:04:04 +00:00
|
|
|
kBitmap_DeviceType,
|
|
|
|
#if SK_SUPPORT_GPU
|
2013-02-08 19:38:21 +00:00
|
|
|
kGPU_DeviceType,
|
2014-03-07 18:41:14 +00:00
|
|
|
kNVPR_DeviceType,
|
2012-08-20 15:04:04 +00:00
|
|
|
#endif
|
|
|
|
};
|
|
|
|
|
2012-11-02 18:11:49 +00:00
|
|
|
enum BBoxHierarchyType {
|
|
|
|
kNone_BBoxHierarchyType = 0,
|
Initial QuadTree implementation
In an effort to find a faster bounding box hierarchy than the R-Tree, a QuadTree has been implemented here.
For now, the QuadTree construction is generally faster than the R-Tree and the queries are a bit slower, so overall, SKP local tests showed QuadTree performance similar to the R-Tree performance.
Tests and bench are included in this cl.
At this point, I'd like to be able to commit this in order to more easily use the bots to test multiple configurations and a larger number of SKPs. The R-Tree BBH is still used by default so this change shouldn't affect chromium.
BUG=skia:
R=junov@chromium.org, junov@google.com, senorblanco@google.com, senorblanco@chromium.org, reed@google.com, sugoi@google.com, fmalita@google.com
Author: sugoi@chromium.org
Review URL: https://codereview.chromium.org/131343011
git-svn-id: http://skia.googlecode.com/svn/trunk@13282 2bbb7eff-a529-9590-31e7-b0007b416f81
2014-02-03 18:08:33 +00:00
|
|
|
kQuadTree_BBoxHierarchyType,
|
2012-11-02 18:11:49 +00:00
|
|
|
kRTree_BBoxHierarchyType,
|
2012-11-06 18:58:43 +00:00
|
|
|
kTileGrid_BBoxHierarchyType,
|
2014-03-11 17:27:07 +00:00
|
|
|
|
|
|
|
kLast_BBoxHierarchyType = kTileGrid_BBoxHierarchyType,
|
2012-11-02 18:11:49 +00:00
|
|
|
};
|
|
|
|
|
2012-11-06 21:26:13 +00:00
|
|
|
// this uses SkPaint::Flags as a base and adds additional flags
|
|
|
|
enum DrawFilterFlags {
|
|
|
|
kNone_DrawFilterFlag = 0,
|
2013-05-22 14:03:45 +00:00
|
|
|
kHinting_DrawFilterFlag = 0x10000, // toggles between no hinting and normal hinting
|
|
|
|
kSlightHinting_DrawFilterFlag = 0x20000, // toggles between slight and normal hinting
|
|
|
|
kAAClip_DrawFilterFlag = 0x40000, // toggles between soft and hard clip
|
2013-07-09 14:13:04 +00:00
|
|
|
kMaskFilter_DrawFilterFlag = 0x80000, // toggles on/off mask filters (e.g., blurs)
|
2012-11-06 21:26:13 +00:00
|
|
|
};
|
|
|
|
|
2013-07-03 15:34:35 +00:00
|
|
|
SK_COMPILE_ASSERT(!(kMaskFilter_DrawFilterFlag & SkPaint::kAllFlags), maskfilter_flag_must_be_greater);
|
2012-11-06 21:26:13 +00:00
|
|
|
SK_COMPILE_ASSERT(!(kHinting_DrawFilterFlag & SkPaint::kAllFlags),
|
|
|
|
hinting_flag_must_be_greater);
|
|
|
|
SK_COMPILE_ASSERT(!(kSlightHinting_DrawFilterFlag & SkPaint::kAllFlags),
|
|
|
|
slight_hinting_flag_must_be_greater);
|
|
|
|
|
2012-11-02 21:28:12 +00:00
|
|
|
/**
|
|
|
|
* Called with each new SkPicture to render.
|
2014-03-19 17:26:07 +00:00
|
|
|
*
|
|
|
|
* @param pict The SkPicture to render.
|
|
|
|
* @param outputDir The output directory within which this renderer should write files,
|
|
|
|
* or NULL if this renderer should not write files at all.
|
|
|
|
* @param inputFilename The name of the input file we are rendering.
|
|
|
|
* @param useChecksumBasedFilenames Whether to use checksum-based filenames when writing
|
|
|
|
* bitmap images to disk.
|
2012-11-02 21:28:12 +00:00
|
|
|
*/
|
2014-03-19 17:26:07 +00:00
|
|
|
virtual void init(SkPicture* pict, const SkString* outputDir,
|
|
|
|
const SkString* inputFilename, bool useChecksumBasedFilenames);
|
2012-09-07 15:21:18 +00:00
|
|
|
|
2012-12-13 21:40:48 +00:00
|
|
|
/**
|
|
|
|
* Set the viewport so that only the portion listed gets drawn.
|
|
|
|
*/
|
|
|
|
void setViewport(SkISize size) { fViewport = size; }
|
|
|
|
|
2012-12-17 19:25:54 +00:00
|
|
|
/**
|
|
|
|
* Set the scale factor at which draw the picture.
|
|
|
|
*/
|
|
|
|
void setScaleFactor(SkScalar scale) { fScaleFactor = scale; }
|
|
|
|
|
2012-09-07 15:21:18 +00:00
|
|
|
/**
|
|
|
|
* Perform any setup that should done prior to each iteration of render() which should not be
|
|
|
|
* timed.
|
|
|
|
*/
|
|
|
|
virtual void setup() {}
|
|
|
|
|
|
|
|
/**
|
2014-03-19 17:26:07 +00:00
|
|
|
* Perform the work. If this is being called within the context of bench_pictures,
|
|
|
|
* this is the step that will be timed.
|
|
|
|
*
|
|
|
|
* Typically "the work" is rendering an SkPicture into a bitmap, but in some subclasses
|
|
|
|
* it is recording the source SkPicture into another SkPicture.
|
|
|
|
*
|
|
|
|
* If fOutputDir has been specified, the result of the work will be written to that dir.
|
|
|
|
*
|
|
|
|
* @param out If non-null, the implementing subclass MAY allocate an SkBitmap, copy the
|
|
|
|
* output image into it, and return it here. (Some subclasses ignore this parameter)
|
|
|
|
* @return bool True if rendering succeeded and, if fOutputDir had been specified, the output
|
|
|
|
* was successfully written to a file.
|
2012-09-07 15:21:18 +00:00
|
|
|
*/
|
2014-03-19 17:26:07 +00:00
|
|
|
virtual bool render(SkBitmap** out = NULL) = 0;
|
2012-09-07 15:21:18 +00:00
|
|
|
|
2012-11-02 21:28:12 +00:00
|
|
|
/**
|
|
|
|
* Called once finished with a particular SkPicture, before calling init again, and before
|
|
|
|
* being done with this Renderer.
|
|
|
|
*/
|
2012-08-07 17:11:33 +00:00
|
|
|
virtual void end();
|
2012-11-02 21:28:12 +00:00
|
|
|
|
Provide an option to bench drawing individual tiles in bench_pictures.
Provides output like the following:
running bench [1236 12045] androidpolice.skp
tile_256x256: tile [0,0] out of [5,48]: msecs = 1.00
tile_256x256: tile [1,0] out of [5,48]: msecs = 1.50
tile_256x256: tile [2,0] out of [5,48]: msecs = 1.00
tile_256x256: tile [3,0] out of [5,48]: msecs = 1.50
tile_256x256: tile [4,0] out of [5,48]: msecs = 2.50
tile_256x256: tile [0,1] out of [5,48]: msecs = 2.00
tile_256x256: tile [1,1] out of [5,48]: msecs = 3.50
tile_256x256: tile [2,1] out of [5,48]: msecs = 3.50
tile_256x256: tile [3,1] out of [5,48]: msecs = 6.00
tile_256x256: tile [4,1] out of [5,48]: msecs = 2.50
tile_256x256: tile [0,2] out of [5,48]: msecs = 2.00
BUG=https://code.google.com/p/skia/issues/detail?id=1016
Review URL: https://codereview.appspot.com/6937047
git-svn-id: http://skia.googlecode.com/svn/trunk@6805 2bbb7eff-a529-9590-31e7-b0007b416f81
2012-12-13 22:09:28 +00:00
|
|
|
/**
|
|
|
|
* If this PictureRenderer is actually a TiledPictureRender, return a pointer to this as a
|
|
|
|
* TiledPictureRender so its methods can be called.
|
|
|
|
*/
|
|
|
|
virtual TiledPictureRenderer* getTiledRenderer() { return NULL; }
|
|
|
|
|
Change the method for timing individual tiles in bench_pictures.
When timing individual tiles in bench_pictures, keep a timer running
across all repeats, and then take the average. The former method of
timing each iteration separately runs into precision errors on some
platforms.
Running on my Mac Pro with OSX 10.8, the cmsecs for the new method
and the old method are roughly the same when checking the CPU time.
When checking the wall time, the old method often gives me 0ms,
while the new method gives me a larger value. I don't think this
can be entirely attributed to rounding though, since on occasion I
see the old method showing a short time period (.05 - .15ms) while
the new method shows .15ms higher (which is in range for the
difference I'm seeing for other tiles where the old method reports
0ms).
Some other changes:
PictureRenderer::resetState now takes a boolean parameter. If called
with false, it will only do a flush, while if called with true, it
will also call finish.
resetState is now called with true everywhere except in between
iterations of drawing the same tile (when timing individual tiles).
render_pictures_main no longer calls resetState directly, since it
already calls end, which calls resetState.
BUG=http://code.google.com/p/skia/issues/detail?id=1066
Review URL: https://codereview.appspot.com/7101060
git-svn-id: http://skia.googlecode.com/svn/trunk@7424 2bbb7eff-a529-9590-31e7-b0007b416f81
2013-01-28 20:40:24 +00:00
|
|
|
/**
|
|
|
|
* Resets the GPU's state. Does nothing if the backing is raster. For a GPU renderer, calls
|
2014-03-11 22:58:00 +00:00
|
|
|
* flush, swapBuffers and, if callFinish is true, finish.
|
Change the method for timing individual tiles in bench_pictures.
When timing individual tiles in bench_pictures, keep a timer running
across all repeats, and then take the average. The former method of
timing each iteration separately runs into precision errors on some
platforms.
Running on my Mac Pro with OSX 10.8, the cmsecs for the new method
and the old method are roughly the same when checking the CPU time.
When checking the wall time, the old method often gives me 0ms,
while the new method gives me a larger value. I don't think this
can be entirely attributed to rounding though, since on occasion I
see the old method showing a short time period (.05 - .15ms) while
the new method shows .15ms higher (which is in range for the
difference I'm seeing for other tiles where the old method reports
0ms).
Some other changes:
PictureRenderer::resetState now takes a boolean parameter. If called
with false, it will only do a flush, while if called with true, it
will also call finish.
resetState is now called with true everywhere except in between
iterations of drawing the same tile (when timing individual tiles).
render_pictures_main no longer calls resetState directly, since it
already calls end, which calls resetState.
BUG=http://code.google.com/p/skia/issues/detail?id=1066
Review URL: https://codereview.appspot.com/7101060
git-svn-id: http://skia.googlecode.com/svn/trunk@7424 2bbb7eff-a529-9590-31e7-b0007b416f81
2013-01-28 20:40:24 +00:00
|
|
|
* @param callFinish Whether to call finish.
|
|
|
|
*/
|
|
|
|
void resetState(bool callFinish);
|
2012-08-07 17:11:33 +00:00
|
|
|
|
2013-12-18 17:25:33 +00:00
|
|
|
/**
|
|
|
|
* Remove all decoded textures from the CPU caches and all uploaded textures
|
|
|
|
* from the GPU.
|
|
|
|
*/
|
|
|
|
void purgeTextures();
|
|
|
|
|
2013-02-08 19:38:21 +00:00
|
|
|
/**
|
|
|
|
* Set the backend type. Returns true on success and false on failure.
|
|
|
|
*/
|
|
|
|
bool setDeviceType(SkDeviceTypes deviceType) {
|
2012-08-20 15:04:04 +00:00
|
|
|
fDeviceType = deviceType;
|
2013-02-08 19:38:21 +00:00
|
|
|
#if SK_SUPPORT_GPU
|
|
|
|
// In case this function is called more than once
|
|
|
|
SkSafeUnref(fGrContext);
|
|
|
|
fGrContext = NULL;
|
|
|
|
// Set to Native so it will have an initial value.
|
|
|
|
GrContextFactory::GLContextType glContextType = GrContextFactory::kNative_GLContextType;
|
|
|
|
#endif
|
|
|
|
switch(deviceType) {
|
|
|
|
case kBitmap_DeviceType:
|
|
|
|
return true;
|
|
|
|
#if SK_SUPPORT_GPU
|
|
|
|
case kGPU_DeviceType:
|
|
|
|
// Already set to GrContextFactory::kNative_GLContextType, above.
|
|
|
|
break;
|
2014-03-07 18:41:14 +00:00
|
|
|
case kNVPR_DeviceType:
|
|
|
|
glContextType = GrContextFactory::kNVPR_GLContextType;
|
|
|
|
break;
|
2013-02-08 19:38:21 +00:00
|
|
|
#if SK_ANGLE
|
|
|
|
case kAngle_DeviceType:
|
|
|
|
glContextType = GrContextFactory::kANGLE_GLContextType;
|
|
|
|
break;
|
|
|
|
#endif
|
2014-01-06 18:37:24 +00:00
|
|
|
#if SK_MESA
|
|
|
|
case kMesa_DeviceType:
|
|
|
|
glContextType = GrContextFactory::kMESA_GLContextType;
|
|
|
|
break;
|
|
|
|
#endif
|
2013-02-08 19:38:21 +00:00
|
|
|
#endif
|
|
|
|
default:
|
|
|
|
// Invalid device type.
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
#if SK_SUPPORT_GPU
|
|
|
|
fGrContext = fGrContextFactory.get(glContextType);
|
|
|
|
if (NULL == fGrContext) {
|
|
|
|
return false;
|
|
|
|
} else {
|
|
|
|
fGrContext->ref();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
#endif
|
2012-08-20 15:03:41 +00:00
|
|
|
}
|
|
|
|
|
2013-05-02 12:39:37 +00:00
|
|
|
#if SK_SUPPORT_GPU
|
|
|
|
void setSampleCount(int sampleCount) {
|
|
|
|
fSampleCount = sampleCount;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2012-11-07 16:42:17 +00:00
|
|
|
void setDrawFilters(DrawFilterFlags const * const filters, const SkString& configName) {
|
|
|
|
memcpy(fDrawFilters, filters, sizeof(fDrawFilters));
|
2012-11-06 21:26:13 +00:00
|
|
|
fDrawFiltersConfig = configName;
|
|
|
|
}
|
|
|
|
|
2012-11-02 18:11:49 +00:00
|
|
|
void setBBoxHierarchyType(BBoxHierarchyType bbhType) {
|
|
|
|
fBBoxHierarchyType = bbhType;
|
|
|
|
}
|
|
|
|
|
2013-03-13 17:27:16 +00:00
|
|
|
BBoxHierarchyType getBBoxHierarchyType() { return fBBoxHierarchyType; }
|
|
|
|
|
2012-11-06 18:58:43 +00:00
|
|
|
void setGridSize(int width, int height) {
|
2013-02-27 18:35:16 +00:00
|
|
|
fGridInfo.fTileInterval.set(width, height);
|
2012-11-06 18:58:43 +00:00
|
|
|
}
|
|
|
|
|
2013-12-13 20:52:36 +00:00
|
|
|
void setJsonSummaryPtr(ImageResultsSummary* jsonSummaryPtr) {
|
|
|
|
fJsonSummaryPtr = jsonSummaryPtr;
|
|
|
|
}
|
|
|
|
|
2012-08-20 15:03:41 +00:00
|
|
|
bool isUsingBitmapDevice() {
|
2012-08-20 15:03:44 +00:00
|
|
|
return kBitmap_DeviceType == fDeviceType;
|
2012-08-20 15:03:29 +00:00
|
|
|
}
|
|
|
|
|
2012-09-07 15:21:18 +00:00
|
|
|
virtual SkString getPerIterTimeFormat() { return SkString("%.2f"); }
|
|
|
|
|
|
|
|
virtual SkString getNormalTimeFormat() { return SkString("%6.2f"); }
|
|
|
|
|
2012-11-02 22:01:26 +00:00
|
|
|
/**
|
|
|
|
* Reports the configuration of this PictureRenderer.
|
|
|
|
*/
|
|
|
|
SkString getConfigName() {
|
|
|
|
SkString config = this->getConfigNameInternal();
|
2012-12-13 22:07:08 +00:00
|
|
|
if (!fViewport.isEmpty()) {
|
|
|
|
config.appendf("_viewport_%ix%i", fViewport.width(), fViewport.height());
|
|
|
|
}
|
2013-12-20 21:49:33 +00:00
|
|
|
if (fScaleFactor != SK_Scalar1) {
|
|
|
|
config.appendf("_scalar_%f", SkScalarToFloat(fScaleFactor));
|
|
|
|
}
|
2012-11-02 22:01:26 +00:00
|
|
|
if (kRTree_BBoxHierarchyType == fBBoxHierarchyType) {
|
|
|
|
config.append("_rtree");
|
Initial QuadTree implementation
In an effort to find a faster bounding box hierarchy than the R-Tree, a QuadTree has been implemented here.
For now, the QuadTree construction is generally faster than the R-Tree and the queries are a bit slower, so overall, SKP local tests showed QuadTree performance similar to the R-Tree performance.
Tests and bench are included in this cl.
At this point, I'd like to be able to commit this in order to more easily use the bots to test multiple configurations and a larger number of SKPs. The R-Tree BBH is still used by default so this change shouldn't affect chromium.
BUG=skia:
R=junov@chromium.org, junov@google.com, senorblanco@google.com, senorblanco@chromium.org, reed@google.com, sugoi@google.com, fmalita@google.com
Author: sugoi@chromium.org
Review URL: https://codereview.chromium.org/131343011
git-svn-id: http://skia.googlecode.com/svn/trunk@13282 2bbb7eff-a529-9590-31e7-b0007b416f81
2014-02-03 18:08:33 +00:00
|
|
|
} else if (kQuadTree_BBoxHierarchyType == fBBoxHierarchyType) {
|
|
|
|
config.append("_quadtree");
|
2012-11-06 18:58:43 +00:00
|
|
|
} else if (kTileGrid_BBoxHierarchyType == fBBoxHierarchyType) {
|
|
|
|
config.append("_grid");
|
2012-11-02 22:01:26 +00:00
|
|
|
}
|
|
|
|
#if SK_SUPPORT_GPU
|
2013-02-13 13:26:13 +00:00
|
|
|
switch (fDeviceType) {
|
2013-02-08 19:38:21 +00:00
|
|
|
case kGPU_DeviceType:
|
2013-05-02 12:39:37 +00:00
|
|
|
if (fSampleCount) {
|
|
|
|
config.appendf("_msaa%d", fSampleCount);
|
|
|
|
} else {
|
|
|
|
config.append("_gpu");
|
|
|
|
}
|
2013-02-08 19:38:21 +00:00
|
|
|
break;
|
2014-03-07 18:41:14 +00:00
|
|
|
case kNVPR_DeviceType:
|
|
|
|
config.appendf("_nvprmsaa%d", fSampleCount);
|
|
|
|
break;
|
2013-02-08 19:38:21 +00:00
|
|
|
#if SK_ANGLE
|
|
|
|
case kAngle_DeviceType:
|
|
|
|
config.append("_angle");
|
|
|
|
break;
|
2014-01-06 18:37:24 +00:00
|
|
|
#endif
|
|
|
|
#if SK_MESA
|
|
|
|
case kMesa_DeviceType:
|
|
|
|
config.append("_mesa");
|
|
|
|
break;
|
2012-11-02 22:01:26 +00:00
|
|
|
#endif
|
2013-02-08 19:38:21 +00:00
|
|
|
default:
|
|
|
|
// Assume that no extra info means bitmap.
|
|
|
|
break;
|
|
|
|
}
|
2013-02-13 13:26:13 +00:00
|
|
|
#endif
|
2012-11-06 21:26:13 +00:00
|
|
|
config.append(fDrawFiltersConfig.c_str());
|
2012-11-02 22:01:26 +00:00
|
|
|
return config;
|
|
|
|
}
|
|
|
|
|
2012-08-20 15:03:29 +00:00
|
|
|
#if SK_SUPPORT_GPU
|
2012-08-20 15:03:41 +00:00
|
|
|
bool isUsingGpuDevice() {
|
2013-02-08 19:38:21 +00:00
|
|
|
switch (fDeviceType) {
|
|
|
|
case kGPU_DeviceType:
|
2014-03-07 18:41:14 +00:00
|
|
|
case kNVPR_DeviceType:
|
2013-02-08 19:38:21 +00:00
|
|
|
// fall through
|
|
|
|
#if SK_ANGLE
|
|
|
|
case kAngle_DeviceType:
|
2014-01-06 18:37:24 +00:00
|
|
|
// fall through
|
|
|
|
#endif
|
|
|
|
#if SK_MESA
|
|
|
|
case kMesa_DeviceType:
|
2013-02-08 19:38:21 +00:00
|
|
|
#endif
|
|
|
|
return true;
|
|
|
|
default:
|
|
|
|
return false;
|
|
|
|
}
|
2012-08-20 15:03:41 +00:00
|
|
|
}
|
2012-08-20 15:03:47 +00:00
|
|
|
|
2013-02-28 20:16:25 +00:00
|
|
|
SkGLContextHelper* getGLContext() {
|
2013-02-08 19:38:21 +00:00
|
|
|
GrContextFactory::GLContextType glContextType
|
|
|
|
= GrContextFactory::kNull_GLContextType;
|
|
|
|
switch(fDeviceType) {
|
|
|
|
case kGPU_DeviceType:
|
|
|
|
glContextType = GrContextFactory::kNative_GLContextType;
|
|
|
|
break;
|
2014-03-07 18:41:14 +00:00
|
|
|
case kNVPR_DeviceType:
|
|
|
|
glContextType = GrContextFactory::kNVPR_GLContextType;
|
|
|
|
break;
|
2013-02-08 19:38:21 +00:00
|
|
|
#if SK_ANGLE
|
|
|
|
case kAngle_DeviceType:
|
|
|
|
glContextType = GrContextFactory::kANGLE_GLContextType;
|
|
|
|
break;
|
2014-01-06 18:37:24 +00:00
|
|
|
#endif
|
|
|
|
#if SK_MESA
|
|
|
|
case kMesa_DeviceType:
|
|
|
|
glContextType = GrContextFactory::kMESA_GLContextType;
|
|
|
|
break;
|
2013-02-08 19:38:21 +00:00
|
|
|
#endif
|
|
|
|
default:
|
|
|
|
return NULL;
|
2012-08-20 15:03:47 +00:00
|
|
|
}
|
2013-02-08 19:38:21 +00:00
|
|
|
return fGrContextFactory.getGLContext(glContextType);
|
2012-08-20 15:03:47 +00:00
|
|
|
}
|
2012-09-13 15:40:37 +00:00
|
|
|
|
|
|
|
GrContext* getGrContext() {
|
|
|
|
return fGrContext;
|
|
|
|
}
|
2012-08-20 15:03:29 +00:00
|
|
|
#endif
|
|
|
|
|
2014-03-16 19:46:36 +00:00
|
|
|
SkCanvas* getCanvas() {
|
|
|
|
return fCanvas;
|
|
|
|
}
|
|
|
|
|
2014-03-31 17:55:12 +00:00
|
|
|
SkPicture* getPicture() {
|
|
|
|
return fPicture;
|
|
|
|
}
|
|
|
|
|
2012-08-20 15:03:36 +00:00
|
|
|
PictureRenderer()
|
2014-04-13 19:09:42 +00:00
|
|
|
: fJsonSummaryPtr(NULL)
|
2012-08-20 15:03:33 +00:00
|
|
|
, fDeviceType(kBitmap_DeviceType)
|
2012-11-02 19:16:22 +00:00
|
|
|
, fBBoxHierarchyType(kNone_BBoxHierarchyType)
|
2013-02-08 21:16:19 +00:00
|
|
|
, fScaleFactor(SK_Scalar1)
|
2012-08-20 15:03:33 +00:00
|
|
|
#if SK_SUPPORT_GPU
|
2013-02-08 19:38:21 +00:00
|
|
|
, fGrContext(NULL)
|
2013-05-02 12:39:37 +00:00
|
|
|
, fSampleCount(0)
|
2012-08-20 15:03:33 +00:00
|
|
|
#endif
|
2012-11-07 16:42:17 +00:00
|
|
|
{
|
2013-03-02 17:45:27 +00:00
|
|
|
fGridInfo.fMargin.setEmpty();
|
|
|
|
fGridInfo.fOffset.setZero();
|
|
|
|
fGridInfo.fTileInterval.set(1, 1);
|
2012-11-07 16:42:17 +00:00
|
|
|
sk_bzero(fDrawFilters, sizeof(fDrawFilters));
|
2012-12-13 21:40:48 +00:00
|
|
|
fViewport.set(0, 0);
|
2012-11-07 16:42:17 +00:00
|
|
|
}
|
2012-08-20 15:03:33 +00:00
|
|
|
|
2013-02-08 19:38:21 +00:00
|
|
|
#if SK_SUPPORT_GPU
|
|
|
|
virtual ~PictureRenderer() {
|
|
|
|
SkSafeUnref(fGrContext);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2012-08-07 17:11:33 +00:00
|
|
|
protected:
|
|
|
|
SkAutoTUnref<SkCanvas> fCanvas;
|
2014-04-13 19:09:42 +00:00
|
|
|
SkAutoTUnref<SkPicture> fPicture;
|
2014-03-19 17:26:07 +00:00
|
|
|
bool fUseChecksumBasedFilenames;
|
2013-12-13 20:52:36 +00:00
|
|
|
ImageResultsSummary* fJsonSummaryPtr;
|
2012-12-13 21:40:48 +00:00
|
|
|
SkDeviceTypes fDeviceType;
|
|
|
|
BBoxHierarchyType fBBoxHierarchyType;
|
|
|
|
DrawFilterFlags fDrawFilters[SkDrawFilter::kTypeCount];
|
|
|
|
SkString fDrawFiltersConfig;
|
2014-03-19 17:26:07 +00:00
|
|
|
SkString fOutputDir;
|
|
|
|
SkString fInputFilename;
|
2014-04-17 23:35:06 +00:00
|
|
|
SkTileGridFactory::TileGridInfo fGridInfo; // used when fBBoxHierarchyType is TileGrid
|
2012-08-20 15:03:33 +00:00
|
|
|
|
2012-12-13 21:40:48 +00:00
|
|
|
void buildBBoxHierarchy();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return the total width that should be drawn. If the viewport width has been set greater than
|
|
|
|
* 0, this will be the minimum of the current SkPicture's width and the viewport's width.
|
|
|
|
*/
|
|
|
|
int getViewWidth();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return the total height that should be drawn. If the viewport height has been set greater
|
|
|
|
* than 0, this will be the minimum of the current SkPicture's height and the viewport's height.
|
|
|
|
*/
|
|
|
|
int getViewHeight();
|
|
|
|
|
2012-12-17 19:25:54 +00:00
|
|
|
/**
|
|
|
|
* Scales the provided canvas to the scale factor set by setScaleFactor.
|
|
|
|
*/
|
|
|
|
void scaleToScaleFactor(SkCanvas*);
|
|
|
|
|
2014-04-17 23:35:06 +00:00
|
|
|
SkBBHFactory* getFactory();
|
2012-12-13 21:40:48 +00:00
|
|
|
uint32_t recordFlags();
|
|
|
|
SkCanvas* setupCanvas();
|
|
|
|
virtual SkCanvas* setupCanvas(int width, int height);
|
|
|
|
|
2014-03-19 17:26:07 +00:00
|
|
|
/**
|
|
|
|
* Copy src to dest; if src==NULL, set dest to empty string.
|
|
|
|
*/
|
|
|
|
static void CopyString(SkString* dest, const SkString* src);
|
|
|
|
|
2012-08-07 17:11:33 +00:00
|
|
|
private:
|
2012-12-13 21:40:48 +00:00
|
|
|
SkISize fViewport;
|
2012-12-17 19:25:54 +00:00
|
|
|
SkScalar fScaleFactor;
|
2013-02-08 19:38:21 +00:00
|
|
|
#if SK_SUPPORT_GPU
|
|
|
|
GrContextFactory fGrContextFactory;
|
|
|
|
GrContext* fGrContext;
|
2013-05-02 12:39:37 +00:00
|
|
|
int fSampleCount;
|
2013-02-08 19:38:21 +00:00
|
|
|
#endif
|
2012-12-13 21:40:48 +00:00
|
|
|
|
2012-11-02 22:01:26 +00:00
|
|
|
virtual SkString getConfigNameInternal() = 0;
|
|
|
|
|
2012-08-07 17:11:33 +00:00
|
|
|
typedef SkRefCnt INHERITED;
|
2012-07-26 17:27:57 +00:00
|
|
|
};
|
|
|
|
|
2012-09-07 15:21:18 +00:00
|
|
|
/**
|
|
|
|
* This class does not do any rendering, but its render function executes recording, which we want
|
|
|
|
* to time.
|
|
|
|
*/
|
|
|
|
class RecordPictureRenderer : public PictureRenderer {
|
2014-03-19 17:26:07 +00:00
|
|
|
virtual bool render(SkBitmap** out = NULL) SK_OVERRIDE;
|
2012-09-07 15:21:18 +00:00
|
|
|
|
|
|
|
virtual SkString getPerIterTimeFormat() SK_OVERRIDE { return SkString("%.4f"); }
|
|
|
|
|
|
|
|
virtual SkString getNormalTimeFormat() SK_OVERRIDE { return SkString("%6.4f"); }
|
2012-11-02 22:01:26 +00:00
|
|
|
|
2012-11-06 16:54:40 +00:00
|
|
|
protected:
|
|
|
|
virtual SkCanvas* setupCanvas(int width, int height) SK_OVERRIDE;
|
|
|
|
|
2012-11-02 22:01:26 +00:00
|
|
|
private:
|
|
|
|
virtual SkString getConfigNameInternal() SK_OVERRIDE;
|
2012-09-07 15:21:18 +00:00
|
|
|
};
|
|
|
|
|
2012-07-26 17:27:57 +00:00
|
|
|
class PipePictureRenderer : public PictureRenderer {
|
2012-08-01 17:53:29 +00:00
|
|
|
public:
|
2014-03-19 17:26:07 +00:00
|
|
|
virtual bool render(SkBitmap** out = NULL) SK_OVERRIDE;
|
2012-08-07 17:11:33 +00:00
|
|
|
|
|
|
|
private:
|
2012-11-02 22:01:26 +00:00
|
|
|
virtual SkString getConfigNameInternal() SK_OVERRIDE;
|
|
|
|
|
2012-08-07 17:11:33 +00:00
|
|
|
typedef PictureRenderer INHERITED;
|
2012-07-26 17:27:57 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class SimplePictureRenderer : public PictureRenderer {
|
2012-08-01 17:53:29 +00:00
|
|
|
public:
|
2014-03-19 17:26:07 +00:00
|
|
|
virtual void init(SkPicture* pict, const SkString* outputDir,
|
|
|
|
const SkString* inputFilename, bool useChecksumBasedFilenames) SK_OVERRIDE;
|
2012-11-02 18:11:49 +00:00
|
|
|
|
2014-03-19 17:26:07 +00:00
|
|
|
virtual bool render(SkBitmap** out = NULL) SK_OVERRIDE;
|
2012-08-07 17:11:33 +00:00
|
|
|
|
|
|
|
private:
|
2012-11-02 22:01:26 +00:00
|
|
|
virtual SkString getConfigNameInternal() SK_OVERRIDE;
|
|
|
|
|
2012-08-07 17:11:33 +00:00
|
|
|
typedef PictureRenderer INHERITED;
|
2012-07-26 17:27:57 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class TiledPictureRenderer : public PictureRenderer {
|
|
|
|
public:
|
|
|
|
TiledPictureRenderer();
|
|
|
|
|
2014-03-19 17:26:07 +00:00
|
|
|
virtual void init(SkPicture* pict, const SkString* outputDir,
|
|
|
|
const SkString* inputFilename, bool useChecksumBasedFilenames) SK_OVERRIDE;
|
2012-09-20 14:54:21 +00:00
|
|
|
|
|
|
|
/**
|
2014-03-19 17:26:07 +00:00
|
|
|
* Renders to tiles, rather than a single canvas.
|
|
|
|
* If fOutputDir was provided, a separate file is
|
2012-09-20 14:54:21 +00:00
|
|
|
* created for each tile, named "path0.png", "path1.png", etc.
|
|
|
|
* Multithreaded mode currently does not support writing to a file.
|
|
|
|
*/
|
2014-03-19 17:26:07 +00:00
|
|
|
virtual bool render(SkBitmap** out = NULL) SK_OVERRIDE;
|
2012-09-20 14:54:21 +00:00
|
|
|
|
2012-08-07 17:11:33 +00:00
|
|
|
virtual void end() SK_OVERRIDE;
|
2012-07-26 17:27:57 +00:00
|
|
|
|
2012-07-27 20:09:26 +00:00
|
|
|
void setTileWidth(int width) {
|
|
|
|
fTileWidth = width;
|
|
|
|
}
|
|
|
|
|
|
|
|
int getTileWidth() const {
|
|
|
|
return fTileWidth;
|
|
|
|
}
|
|
|
|
|
|
|
|
void setTileHeight(int height) {
|
|
|
|
fTileHeight = height;
|
|
|
|
}
|
|
|
|
|
|
|
|
int getTileHeight() const {
|
|
|
|
return fTileHeight;
|
|
|
|
}
|
|
|
|
|
|
|
|
void setTileWidthPercentage(double percentage) {
|
|
|
|
fTileWidthPercentage = percentage;
|
|
|
|
}
|
|
|
|
|
2012-08-01 17:53:29 +00:00
|
|
|
double getTileWidthPercentage() const {
|
2012-07-27 20:09:26 +00:00
|
|
|
return fTileWidthPercentage;
|
|
|
|
}
|
|
|
|
|
|
|
|
void setTileHeightPercentage(double percentage) {
|
|
|
|
fTileHeightPercentage = percentage;
|
|
|
|
}
|
|
|
|
|
2012-08-01 17:53:29 +00:00
|
|
|
double getTileHeightPercentage() const {
|
2012-07-27 20:09:26 +00:00
|
|
|
return fTileHeightPercentage;
|
|
|
|
}
|
|
|
|
|
2012-08-23 20:53:25 +00:00
|
|
|
void setTileMinPowerOf2Width(int width) {
|
|
|
|
SkASSERT(SkIsPow2(width) && width > 0);
|
|
|
|
if (!SkIsPow2(width) || width <= 0) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
fTileMinPowerOf2Width = width;
|
|
|
|
}
|
|
|
|
|
|
|
|
int getTileMinPowerOf2Width() const {
|
|
|
|
return fTileMinPowerOf2Width;
|
|
|
|
}
|
|
|
|
|
Provide an option to bench drawing individual tiles in bench_pictures.
Provides output like the following:
running bench [1236 12045] androidpolice.skp
tile_256x256: tile [0,0] out of [5,48]: msecs = 1.00
tile_256x256: tile [1,0] out of [5,48]: msecs = 1.50
tile_256x256: tile [2,0] out of [5,48]: msecs = 1.00
tile_256x256: tile [3,0] out of [5,48]: msecs = 1.50
tile_256x256: tile [4,0] out of [5,48]: msecs = 2.50
tile_256x256: tile [0,1] out of [5,48]: msecs = 2.00
tile_256x256: tile [1,1] out of [5,48]: msecs = 3.50
tile_256x256: tile [2,1] out of [5,48]: msecs = 3.50
tile_256x256: tile [3,1] out of [5,48]: msecs = 6.00
tile_256x256: tile [4,1] out of [5,48]: msecs = 2.50
tile_256x256: tile [0,2] out of [5,48]: msecs = 2.00
BUG=https://code.google.com/p/skia/issues/detail?id=1016
Review URL: https://codereview.appspot.com/6937047
git-svn-id: http://skia.googlecode.com/svn/trunk@6805 2bbb7eff-a529-9590-31e7-b0007b416f81
2012-12-13 22:09:28 +00:00
|
|
|
virtual TiledPictureRenderer* getTiledRenderer() SK_OVERRIDE { return this; }
|
|
|
|
|
2013-03-04 16:41:06 +00:00
|
|
|
virtual bool supportsTimingIndividualTiles() { return true; }
|
|
|
|
|
Provide an option to bench drawing individual tiles in bench_pictures.
Provides output like the following:
running bench [1236 12045] androidpolice.skp
tile_256x256: tile [0,0] out of [5,48]: msecs = 1.00
tile_256x256: tile [1,0] out of [5,48]: msecs = 1.50
tile_256x256: tile [2,0] out of [5,48]: msecs = 1.00
tile_256x256: tile [3,0] out of [5,48]: msecs = 1.50
tile_256x256: tile [4,0] out of [5,48]: msecs = 2.50
tile_256x256: tile [0,1] out of [5,48]: msecs = 2.00
tile_256x256: tile [1,1] out of [5,48]: msecs = 3.50
tile_256x256: tile [2,1] out of [5,48]: msecs = 3.50
tile_256x256: tile [3,1] out of [5,48]: msecs = 6.00
tile_256x256: tile [4,1] out of [5,48]: msecs = 2.50
tile_256x256: tile [0,2] out of [5,48]: msecs = 2.00
BUG=https://code.google.com/p/skia/issues/detail?id=1016
Review URL: https://codereview.appspot.com/6937047
git-svn-id: http://skia.googlecode.com/svn/trunk@6805 2bbb7eff-a529-9590-31e7-b0007b416f81
2012-12-13 22:09:28 +00:00
|
|
|
/**
|
|
|
|
* Report the number of tiles in the x and y directions. Must not be called before init.
|
|
|
|
* @param x Output parameter identifying the number of tiles in the x direction.
|
|
|
|
* @param y Output parameter identifying the number of tiles in the y direction.
|
|
|
|
* @return True if the tiles have been set up, and x and y are meaningful. If false, x and y are
|
|
|
|
* unmodified.
|
|
|
|
*/
|
|
|
|
bool tileDimensions(int& x, int&y);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Move to the next tile and return its indices. Must be called before calling drawCurrentTile
|
|
|
|
* for the first time.
|
|
|
|
* @param i Output parameter identifying the column of the next tile to be drawn on the next
|
|
|
|
* call to drawNextTile.
|
|
|
|
* @param j Output parameter identifying the row of the next tile to be drawn on the next call
|
|
|
|
* to drawNextTile.
|
|
|
|
* @param True if the tiles have been created and the next tile to be drawn by drawCurrentTile
|
|
|
|
* is within the range of tiles. If false, i and j are unmodified.
|
|
|
|
*/
|
|
|
|
bool nextTile(int& i, int& j);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Render one tile. This will draw the same tile each time it is called until nextTile is
|
|
|
|
* called. The tile rendered will depend on how many calls have been made to nextTile.
|
|
|
|
* It is an error to call this without first calling nextTile, or if nextTile returns false.
|
|
|
|
*/
|
|
|
|
void drawCurrentTile();
|
|
|
|
|
2012-11-02 21:28:12 +00:00
|
|
|
protected:
|
|
|
|
SkTDArray<SkRect> fTileRects;
|
2012-07-26 17:27:57 +00:00
|
|
|
|
2012-11-02 22:01:26 +00:00
|
|
|
virtual SkCanvas* setupCanvas(int width, int height) SK_OVERRIDE;
|
|
|
|
virtual SkString getConfigNameInternal() SK_OVERRIDE;
|
|
|
|
|
2012-07-26 17:27:57 +00:00
|
|
|
private:
|
Provide an option to bench drawing individual tiles in bench_pictures.
Provides output like the following:
running bench [1236 12045] androidpolice.skp
tile_256x256: tile [0,0] out of [5,48]: msecs = 1.00
tile_256x256: tile [1,0] out of [5,48]: msecs = 1.50
tile_256x256: tile [2,0] out of [5,48]: msecs = 1.00
tile_256x256: tile [3,0] out of [5,48]: msecs = 1.50
tile_256x256: tile [4,0] out of [5,48]: msecs = 2.50
tile_256x256: tile [0,1] out of [5,48]: msecs = 2.00
tile_256x256: tile [1,1] out of [5,48]: msecs = 3.50
tile_256x256: tile [2,1] out of [5,48]: msecs = 3.50
tile_256x256: tile [3,1] out of [5,48]: msecs = 6.00
tile_256x256: tile [4,1] out of [5,48]: msecs = 2.50
tile_256x256: tile [0,2] out of [5,48]: msecs = 2.00
BUG=https://code.google.com/p/skia/issues/detail?id=1016
Review URL: https://codereview.appspot.com/6937047
git-svn-id: http://skia.googlecode.com/svn/trunk@6805 2bbb7eff-a529-9590-31e7-b0007b416f81
2012-12-13 22:09:28 +00:00
|
|
|
int fTileWidth;
|
|
|
|
int fTileHeight;
|
|
|
|
double fTileWidthPercentage;
|
|
|
|
double fTileHeightPercentage;
|
|
|
|
int fTileMinPowerOf2Width;
|
|
|
|
|
|
|
|
// These variables are only used for timing individual tiles.
|
|
|
|
// Next tile to draw in fTileRects.
|
|
|
|
int fCurrentTileOffset;
|
|
|
|
// Number of tiles in the x direction.
|
|
|
|
int fTilesX;
|
|
|
|
// Number of tiles in the y direction.
|
|
|
|
int fTilesY;
|
2012-09-20 14:42:33 +00:00
|
|
|
|
2012-08-07 17:11:33 +00:00
|
|
|
void setupTiles();
|
2012-08-23 20:53:25 +00:00
|
|
|
void setupPowerOf2Tiles();
|
2012-08-07 17:11:33 +00:00
|
|
|
|
|
|
|
typedef PictureRenderer INHERITED;
|
2012-07-26 17:27:57 +00:00
|
|
|
};
|
|
|
|
|
2012-11-02 21:28:12 +00:00
|
|
|
class CloneData;
|
|
|
|
|
|
|
|
class MultiCorePictureRenderer : public TiledPictureRenderer {
|
|
|
|
public:
|
|
|
|
explicit MultiCorePictureRenderer(int threadCount);
|
|
|
|
|
|
|
|
~MultiCorePictureRenderer();
|
|
|
|
|
2014-03-19 17:26:07 +00:00
|
|
|
virtual void init(SkPicture* pict, const SkString* outputDir,
|
|
|
|
const SkString* inputFilename, bool useChecksumBasedFilenames) SK_OVERRIDE;
|
2012-11-02 21:28:12 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Behaves like TiledPictureRenderer::render(), only using multiple threads.
|
|
|
|
*/
|
2014-03-19 17:26:07 +00:00
|
|
|
virtual bool render(SkBitmap** out = NULL) SK_OVERRIDE;
|
2012-11-02 21:28:12 +00:00
|
|
|
|
|
|
|
virtual void end() SK_OVERRIDE;
|
|
|
|
|
2013-03-04 16:41:06 +00:00
|
|
|
virtual bool supportsTimingIndividualTiles() SK_OVERRIDE { return false; }
|
|
|
|
|
2012-11-02 21:28:12 +00:00
|
|
|
private:
|
2012-11-02 22:01:26 +00:00
|
|
|
virtual SkString getConfigNameInternal() SK_OVERRIDE;
|
|
|
|
|
2012-11-02 21:28:12 +00:00
|
|
|
const int fNumThreads;
|
|
|
|
SkTDArray<SkCanvas*> fCanvasPool;
|
|
|
|
SkThreadPool fThreadPool;
|
|
|
|
SkPicture* fPictureClones;
|
|
|
|
CloneData** fCloneData;
|
|
|
|
SkCountdown fCountdown;
|
|
|
|
|
|
|
|
typedef TiledPictureRenderer INHERITED;
|
|
|
|
};
|
|
|
|
|
2012-09-07 15:21:18 +00:00
|
|
|
/**
|
|
|
|
* This class does not do any rendering, but its render function executes turning an SkPictureRecord
|
|
|
|
* into an SkPicturePlayback, which we want to time.
|
|
|
|
*/
|
|
|
|
class PlaybackCreationRenderer : public PictureRenderer {
|
|
|
|
public:
|
|
|
|
virtual void setup() SK_OVERRIDE;
|
|
|
|
|
2014-03-19 17:26:07 +00:00
|
|
|
virtual bool render(SkBitmap** out = NULL) SK_OVERRIDE;
|
2012-09-07 15:21:18 +00:00
|
|
|
|
|
|
|
virtual SkString getPerIterTimeFormat() SK_OVERRIDE { return SkString("%.4f"); }
|
|
|
|
|
|
|
|
virtual SkString getNormalTimeFormat() SK_OVERRIDE { return SkString("%6.4f"); }
|
|
|
|
|
|
|
|
private:
|
2014-04-13 19:09:42 +00:00
|
|
|
SkAutoTDelete<SkPictureRecorder> fRecorder;
|
2012-11-02 22:01:26 +00:00
|
|
|
|
|
|
|
virtual SkString getConfigNameInternal() SK_OVERRIDE;
|
|
|
|
|
2012-09-07 15:21:18 +00:00
|
|
|
typedef PictureRenderer INHERITED;
|
|
|
|
};
|
|
|
|
|
2012-11-29 21:00:39 +00:00
|
|
|
extern PictureRenderer* CreateGatherPixelRefsRenderer();
|
2012-12-10 16:05:09 +00:00
|
|
|
extern PictureRenderer* CreatePictureCloneRenderer();
|
2012-11-29 21:00:39 +00:00
|
|
|
|
2012-07-26 17:27:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif // PictureRenderer_DEFINED
|