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 "SkAndroidCodec.h" | 9 #include "SkAndroidCodec.h" |
10 #include "SkCodec.h" | 10 #include "SkCodec.h" |
(...skipping 838 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
849 } | 849 } |
850 | 850 |
851 /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~*/ | 851 /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~*/ |
852 | 852 |
853 DEFINE_bool(gpuStats, false, "Append GPU stats to the log for each GPU task?"); | 853 DEFINE_bool(gpuStats, false, "Append GPU stats to the log for each GPU task?"); |
854 | 854 |
855 GPUSink::GPUSink(GrContextFactory::GLContextType ct, | 855 GPUSink::GPUSink(GrContextFactory::GLContextType ct, |
856 GrContextFactory::GLContextOptions options, | 856 GrContextFactory::GLContextOptions options, |
857 int samples, | 857 int samples, |
858 bool diText, | 858 bool diText, |
859 SkColorType colorType, | |
860 SkColorProfileType profileType, | |
861 bool threaded) | 859 bool threaded) |
862 : fContextType(ct) | 860 : fContextType(ct) |
863 , fContextOptions(options) | 861 , fContextOptions(options) |
864 , fSampleCount(samples) | 862 , fSampleCount(samples) |
865 , fUseDIText(diText) | 863 , fUseDIText(diText) |
866 , fColorType(colorType) | |
867 , fProfileType(profileType) | |
868 , fThreaded(threaded) {} | 864 , fThreaded(threaded) {} |
869 | 865 |
870 void PreAbandonGpuContextErrorHandler(SkError, void*) {} | 866 void PreAbandonGpuContextErrorHandler(SkError, void*) {} |
871 | 867 |
872 DEFINE_bool(imm, false, "Run gpu configs in immediate mode."); | 868 DEFINE_bool(imm, false, "Run gpu configs in immediate mode."); |
873 DEFINE_bool(batchClip, false, "Clip each GrBatch to its device bounds for testin
g."); | 869 DEFINE_bool(batchClip, false, "Clip each GrBatch to its device bounds for testin
g."); |
874 DEFINE_bool(batchBounds, false, "Draw a wireframe bounds of each GrBatch."); | 870 DEFINE_bool(batchBounds, false, "Draw a wireframe bounds of each GrBatch."); |
875 DEFINE_int32(batchLookback, -1, "Maximum GrBatch lookback for combining, negativ
e means default."); | 871 DEFINE_int32(batchLookback, -1, "Maximum GrBatch lookback for combining, negativ
e means default."); |
876 | 872 |
877 Error GPUSink::draw(const Src& src, SkBitmap* dst, SkWStream*, SkString* log) co
nst { | 873 Error GPUSink::draw(const Src& src, SkBitmap* dst, SkWStream*, SkString* log) co
nst { |
878 GrContextOptions grOptions; | 874 GrContextOptions grOptions; |
879 grOptions.fImmediateMode = FLAGS_imm; | 875 grOptions.fImmediateMode = FLAGS_imm; |
880 grOptions.fClipBatchToBounds = FLAGS_batchClip; | 876 grOptions.fClipBatchToBounds = FLAGS_batchClip; |
881 grOptions.fDrawBatchBounds = FLAGS_batchBounds; | 877 grOptions.fDrawBatchBounds = FLAGS_batchBounds; |
882 grOptions.fMaxBatchLookback = FLAGS_batchLookback; | 878 grOptions.fMaxBatchLookback = FLAGS_batchLookback; |
883 | 879 |
884 src.modifyGrContextOptions(&grOptions); | 880 src.modifyGrContextOptions(&grOptions); |
885 | 881 |
886 GrContextFactory factory(grOptions); | 882 GrContextFactory factory(grOptions); |
887 const SkISize size = src.size(); | 883 const SkISize size = src.size(); |
888 const SkImageInfo info = | 884 const SkImageInfo info = |
889 SkImageInfo::Make(size.width(), size.height(), fColorType, | 885 SkImageInfo::Make(size.width(), size.height(), kN32_SkColorType, kPremul
_SkAlphaType); |
890 kPremul_SkAlphaType, fProfileType); | |
891 #if SK_SUPPORT_GPU | 886 #if SK_SUPPORT_GPU |
892 const int maxDimension = factory.getContextInfo(fContextType, fContextOption
s). | 887 const int maxDimension = factory.getContextInfo(fContextType, fContextOption
s). |
893 fGrContext->caps()->maxTextureSize(); | 888 fGrContext->caps()->maxTextureSize(); |
894 if (maxDimension < SkTMax(size.width(), size.height())) { | 889 if (maxDimension < SkTMax(size.width(), size.height())) { |
895 return Error::Nonfatal("Src too large to create a texture.\n"); | 890 return Error::Nonfatal("Src too large to create a texture.\n"); |
896 } | 891 } |
897 #endif | 892 #endif |
898 | 893 |
899 SkAutoTUnref<SkSurface> surface( | 894 SkAutoTUnref<SkSurface> surface( |
900 NewGpuSurface(&factory, fContextType, fContextOptions, info, fSample
Count, fUseDIText)); | 895 NewGpuSurface(&factory, fContextType, fContextOptions, info, fSample
Count, fUseDIText)); |
(...skipping 526 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1427 skr.visit<void>(i, drawsAsSingletonPictures); | 1422 skr.visit<void>(i, drawsAsSingletonPictures); |
1428 } | 1423 } |
1429 SkAutoTUnref<SkPicture> macroPic(macroRec.endRecordingAsPicture()); | 1424 SkAutoTUnref<SkPicture> macroPic(macroRec.endRecordingAsPicture()); |
1430 | 1425 |
1431 canvas->drawPicture(macroPic); | 1426 canvas->drawPicture(macroPic); |
1432 return check_against_reference(bitmap, src, fSink); | 1427 return check_against_reference(bitmap, src, fSink); |
1433 }); | 1428 }); |
1434 } | 1429 } |
1435 | 1430 |
1436 } // namespace DM | 1431 } // namespace DM |
OLD | NEW |