| 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 "SkCodec.h" | 10 #include "SkCodec.h" |
| (...skipping 620 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 631 return src.draw(canvas); | 631 return src.draw(canvas); |
| 632 } | 632 } |
| 633 | 633 |
| 634 /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~*/ | 634 /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~*/ |
| 635 | 635 |
| 636 DEFINE_bool(gpuStats, false, "Append GPU stats to the log for each GPU task?"); | 636 DEFINE_bool(gpuStats, false, "Append GPU stats to the log for each GPU task?"); |
| 637 | 637 |
| 638 GPUSink::GPUSink(GrContextFactory::GLContextType ct, | 638 GPUSink::GPUSink(GrContextFactory::GLContextType ct, |
| 639 GrGLStandard api, | 639 GrGLStandard api, |
| 640 int samples, | 640 int samples, |
| 641 bool dfText, | 641 bool diText, |
| 642 bool threaded) | 642 bool threaded) |
| 643 : fContextType(ct) | 643 : fContextType(ct) |
| 644 , fGpuAPI(api) | 644 , fGpuAPI(api) |
| 645 , fSampleCount(samples) | 645 , fSampleCount(samples) |
| 646 , fUseDFText(dfText) | 646 , fUseDIText(diText) |
| 647 , fThreaded(threaded) {} | 647 , fThreaded(threaded) {} |
| 648 | 648 |
| 649 int GPUSink::enclave() const { | 649 int GPUSink::enclave() const { |
| 650 return fThreaded ? kAnyThread_Enclave : kGPU_Enclave; | 650 return fThreaded ? kAnyThread_Enclave : kGPU_Enclave; |
| 651 } | 651 } |
| 652 | 652 |
| 653 void PreAbandonGpuContextErrorHandler(SkError, void*) {} | 653 void PreAbandonGpuContextErrorHandler(SkError, void*) {} |
| 654 | 654 |
| 655 Error GPUSink::draw(const Src& src, SkBitmap* dst, SkWStream*, SkString* log) co
nst { | 655 Error GPUSink::draw(const Src& src, SkBitmap* dst, SkWStream*, SkString* log) co
nst { |
| 656 GrContextOptions options; | 656 GrContextOptions options; |
| 657 src.modifyGrContextOptions(&options); | 657 src.modifyGrContextOptions(&options); |
| 658 | 658 |
| 659 GrContextFactory factory(options); | 659 GrContextFactory factory(options); |
| 660 const SkISize size = src.size(); | 660 const SkISize size = src.size(); |
| 661 const SkImageInfo info = | 661 const SkImageInfo info = |
| 662 SkImageInfo::Make(size.width(), size.height(), kN32_SkColorType, kPremul
_SkAlphaType); | 662 SkImageInfo::Make(size.width(), size.height(), kN32_SkColorType, kPremul
_SkAlphaType); |
| 663 SkAutoTUnref<SkSurface> surface( | 663 SkAutoTUnref<SkSurface> surface( |
| 664 NewGpuSurface(&factory, fContextType, fGpuAPI, info, fSampleCount, f
UseDFText)); | 664 NewGpuSurface(&factory, fContextType, fGpuAPI, info, fSampleCount, f
UseDIText)); |
| 665 if (!surface) { | 665 if (!surface) { |
| 666 return "Could not create a surface."; | 666 return "Could not create a surface."; |
| 667 } | 667 } |
| 668 if (FLAGS_preAbandonGpuContext) { | 668 if (FLAGS_preAbandonGpuContext) { |
| 669 SkSetErrorCallback(&PreAbandonGpuContextErrorHandler, nullptr); | 669 SkSetErrorCallback(&PreAbandonGpuContextErrorHandler, nullptr); |
| 670 factory.abandonContexts(); | 670 factory.abandonContexts(); |
| 671 } | 671 } |
| 672 SkCanvas* canvas = surface->getCanvas(); | 672 SkCanvas* canvas = surface->getCanvas(); |
| 673 Error err = src.draw(canvas); | 673 Error err = src.draw(canvas); |
| 674 if (!err.isEmpty()) { | 674 if (!err.isEmpty()) { |
| (...skipping 406 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1081 skr.visit<void>(i, drawsAsSingletonPictures); | 1081 skr.visit<void>(i, drawsAsSingletonPictures); |
| 1082 } | 1082 } |
| 1083 SkAutoTUnref<SkPicture> macroPic(macroRec.endRecordingAsPicture()); | 1083 SkAutoTUnref<SkPicture> macroPic(macroRec.endRecordingAsPicture()); |
| 1084 | 1084 |
| 1085 canvas->drawPicture(macroPic); | 1085 canvas->drawPicture(macroPic); |
| 1086 return ""; | 1086 return ""; |
| 1087 }); | 1087 }); |
| 1088 } | 1088 } |
| 1089 | 1089 |
| 1090 } // namespace DM | 1090 } // namespace DM |
| OLD | NEW |