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

Side by Side Diff: dm/DMSrcSink.cpp

Issue 817573004: turn back on gpu tests (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: missing file 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 "SkTLS.h"
10 9
11 namespace DM { 10 namespace DM {
12 11
13 void SafeUnref(SkPicture* p) { SkSafeUnref(p); } 12 void SafeUnref(SkPicture* p) { SkSafeUnref(p); }
14 void SafeUnref(SkData* d) { SkSafeUnref(d); } 13 void SafeUnref(SkData* d) { SkSafeUnref(d); }
15 14
16 // FIXME: the GM objects themselves are not threadsafe, so we create and destroy them as needed. 15 // FIXME: the GM objects themselves are not threadsafe, so we create and destroy them as needed.
17 16
18 GMSrc::GMSrc(skiagm::GMRegistry::Factory factory) : fFactory(factory) {} 17 GMSrc::GMSrc(skiagm::GMRegistry::Factory factory) : fFactory(factory) {}
19 18
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 SkIRect bounds; 145 SkIRect bounds;
147 cull.roundOut(&bounds); 146 cull.roundOut(&bounds);
148 SkISize size = { bounds.width(), bounds.height() }; 147 SkISize size = { bounds.width(), bounds.height() };
149 return size; 148 return size;
150 } 149 }
151 150
152 Name SKPSrc::name() const { return SkOSPath::Basename(fPath.c_str()); } 151 Name SKPSrc::name() const { return SkOSPath::Basename(fPath.c_str()); }
153 152
154 /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~*/ 153 /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~*/
155 154
156 DEFINE_string(gpu_threading, "none", 155 GPUSink::GPUSink(GrContextFactory::GLContextType ct,
157 "none: single thread,\n" 156 GrGLStandard api,
158 "tls: any thread, GrContextFactory in TLS (crashy),\n" 157 int samples,
159 "stack: any thread, GrContextFactory on stack (less crashy, differently so)"); 158 bool dfText,
160 159 bool threaded)
161 GPUSink::GPUSink(GrContextFactory::GLContextType ct, GrGLStandard api, int sampl es, bool dfText)
162 : fContextType(ct) 160 : fContextType(ct)
163 , fGpuAPI(api) 161 , fGpuAPI(api)
164 , fSampleCount(samples) 162 , fSampleCount(samples)
165 , fUseDFText(dfText) {} 163 , fUseDFText(dfText)
164 , fThreaded(threaded) {}
166 165
167 int GPUSink::enclave() const { 166 int GPUSink::enclave() const {
168 return FLAGS_gpu_threading.contains("none") ? kGPUSink_Enclave : kAnyThread_ Enclave; 167 return fThreaded ? kAnyThread_Enclave : kGPUSink_Enclave;
169 } 168 }
170 169
171 static void* CreateGrFactory() { return new GrContextFactory; }
172 static void DeleteGrFactory(void* p) { delete (GrContextFactory*)p; }
173
174 Error GPUSink::draw(const Src& src, SkBitmap* dst, SkWStream*) const { 170 Error GPUSink::draw(const Src& src, SkBitmap* dst, SkWStream*) const {
175 GrContextFactory local, *factory = &local; 171 GrContextFactory* factory = GetThreadLocalGrContextFactory();
176 if (!FLAGS_gpu_threading.contains("stack")) {
177 factory = (GrContextFactory*)SkTLS::Get(CreateGrFactory, DeleteGrFactory );
178 }
179 // Does abandoning / resetting contexts make any sense if we have stack-scop ed factories?
180 if (FLAGS_abandonGpuContext) { 172 if (FLAGS_abandonGpuContext) {
181 factory->abandonContexts(); 173 factory->abandonContexts();
182 } 174 }
183 if (FLAGS_resetGpuContext || FLAGS_abandonGpuContext) { 175 if (FLAGS_resetGpuContext || FLAGS_abandonGpuContext) {
184 factory->destroyContexts(); 176 factory->destroyContexts();
185 } 177 }
186 const SkISize size = src.size(); 178 const SkISize size = src.size();
187 const SkImageInfo info = 179 const SkImageInfo info =
188 SkImageInfo::Make(size.width(), size.height(), kN32_SkColorType, kPremul _SkAlphaType); 180 SkImageInfo::Make(size.width(), size.height(), kN32_SkColorType, kPremul _SkAlphaType);
189 SkAutoTUnref<SkSurface> surface( 181 SkAutoTUnref<SkSurface> surface(
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
380 surfaces.unrefAll(); 372 surfaces.unrefAll();
381 return ""; 373 return "";
382 } 374 }
383 SkISize size() const SK_OVERRIDE { return fSize; } 375 SkISize size() const SK_OVERRIDE { return fSize; }
384 Name name() const SK_OVERRIDE { sk_throw(); return ""; } // No one shou ld be calling this. 376 Name name() const SK_OVERRIDE { sk_throw(); return ""; } // No one shou ld be calling this.
385 } proxy(fW, fH, pic, src.size()); 377 } proxy(fW, fH, pic, src.size());
386 return fSink->draw(proxy, bitmap, stream); 378 return fSink->draw(proxy, bitmap, stream);
387 } 379 }
388 380
389 } // namespace DM 381 } // 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