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