| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 Google Inc. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 6 */ | 6 */ |
| 7 | 7 |
| 8 #include "DMSrcSink.h" | 8 #include "DMSrcSink.h" |
| 9 #include "SamplePipeControllers.h" | 9 #include "SamplePipeControllers.h" |
| 10 #include "SkAndroidCodec.h" | 10 #include "SkAndroidCodec.h" |
| (...skipping 771 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 782 Error NullSink::draw(const Src& src, SkBitmap*, SkWStream*, SkString*) const { | 782 Error NullSink::draw(const Src& src, SkBitmap*, SkWStream*, SkString*) const { |
| 783 SkAutoTDelete<SkCanvas> canvas(SkCreateNullCanvas()); | 783 SkAutoTDelete<SkCanvas> canvas(SkCreateNullCanvas()); |
| 784 return src.draw(canvas); | 784 return src.draw(canvas); |
| 785 } | 785 } |
| 786 | 786 |
| 787 /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~*/ | 787 /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~*/ |
| 788 | 788 |
| 789 DEFINE_bool(gpuStats, false, "Append GPU stats to the log for each GPU task?"); | 789 DEFINE_bool(gpuStats, false, "Append GPU stats to the log for each GPU task?"); |
| 790 | 790 |
| 791 GPUSink::GPUSink(GrContextFactory::GLContextType ct, | 791 GPUSink::GPUSink(GrContextFactory::GLContextType ct, |
| 792 GrContextFactory::GLContextOptions options, | 792 GrGLStandard api, |
| 793 GrGLStandard gpuAPI, | |
| 794 int samples, | 793 int samples, |
| 795 bool diText, | 794 bool diText, |
| 796 bool threaded) | 795 bool threaded) |
| 797 : fContextType(ct) | 796 : fContextType(ct) |
| 798 , fContextOptions(options) | 797 , fGpuAPI(api) |
| 799 , fGpuAPI(gpuAPI) | |
| 800 , fSampleCount(samples) | 798 , fSampleCount(samples) |
| 801 , fUseDIText(diText) | 799 , fUseDIText(diText) |
| 802 , fThreaded(threaded) {} | 800 , fThreaded(threaded) {} |
| 803 | 801 |
| 804 int GPUSink::enclave() const { | 802 int GPUSink::enclave() const { |
| 805 return fThreaded ? kAnyThread_Enclave : kGPU_Enclave; | 803 return fThreaded ? kAnyThread_Enclave : kGPU_Enclave; |
| 806 } | 804 } |
| 807 | 805 |
| 808 void PreAbandonGpuContextErrorHandler(SkError, void*) {} | 806 void PreAbandonGpuContextErrorHandler(SkError, void*) {} |
| 809 | 807 |
| 810 DEFINE_bool(imm, false, "Run gpu configs in immediate mode."); | 808 DEFINE_bool(imm, false, "Run gpu configs in immediate mode."); |
| 811 DEFINE_bool(batchClip, false, "Clip each GrBatch to its device bounds for testin
g."); | 809 DEFINE_bool(batchClip, false, "Clip each GrBatch to its device bounds for testin
g."); |
| 812 DEFINE_bool(batchBounds, false, "Draw a wireframe bounds of each GrBatch."); | 810 DEFINE_bool(batchBounds, false, "Draw a wireframe bounds of each GrBatch."); |
| 813 | 811 |
| 814 Error GPUSink::draw(const Src& src, SkBitmap* dst, SkWStream*, SkString* log) co
nst { | 812 Error GPUSink::draw(const Src& src, SkBitmap* dst, SkWStream*, SkString* log) co
nst { |
| 815 GrContextOptions grOptions; | 813 GrContextOptions options; |
| 816 if (FLAGS_imm) { | 814 if (FLAGS_imm) { |
| 817 grOptions.fImmediateMode = true; | 815 options.fImmediateMode = true; |
| 818 } | 816 } |
| 819 if (FLAGS_batchClip) { | 817 if (FLAGS_batchClip) { |
| 820 grOptions.fClipBatchToBounds = true; | 818 options.fClipBatchToBounds = true; |
| 821 } | 819 } |
| 820 if (FLAGS_batchBounds) { |
| 821 options.fDrawBatchBounds = true; |
| 822 } |
| 823 src.modifyGrContextOptions(&options); |
| 822 | 824 |
| 823 if (FLAGS_batchBounds) { | 825 GrContextFactory factory(options); |
| 824 grOptions.fDrawBatchBounds = true; | |
| 825 } | |
| 826 src.modifyGrContextOptions(&grOptions); | |
| 827 | |
| 828 GrContextFactory factory(grOptions); | |
| 829 const SkISize size = src.size(); | 826 const SkISize size = src.size(); |
| 830 const SkImageInfo info = | 827 const SkImageInfo info = |
| 831 SkImageInfo::Make(size.width(), size.height(), kN32_SkColorType, kPremul
_SkAlphaType); | 828 SkImageInfo::Make(size.width(), size.height(), kN32_SkColorType, kPremul
_SkAlphaType); |
| 832 SkAutoTUnref<SkSurface> surface( | 829 SkAutoTUnref<SkSurface> surface( |
| 833 NewGpuSurface(&factory, fContextType, fContextOptions, fGpuAPI, info
, fSampleCount, | 830 NewGpuSurface(&factory, fContextType, fGpuAPI, info, fSampleCount, f
UseDIText)); |
| 834 fUseDIText)); | |
| 835 if (!surface) { | 831 if (!surface) { |
| 836 return "Could not create a surface."; | 832 return "Could not create a surface."; |
| 837 } | 833 } |
| 838 if (FLAGS_preAbandonGpuContext) { | 834 if (FLAGS_preAbandonGpuContext) { |
| 839 SkSetErrorCallback(&PreAbandonGpuContextErrorHandler, nullptr); | 835 SkSetErrorCallback(&PreAbandonGpuContextErrorHandler, nullptr); |
| 840 factory.abandonContexts(); | 836 factory.abandonContexts(); |
| 841 } | 837 } |
| 842 SkCanvas* canvas = surface->getCanvas(); | 838 SkCanvas* canvas = surface->getCanvas(); |
| 843 Error err = src.draw(canvas); | 839 Error err = src.draw(canvas); |
| 844 if (!err.isEmpty()) { | 840 if (!err.isEmpty()) { |
| (...skipping 423 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1268 skr.visit<void>(i, drawsAsSingletonPictures); | 1264 skr.visit<void>(i, drawsAsSingletonPictures); |
| 1269 } | 1265 } |
| 1270 SkAutoTUnref<SkPicture> macroPic(macroRec.endRecordingAsPicture()); | 1266 SkAutoTUnref<SkPicture> macroPic(macroRec.endRecordingAsPicture()); |
| 1271 | 1267 |
| 1272 canvas->drawPicture(macroPic); | 1268 canvas->drawPicture(macroPic); |
| 1273 return ""; | 1269 return ""; |
| 1274 }); | 1270 }); |
| 1275 } | 1271 } |
| 1276 | 1272 |
| 1277 } // namespace DM | 1273 } // namespace DM |
| OLD | NEW |