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

Side by Side Diff: dm/DMPipeTask.cpp

Issue 47773002: DM: add --pipe (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: epoger Created 7 years, 1 month 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 | Annotate | Revision Log
« no previous file with comments | « dm/DMPipeTask.h ('k') | dm/README » ('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, false, "If true, check several pipe variants against the refer ence bitmap.");
10
11 namespace DM {
12
13 static uint32_t get_flags(bool crossProcess, bool sharedAddressSpace) {
14 SkASSERT(!(!crossProcess && sharedAddressSpace));
15 uint32_t flags = 0;
16 if (crossProcess) {
17 flags |= SkGPipeWriter::kCrossProcess_Flag;
18 if (sharedAddressSpace) {
19 flags |= SkGPipeWriter::kSharedAddressSpace_Flag;
20 }
21 }
22 return flags;
23 }
24
25 static const char* get_name(const uint32_t flags) {
26 if (flags & SkGPipeWriter::kCrossProcess_Flag &&
27 flags & SkGPipeWriter::kSharedAddressSpace_Flag) {
28 return "cross_process_shared_address_space_pipe";
29 } else if (flags & SkGPipeWriter::kCrossProcess_Flag) {
30 return "cross_process_pipe";
31 } else {
32 return "pipe";
33 }
34 }
35
36 PipeTask::PipeTask(const Task& parent,
37 skiagm::GM* gm,
38 SkBitmap reference,
39 bool crossProcess,
40 bool sharedAddressSpace)
41 : Task(parent)
42 , fFlags(get_flags(crossProcess, sharedAddressSpace))
43 , fName(UnderJoin(parent.name().c_str(), get_name(fFlags)))
44 , fGM(gm)
45 , fReference(reference)
46 {}
47
48 void PipeTask::draw() {
49 SkBitmap bitmap;
50 SetupBitmap(fReference.config(), fGM.get(), &bitmap);
51
52 SkCanvas canvas(bitmap);
53 PipeController pipeController(&canvas, &SkImageDecoder::DecodeMemory);
54 SkGPipeWriter writer;
55
56 SkCanvas* pipeCanvas = writer.startRecording(&pipeController,
57 fFlags,
58 bitmap.width(),
59 bitmap.height());
60 pipeCanvas->concat(fGM->getInitialTransform());
61 fGM->draw(pipeCanvas);
62 writer.endRecording();
63
64 if (!BitmapsEqual(bitmap, fReference)) {
65 this->fail();
66 this->spawnChild(SkNEW_ARGS(WriteTask, (*this, bitmap)));
67 }
68 }
69
70 bool PipeTask::shouldSkip() const {
71 if (!FLAGS_pipe) {
72 return true;
73 }
74 if (fGM->getFlags() & skiagm::GM::kSkipPipe_Flag) {
75 return true;
76 }
77 if (fFlags == SkGPipeWriter::kCrossProcess_Flag &&
78 fGM->getFlags() & skiagm::GM::kSkipPipeCrossProcess_Flag) {
79 return true;
80 }
81 return false;
82 }
83
84 } // namespace DM
OLDNEW
« no previous file with comments | « dm/DMPipeTask.h ('k') | dm/README » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698