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
85 lines
2.4 KiB
C++
85 lines
2.4 KiB
C++
#include "DMPipeTask.h"
|
|
#include "DMUtil.h"
|
|
#include "DMWriteTask.h"
|
|
|
|
#include "SamplePipeControllers.h"
|
|
#include "SkCommandLineFlags.h"
|
|
#include "SkGPipe.h"
|
|
|
|
DEFINE_bool(pipe, true, "If true, check several pipe variants against the reference bitmap.");
|
|
|
|
namespace DM {
|
|
|
|
static uint32_t get_flags(bool crossProcess, bool sharedAddressSpace) {
|
|
SkASSERT(!(!crossProcess && sharedAddressSpace));
|
|
uint32_t flags = 0;
|
|
if (crossProcess) {
|
|
flags |= SkGPipeWriter::kCrossProcess_Flag;
|
|
if (sharedAddressSpace) {
|
|
flags |= SkGPipeWriter::kSharedAddressSpace_Flag;
|
|
}
|
|
}
|
|
return flags;
|
|
}
|
|
|
|
static const char* get_name(const uint32_t flags) {
|
|
if (flags & SkGPipeWriter::kCrossProcess_Flag &&
|
|
flags & SkGPipeWriter::kSharedAddressSpace_Flag) {
|
|
return "cross_process_shared_address_space_pipe";
|
|
} else if (flags & SkGPipeWriter::kCrossProcess_Flag) {
|
|
return "cross_process_pipe";
|
|
} else {
|
|
return "pipe";
|
|
}
|
|
}
|
|
|
|
PipeTask::PipeTask(const Task& parent,
|
|
skiagm::GM* gm,
|
|
SkBitmap reference,
|
|
bool crossProcess,
|
|
bool sharedAddressSpace)
|
|
: CpuTask(parent)
|
|
, fFlags(get_flags(crossProcess, sharedAddressSpace))
|
|
, fName(UnderJoin(parent.name().c_str(), get_name(fFlags)))
|
|
, fGM(gm)
|
|
, fReference(reference)
|
|
{}
|
|
|
|
void PipeTask::draw() {
|
|
SkBitmap bitmap;
|
|
SetupBitmap(fReference.colorType(), fGM.get(), &bitmap);
|
|
|
|
SkCanvas canvas(bitmap);
|
|
PipeController pipeController(&canvas, &SkImageDecoder::DecodeMemory);
|
|
SkGPipeWriter writer;
|
|
|
|
SkCanvas* pipeCanvas = writer.startRecording(&pipeController,
|
|
fFlags,
|
|
bitmap.width(),
|
|
bitmap.height());
|
|
pipeCanvas->concat(fGM->getInitialTransform());
|
|
fGM->draw(pipeCanvas);
|
|
writer.endRecording();
|
|
|
|
if (!BitmapsEqual(bitmap, fReference)) {
|
|
this->fail();
|
|
this->spawnChild(SkNEW_ARGS(WriteTask, (*this, bitmap)));
|
|
}
|
|
}
|
|
|
|
bool PipeTask::shouldSkip() const {
|
|
if (!FLAGS_pipe) {
|
|
return true;
|
|
}
|
|
if (fGM->getFlags() & skiagm::GM::kSkipPipe_Flag) {
|
|
return true;
|
|
}
|
|
if (fFlags == SkGPipeWriter::kCrossProcess_Flag &&
|
|
fGM->getFlags() & skiagm::GM::kSkipPipeCrossProcess_Flag) {
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
} // namespace DM
|