Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 #include "DMPipeTask.h" | |
| 2 #include "DMUtil.h" | |
| 3 #include "DMWriteTask.h" | |
| 4 | |
| 5 #include "SamplePipeControllers.h" | |
| 6 #include "SkCommandLineFlags.h" | |
| 7 #include "SkGPipe.h" | |
| 8 | |
| 9 DEFINE_bool(pipe, false, "If true, check several pipe variants against the refer ence bitmap."); | |
| 10 | |
| 11 namespace DM { | |
| 12 | |
| 13 static const char* kNames[] = { | |
|
epoger
2013/10/28 17:42:15
I see that the indices of these correspond to the
mtklein
2013/10/28 19:03:41
Added get_name().
| |
| 14 "pipe", | |
| 15 "cross_process_pipe", | |
| 16 "shared_address_space_pipe", | |
| 17 "cross_process_shared_address_space_pipe", | |
| 18 }; | |
| 19 | |
| 20 static uint32_t get_flags(bool crossProcess, bool sharedAddressSpace) { | |
| 21 uint32_t flags = 0; | |
| 22 if (crossProcess) { | |
| 23 flags |= SkGPipeWriter::kCrossProcess_Flag; | |
| 24 } | |
| 25 if (sharedAddressSpace) { | |
| 26 flags |= SkGPipeWriter::kSharedAddressSpace_Flag; | |
| 27 } | |
| 28 return flags; | |
| 29 } | |
| 30 | |
| 31 PipeTask::PipeTask(const Task& parent, | |
| 32 skiagm::GM* gm, | |
| 33 SkBitmap reference, | |
| 34 bool crossProcess, | |
| 35 bool sharedAddressSpace) | |
| 36 : Task(parent) | |
| 37 , fFlags(get_flags(crossProcess, sharedAddressSpace)) | |
| 38 , fName(UnderJoin(parent.name().c_str(), kNames[fFlags])) | |
| 39 , fGM(gm) | |
| 40 , fReference(reference) | |
| 41 {} | |
| 42 | |
| 43 void PipeTask::draw() { | |
| 44 SkBitmap bitmap; | |
| 45 SetupBitmap(fReference.config(), fGM.get(), &bitmap); | |
| 46 | |
| 47 SkCanvas canvas(bitmap); | |
| 48 PipeController pipeController(&canvas, &SkImageDecoder::DecodeMemory); | |
| 49 SkGPipeWriter writer; | |
| 50 | |
| 51 SkCanvas* pipeCanvas = writer.startRecording(&pipeController, | |
| 52 fFlags, | |
| 53 bitmap.width(), | |
| 54 bitmap.height()); | |
| 55 pipeCanvas->concat(fGM->getInitialTransform()); | |
| 56 fGM->draw(pipeCanvas); | |
| 57 writer.endRecording(); | |
| 58 | |
| 59 if (!BitmapsEqual(bitmap, fReference)) { | |
| 60 this->fail(); | |
| 61 this->spawnChild(SkNEW_ARGS(WriteTask, (*this, bitmap))); | |
| 62 } | |
| 63 } | |
| 64 | |
| 65 bool PipeTask::shouldSkip() const { | |
| 66 if (!FLAGS_pipe) { | |
| 67 return true; | |
| 68 } | |
| 69 if (fGM->getFlags() & skiagm::GM::kSkipPipe_Flag) { | |
| 70 return true; | |
| 71 } | |
| 72 if (fFlags == SkGPipeWriter::kCrossProcess_Flag && | |
| 73 fGM->getFlags() & skiagm::GM::kSkipPipeCrossProcess_Flag) { | |
| 74 return true; | |
| 75 } | |
| 76 return false; | |
| 77 } | |
| 78 | |
| 79 } // namespace DM | |
| OLD | NEW |