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

Side by Side Diff: dm/DMWriteTask.cpp

Issue 179233005: DM: make GPU tasks multithreaded again. Big refactor. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: default 1 GPU thread Created 6 years, 9 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/DMWriteTask.h ('k') | gyp/dm.gyp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #include "DMWriteTask.h" 1 #include "DMWriteTask.h"
2 2
3 #include "DMUtil.h" 3 #include "DMUtil.h"
4 #include "SkColorPriv.h" 4 #include "SkColorPriv.h"
5 #include "SkCommandLineFlags.h" 5 #include "SkCommandLineFlags.h"
6 #include "SkImageDecoder.h" 6 #include "SkImageDecoder.h"
7 #include "SkImageEncoder.h" 7 #include "SkImageEncoder.h"
8 #include "SkString.h" 8 #include "SkString.h"
9 #include "SkUnPreMultiply.h" 9 #include "SkUnPreMultiply.h"
10 10
11 DEFINE_string2(writePath, w, "", "If set, write GMs here as .pngs."); 11 DEFINE_string2(writePath, w, "", "If set, write GMs here as .pngs.");
12 12
13 namespace DM { 13 namespace DM {
14 14
15 // Splits off the last N suffixes of name (splitting on _) and appends them to o ut. 15 // Splits off the last N suffixes of name (splitting on _) and appends them to o ut.
16 // Returns the total number of characters consumed. 16 // Returns the total number of characters consumed.
17 static int split_suffixes(int N, const char* name, SkTArray<SkString>* out) { 17 static int split_suffixes(int N, const char* name, SkTArray<SkString>* out) {
18 SkTArray<SkString> split; 18 SkTArray<SkString> split;
19 SkStrSplit(name, "_", &split); 19 SkStrSplit(name, "_", &split);
20 int consumed = 0; 20 int consumed = 0;
21 for (int i = 0; i < N; i++) { 21 for (int i = 0; i < N; i++) {
22 // We're splitting off suffixes from the back to front. 22 // We're splitting off suffixes from the back to front.
23 out->push_back(split[split.count()-i-1]); 23 out->push_back(split[split.count()-i-1]);
24 consumed += out->back().size() + 1; // Add one for the _. 24 consumed += out->back().size() + 1; // Add one for the _.
25 } 25 }
26 return consumed; 26 return consumed;
27 } 27 }
28 28
29 WriteTask::WriteTask(const Task& parent, SkBitmap bitmap) : Task(parent), fBitma p(bitmap) { 29 WriteTask::WriteTask(const Task& parent, SkBitmap bitmap) : CpuTask(parent), fBi tmap(bitmap) {
30 const int suffixes = parent.depth() + 1; 30 const int suffixes = parent.depth() + 1;
31 const SkString& name = parent.name(); 31 const SkString& name = parent.name();
32 const int totalSuffixLength = split_suffixes(suffixes, name.c_str(), &fSuffi xes); 32 const int totalSuffixLength = split_suffixes(suffixes, name.c_str(), &fSuffi xes);
33 fGmName.set(name.c_str(), name.size()-totalSuffixLength); 33 fGmName.set(name.c_str(), name.size()-totalSuffixLength);
34 } 34 }
35 35
36 void WriteTask::makeDirOrFail(SkString dir) { 36 void WriteTask::makeDirOrFail(SkString dir) {
37 if (!sk_mkdir(dir.c_str())) { 37 if (!sk_mkdir(dir.c_str())) {
38 this->fail(); 38 this->fail();
39 } 39 }
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 for (size_t i = 0; i < bitmap.getSize()/4; i++) { 145 for (size_t i = 0; i < bitmap.getSize()/4; i++) {
146 dst[i] = SkUnPreMultiply::UnPreMultiplyPreservingByteOrder(src[i]); 146 dst[i] = SkUnPreMultiply::UnPreMultiplyPreservingByteOrder(src[i]);
147 } 147 }
148 bitmap.swap(unpremul); 148 bitmap.swap(unpremul);
149 } 149 }
150 150
151 return BitmapsEqual(expected, bitmap); 151 return BitmapsEqual(expected, bitmap);
152 } 152 }
153 153
154 } // namespace DM 154 } // namespace DM
OLDNEW
« no previous file with comments | « dm/DMWriteTask.h ('k') | gyp/dm.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698