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

Side by Side Diff: dm/DMSrcSink.cpp

Issue 847273005: More natural way to serialize GPU tasks and tests. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: always stack-scope GrContextFactories 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/DMSrcSink.h ('k') | gyp/dm.gypi » ('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 "DMSrcSink.h" 1 #include "DMSrcSink.h"
2 #include "SamplePipeControllers.h" 2 #include "SamplePipeControllers.h"
3 #include "SkCommonFlags.h" 3 #include "SkCommonFlags.h"
4 #include "SkDocument.h" 4 #include "SkDocument.h"
5 #include "SkMultiPictureDraw.h" 5 #include "SkMultiPictureDraw.h"
6 #include "SkOSFile.h" 6 #include "SkOSFile.h"
7 #include "SkPictureRecorder.h" 7 #include "SkPictureRecorder.h"
8 #include "SkRandom.h" 8 #include "SkRandom.h"
9 #include "SkStream.h" 9 #include "SkStream.h"
10 10
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 int samples, 134 int samples,
135 bool dfText, 135 bool dfText,
136 bool threaded) 136 bool threaded)
137 : fContextType(ct) 137 : fContextType(ct)
138 , fGpuAPI(api) 138 , fGpuAPI(api)
139 , fSampleCount(samples) 139 , fSampleCount(samples)
140 , fUseDFText(dfText) 140 , fUseDFText(dfText)
141 , fThreaded(threaded) {} 141 , fThreaded(threaded) {}
142 142
143 int GPUSink::enclave() const { 143 int GPUSink::enclave() const {
144 return fThreaded ? kAnyThread_Enclave : kGPUSink_Enclave; 144 return fThreaded ? kAnyThread_Enclave : kGPU_Enclave;
145 } 145 }
146 146
147 Error GPUSink::draw(const Src& src, SkBitmap* dst, SkWStream*) const { 147 Error GPUSink::draw(const Src& src, SkBitmap* dst, SkWStream*) const {
148 GrContextFactory* factory = GetThreadLocalGrContextFactory(); 148 GrContextFactory factory;
149 if (FLAGS_abandonGpuContext) {
150 factory->abandonContexts();
151 }
152 if (FLAGS_resetGpuContext || FLAGS_abandonGpuContext) {
153 factory->destroyContexts();
154 }
155 const SkISize size = src.size(); 149 const SkISize size = src.size();
156 const SkImageInfo info = 150 const SkImageInfo info =
157 SkImageInfo::Make(size.width(), size.height(), kN32_SkColorType, kPremul _SkAlphaType); 151 SkImageInfo::Make(size.width(), size.height(), kN32_SkColorType, kPremul _SkAlphaType);
158 SkAutoTUnref<SkSurface> surface( 152 SkAutoTUnref<SkSurface> surface(
159 NewGpuSurface(factory, fContextType, fGpuAPI, info, fSampleCount, fU seDFText)); 153 NewGpuSurface(&factory, fContextType, fGpuAPI, info, fSampleCount, f UseDFText));
160 if (!surface) { 154 if (!surface) {
161 return "Could not create a surface."; 155 return "Could not create a surface.";
162 } 156 }
163 SkCanvas* canvas = surface->getCanvas(); 157 SkCanvas* canvas = surface->getCanvas();
164 Error err = src.draw(canvas); 158 Error err = src.draw(canvas);
165 if (!err.isEmpty()) { 159 if (!err.isEmpty()) {
166 return err; 160 return err;
167 } 161 }
168 canvas->flush(); 162 canvas->flush();
169 dst->allocPixels(info); 163 dst->allocPixels(info);
170 canvas->readPixels(dst, 0,0); 164 canvas->readPixels(dst, 0,0);
165 if (FLAGS_abandonGpuContext) {
166 factory.abandonContexts();
167 }
171 return ""; 168 return "";
172 } 169 }
173 170
174 /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~*/ 171 /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~*/
175 172
176 PDFSink::PDFSink() {} 173 PDFSink::PDFSink() {}
177 174
178 Error PDFSink::draw(const Src& src, SkBitmap*, SkWStream* dst) const { 175 Error PDFSink::draw(const Src& src, SkBitmap*, SkWStream* dst) const {
179 SkSize size; 176 SkSize size;
180 size = src.size(); 177 size = src.size();
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
348 surfaces.unrefAll(); 345 surfaces.unrefAll();
349 return ""; 346 return "";
350 } 347 }
351 SkISize size() const SK_OVERRIDE { return fSize; } 348 SkISize size() const SK_OVERRIDE { return fSize; }
352 Name name() const SK_OVERRIDE { sk_throw(); return ""; } // No one shou ld be calling this. 349 Name name() const SK_OVERRIDE { sk_throw(); return ""; } // No one shou ld be calling this.
353 } proxy(fW, fH, pic, src.size()); 350 } proxy(fW, fH, pic, src.size());
354 return fSink->draw(proxy, bitmap, stream); 351 return fSink->draw(proxy, bitmap, stream);
355 } 352 }
356 353
357 } // namespace DM 354 } // namespace DM
OLDNEW
« no previous file with comments | « dm/DMSrcSink.h ('k') | gyp/dm.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698