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

Side by Side Diff: dm/DMSrcSink.cpp

Issue 929243004: adding preabandon flag to DM (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: feedback incorporated Created 5 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 | « no previous file | src/core/SkCanvas.cpp » ('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 "SkError.h"
5 #include "SkMultiPictureDraw.h" 6 #include "SkMultiPictureDraw.h"
6 #include "SkNullCanvas.h" 7 #include "SkNullCanvas.h"
7 #include "SkOSFile.h" 8 #include "SkOSFile.h"
8 #include "SkPictureRecorder.h" 9 #include "SkPictureRecorder.h"
9 #include "SkRandom.h" 10 #include "SkRandom.h"
10 #include "SkSVGCanvas.h" 11 #include "SkSVGCanvas.h"
11 #include "SkStream.h" 12 #include "SkStream.h"
12 #include "SkXMLWriter.h" 13 #include "SkXMLWriter.h"
13 14
14 namespace DM { 15 namespace DM {
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 : fContextType(ct) 151 : fContextType(ct)
151 , fGpuAPI(api) 152 , fGpuAPI(api)
152 , fSampleCount(samples) 153 , fSampleCount(samples)
153 , fUseDFText(dfText) 154 , fUseDFText(dfText)
154 , fThreaded(threaded) {} 155 , fThreaded(threaded) {}
155 156
156 int GPUSink::enclave() const { 157 int GPUSink::enclave() const {
157 return fThreaded ? kAnyThread_Enclave : kGPU_Enclave; 158 return fThreaded ? kAnyThread_Enclave : kGPU_Enclave;
158 } 159 }
159 160
161 void PreAbandonGpuContextErrorHandler(SkError, void*) {}
162
160 Error GPUSink::draw(const Src& src, SkBitmap* dst, SkWStream*, SkString* log) co nst { 163 Error GPUSink::draw(const Src& src, SkBitmap* dst, SkWStream*, SkString* log) co nst {
161 GrContextFactory factory; 164 GrContextFactory factory;
162 const SkISize size = src.size(); 165 const SkISize size = src.size();
163 const SkImageInfo info = 166 const SkImageInfo info =
164 SkImageInfo::Make(size.width(), size.height(), kN32_SkColorType, kPremul _SkAlphaType); 167 SkImageInfo::Make(size.width(), size.height(), kN32_SkColorType, kPremul _SkAlphaType);
165 SkAutoTUnref<SkSurface> surface( 168 SkAutoTUnref<SkSurface> surface(
166 NewGpuSurface(&factory, fContextType, fGpuAPI, info, fSampleCount, f UseDFText)); 169 NewGpuSurface(&factory, fContextType, fGpuAPI, info, fSampleCount, f UseDFText));
167 if (!surface) { 170 if (!surface) {
168 return "Could not create a surface."; 171 return "Could not create a surface.";
169 } 172 }
173 if (FLAGS_preAbandonGpuContext) {
174 SkSetErrorCallback(&PreAbandonGpuContextErrorHandler, NULL);
175 factory.abandonContexts();
176 }
170 SkCanvas* canvas = surface->getCanvas(); 177 SkCanvas* canvas = surface->getCanvas();
171 Error err = src.draw(canvas); 178 Error err = src.draw(canvas);
172 if (!err.isEmpty()) { 179 if (!err.isEmpty()) {
173 return err; 180 return err;
174 } 181 }
175 canvas->flush(); 182 canvas->flush();
176 if (FLAGS_gpuStats) { 183 if (FLAGS_gpuStats) {
177 canvas->getGrContext()->dumpCacheStats(log); 184 canvas->getGrContext()->dumpCacheStats(log);
178 canvas->getGrContext()->dumpGpuStats(log); 185 canvas->getGrContext()->dumpGpuStats(log);
179 } 186 }
180 dst->allocPixels(info); 187 dst->allocPixels(info);
181 canvas->readPixels(dst, 0,0); 188 canvas->readPixels(dst, 0, 0);
182 if (FLAGS_abandonGpuContext) { 189 if (FLAGS_abandonGpuContext) {
183 factory.abandonContexts(); 190 factory.abandonContexts();
184 } 191 }
185 return ""; 192 return "";
186 } 193 }
187 194
188 /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~*/ 195 /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~*/
189 196
190 PDFSink::PDFSink() {} 197 PDFSink::PDFSink() {}
191 198
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after
457 surfaces.unrefAll(); 464 surfaces.unrefAll();
458 return ""; 465 return "";
459 } 466 }
460 SkISize size() const SK_OVERRIDE { return fSize; } 467 SkISize size() const SK_OVERRIDE { return fSize; }
461 Name name() const SK_OVERRIDE { sk_throw(); return ""; } // No one shou ld be calling this. 468 Name name() const SK_OVERRIDE { sk_throw(); return ""; } // No one shou ld be calling this.
462 } proxy(fW, fH, pic, src.size()); 469 } proxy(fW, fH, pic, src.size());
463 return fSink->draw(proxy, bitmap, stream, log); 470 return fSink->draw(proxy, bitmap, stream, log);
464 } 471 }
465 472
466 } // namespace DM 473 } // namespace DM
OLDNEW
« no previous file with comments | « no previous file | src/core/SkCanvas.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698