Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1266)

Side by Side Diff: dm/DMPipeTask.cpp

Issue 788243008: Sketch DM refactor. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: better failure messages, disable a few things temporarily to try to go green Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « dm/DMPipeTask.h ('k') | dm/DMQuiltTask.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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, true, "If true, check several pipe variants against the refere nce bitmap.");
10
11 namespace DM {
12
13 static uint32_t get_flags(PipeTask::Mode mode) {
14 uint32_t flags = 0;
15 if (mode != PipeTask::kInProcess_Mode) {
16 flags |= SkGPipeWriter::kCrossProcess_Flag;
17 }
18 if (mode == PipeTask::kSharedAddress_Mode) {
19 flags |= SkGPipeWriter::kSharedAddressSpace_Flag;
20 }
21 return flags;
22 }
23
24 static const char* get_name(const uint32_t flags) {
25 if (flags & SkGPipeWriter::kCrossProcess_Flag &&
26 flags & SkGPipeWriter::kSharedAddressSpace_Flag) {
27 return "shared-address-space-pipe";
28 } else if (flags & SkGPipeWriter::kCrossProcess_Flag) {
29 return "cross-process-pipe";
30 } else {
31 return "pipe";
32 }
33 }
34
35 PipeTask::PipeTask(const Task& parent,
36 skiagm::GM* gm,
37 SkBitmap reference,
38 Mode mode)
39 : CpuTask(parent)
40 , fFlags(get_flags(mode))
41 , fName(UnderJoin(parent.name().c_str(), get_name(fFlags)))
42 , fGM(gm)
43 , fReference(reference)
44 {}
45
46 void PipeTask::draw() {
47 SkBitmap bitmap;
48 AllocatePixels(fReference, &bitmap);
49
50 SkCanvas canvas(bitmap);
51 PipeController pipeController(&canvas, &SkImageDecoder::DecodeMemory);
52 SkGPipeWriter writer;
53
54 SkCanvas* pipeCanvas = writer.startRecording(&pipeController,
55 fFlags,
56 bitmap.width(),
57 bitmap.height());
58 CanvasPreflight(pipeCanvas);
59 pipeCanvas->concat(fGM->getInitialTransform());
60 fGM->draw(pipeCanvas);
61 writer.endRecording();
62
63 if (!BitmapsEqual(bitmap, fReference)) {
64 this->fail();
65 this->spawnChild(SkNEW_ARGS(WriteTask, (*this, "GM", bitmap)));
66 }
67 }
68
69 bool PipeTask::shouldSkip() const {
70 if (!FLAGS_pipe) {
71 return true;
72 }
73 if (fGM->getFlags() & skiagm::GM::kSkipPipe_Flag) {
74 return true;
75 }
76 if (fFlags == SkGPipeWriter::kCrossProcess_Flag &&
77 fGM->getFlags() & skiagm::GM::kSkipPipeCrossProcess_Flag) {
78 return true;
79 }
80 return false;
81 }
82
83 } // namespace DM
OLDNEW
« no previous file with comments | « dm/DMPipeTask.h ('k') | dm/DMQuiltTask.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698