ef57b7e653
The main meat of things is in SkThreadPool. We can now give SkThreadPool a type for each thread to create and destroy on its local stack. It's TLS without going through SkTLS. I've split the DM tasks into CpuTasks that run on threads with no TLS, and GpuTasks that run on threads with a thread local GrContextFactory. The old CpuTask and GpuTask have been renamed to CpuGMTask and GpuGMTask. Upshot: default run of out/Debug/dm goes from ~45 seconds to ~20 seconds. BUG=skia: R=bsalomon@google.com, mtklein@google.com, reed@google.com Author: mtklein@chromium.org Review URL: https://codereview.chromium.org/179233005 git-svn-id: http://skia.googlecode.com/svn/trunk@13632 2bbb7eff-a529-9590-31e7-b0007b416f81
57 lines
1.7 KiB
C++
57 lines
1.7 KiB
C++
#include "DMGpuGMTask.h"
|
|
|
|
#include "DMExpectationsTask.h"
|
|
#include "DMUtil.h"
|
|
#include "DMWriteTask.h"
|
|
#include "SkCommandLineFlags.h"
|
|
#include "SkSurface.h"
|
|
#include "SkTLS.h"
|
|
|
|
namespace DM {
|
|
|
|
GpuGMTask::GpuGMTask(const char* config,
|
|
Reporter* reporter,
|
|
TaskRunner* taskRunner,
|
|
const Expectations& expectations,
|
|
skiagm::GMRegistry::Factory gmFactory,
|
|
GrContextFactory::GLContextType contextType,
|
|
int sampleCount)
|
|
: GpuTask(reporter, taskRunner)
|
|
, fGM(gmFactory(NULL))
|
|
, fName(UnderJoin(fGM->getName(), config))
|
|
, fExpectations(expectations)
|
|
, fContextType(contextType)
|
|
, fSampleCount(sampleCount)
|
|
{}
|
|
|
|
void GpuGMTask::draw(GrContextFactory* grFactory) {
|
|
SkImageInfo info = SkImageInfo::Make(SkScalarCeilToInt(fGM->width()),
|
|
SkScalarCeilToInt(fGM->height()),
|
|
kPMColor_SkColorType,
|
|
kPremul_SkAlphaType);
|
|
SkAutoTUnref<SkSurface> surface(SkSurface::NewRenderTarget(
|
|
grFactory->get(fContextType), info, fSampleCount));
|
|
SkCanvas* canvas = surface->getCanvas();
|
|
|
|
canvas->concat(fGM->getInitialTransform());
|
|
fGM->draw(canvas);
|
|
canvas->flush();
|
|
|
|
SkBitmap bitmap;
|
|
bitmap.setConfig(info);
|
|
canvas->readPixels(&bitmap, 0, 0);
|
|
|
|
#if GR_CACHE_STATS
|
|
gr->printCacheStats();
|
|
#endif
|
|
|
|
this->spawnChild(SkNEW_ARGS(ExpectationsTask, (*this, fExpectations, bitmap)));
|
|
this->spawnChild(SkNEW_ARGS(WriteTask, (*this, bitmap)));
|
|
}
|
|
|
|
bool GpuGMTask::shouldSkip() const {
|
|
return SkToBool(fGM->getFlags() & skiagm::GM::kSkipGPU_Flag);
|
|
}
|
|
|
|
} // namespace DM
|