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

Side by Side Diff: dm/DMSrcSink.cpp

Issue 2072813002: Revert of Lots of progress switching to SkColorSpace rather than SkColorProfileType (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 6 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 | « dm/DMSrcSink.h ('k') | example/HelloWorld.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 /* 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 "Resources.h" 9 #include "Resources.h"
10 #include "SkAndroidCodec.h" 10 #include "SkAndroidCodec.h"
(...skipping 1042 matching lines...) Expand 10 before | Expand all | Expand 10 after
1053 1053
1054 /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~*/ 1054 /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~*/
1055 1055
1056 DEFINE_bool(gpuStats, false, "Append GPU stats to the log for each GPU task?"); 1056 DEFINE_bool(gpuStats, false, "Append GPU stats to the log for each GPU task?");
1057 1057
1058 GPUSink::GPUSink(GrContextFactory::ContextType ct, 1058 GPUSink::GPUSink(GrContextFactory::ContextType ct,
1059 GrContextFactory::ContextOptions options, 1059 GrContextFactory::ContextOptions options,
1060 int samples, 1060 int samples,
1061 bool diText, 1061 bool diText,
1062 SkColorType colorType, 1062 SkColorType colorType,
1063 sk_sp<SkColorSpace> colorSpace, 1063 SkColorProfileType profileType,
1064 bool threaded) 1064 bool threaded)
1065 : fContextType(ct) 1065 : fContextType(ct)
1066 , fContextOptions(options) 1066 , fContextOptions(options)
1067 , fSampleCount(samples) 1067 , fSampleCount(samples)
1068 , fUseDIText(diText) 1068 , fUseDIText(diText)
1069 , fColorType(colorType) 1069 , fColorType(colorType)
1070 , fColorSpace(std::move(colorSpace)) 1070 , fProfileType(profileType)
1071 , fThreaded(threaded) {} 1071 , fThreaded(threaded) {}
1072 1072
1073 void PreAbandonGpuContextErrorHandler(SkError, void*) {} 1073 void PreAbandonGpuContextErrorHandler(SkError, void*) {}
1074 1074
1075 DEFINE_bool(imm, false, "Run gpu configs in immediate mode."); 1075 DEFINE_bool(imm, false, "Run gpu configs in immediate mode.");
1076 DEFINE_bool(batchClip, false, "Clip each GrBatch to its device bounds for testin g."); 1076 DEFINE_bool(batchClip, false, "Clip each GrBatch to its device bounds for testin g.");
1077 DEFINE_bool(batchBounds, false, "Draw a wireframe bounds of each GrBatch."); 1077 DEFINE_bool(batchBounds, false, "Draw a wireframe bounds of each GrBatch.");
1078 DEFINE_int32(batchLookback, -1, "Maximum GrBatch lookback for combining, negativ e means default."); 1078 DEFINE_int32(batchLookback, -1, "Maximum GrBatch lookback for combining, negativ e means default.");
1079 DEFINE_int32(batchLookahead, -1, "Maximum GrBatch lookahead for combining, negat ive means " 1079 DEFINE_int32(batchLookahead, -1, "Maximum GrBatch lookahead for combining, negat ive means "
1080 "default."); 1080 "default.");
1081 1081
1082 Error GPUSink::draw(const Src& src, SkBitmap* dst, SkWStream*, SkString* log) co nst { 1082 Error GPUSink::draw(const Src& src, SkBitmap* dst, SkWStream*, SkString* log) co nst {
1083 GrContextOptions grOptions; 1083 GrContextOptions grOptions;
1084 grOptions.fImmediateMode = FLAGS_imm; 1084 grOptions.fImmediateMode = FLAGS_imm;
1085 grOptions.fClipBatchToBounds = FLAGS_batchClip; 1085 grOptions.fClipBatchToBounds = FLAGS_batchClip;
1086 grOptions.fDrawBatchBounds = FLAGS_batchBounds; 1086 grOptions.fDrawBatchBounds = FLAGS_batchBounds;
1087 grOptions.fMaxBatchLookback = FLAGS_batchLookback; 1087 grOptions.fMaxBatchLookback = FLAGS_batchLookback;
1088 grOptions.fMaxBatchLookahead = FLAGS_batchLookahead; 1088 grOptions.fMaxBatchLookahead = FLAGS_batchLookahead;
1089 1089
1090 src.modifyGrContextOptions(&grOptions); 1090 src.modifyGrContextOptions(&grOptions);
1091 1091
1092 GrContextFactory factory(grOptions); 1092 GrContextFactory factory(grOptions);
1093 const SkISize size = src.size(); 1093 const SkISize size = src.size();
1094 const SkImageInfo info = 1094 const SkImageInfo info =
1095 SkImageInfo::Make(size.width(), size.height(), fColorType, 1095 SkImageInfo::Make(size.width(), size.height(), fColorType,
1096 kPremul_SkAlphaType, fColorSpace); 1096 kPremul_SkAlphaType, fProfileType);
1097 #if SK_SUPPORT_GPU 1097 #if SK_SUPPORT_GPU
1098 GrContext* context = factory.getContextInfo(fContextType, fContextOptions).g rContext(); 1098 GrContext* context = factory.getContextInfo(fContextType, fContextOptions).g rContext();
1099 const int maxDimension = context->caps()->maxTextureSize(); 1099 const int maxDimension = context->caps()->maxTextureSize();
1100 if (maxDimension < SkTMax(size.width(), size.height())) { 1100 if (maxDimension < SkTMax(size.width(), size.height())) {
1101 return Error::Nonfatal("Src too large to create a texture.\n"); 1101 return Error::Nonfatal("Src too large to create a texture.\n");
1102 } 1102 }
1103 #endif 1103 #endif
1104 1104
1105 auto surface( 1105 auto surface(
1106 NewGpuSurface(&factory, fContextType, fContextOptions, info, fSample Count, fUseDIText)); 1106 NewGpuSurface(&factory, fContextType, fContextOptions, info, fSample Count, fUseDIText));
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
1206 Error SVGSink::draw(const Src& src, SkBitmap*, SkWStream* dst, SkString*) const { 1206 Error SVGSink::draw(const Src& src, SkBitmap*, SkWStream* dst, SkString*) const {
1207 SkAutoTDelete<SkXMLWriter> xmlWriter(new SkXMLStreamWriter(dst)); 1207 SkAutoTDelete<SkXMLWriter> xmlWriter(new SkXMLStreamWriter(dst));
1208 SkAutoTUnref<SkCanvas> canvas(SkSVGCanvas::Create( 1208 SkAutoTUnref<SkCanvas> canvas(SkSVGCanvas::Create(
1209 SkRect::MakeWH(SkIntToScalar(src.size().width()), SkIntToScalar(src.size ().height())), 1209 SkRect::MakeWH(SkIntToScalar(src.size().width()), SkIntToScalar(src.size ().height())),
1210 xmlWriter)); 1210 xmlWriter));
1211 return src.draw(canvas); 1211 return src.draw(canvas);
1212 } 1212 }
1213 1213
1214 /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~*/ 1214 /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~*/
1215 1215
1216 RasterSink::RasterSink(SkColorType colorType, sk_sp<SkColorSpace> colorSpace) 1216 RasterSink::RasterSink(SkColorType colorType, SkColorProfileType profileType)
1217 : fColorType(colorType) 1217 : fColorType(colorType)
1218 , fColorSpace(std::move(colorSpace)) {} 1218 , fProfileType(profileType) {}
1219 1219
1220 Error RasterSink::draw(const Src& src, SkBitmap* dst, SkWStream*, SkString*) con st { 1220 Error RasterSink::draw(const Src& src, SkBitmap* dst, SkWStream*, SkString*) con st {
1221 const SkISize size = src.size(); 1221 const SkISize size = src.size();
1222 // If there's an appropriate alpha type for this color type, use it, otherwi se use premul. 1222 // If there's an appropriate alpha type for this color type, use it, otherwi se use premul.
1223 SkAlphaType alphaType = kPremul_SkAlphaType; 1223 SkAlphaType alphaType = kPremul_SkAlphaType;
1224 (void)SkColorTypeValidateAlphaType(fColorType, alphaType, &alphaType); 1224 (void)SkColorTypeValidateAlphaType(fColorType, alphaType, &alphaType);
1225 1225
1226 SkMallocPixelRef::ZeroedPRFactory factory; 1226 SkMallocPixelRef::ZeroedPRFactory factory;
1227 dst->allocPixels(SkImageInfo::Make(size.width(), size.height(), 1227 dst->allocPixels(SkImageInfo::Make(size.width(), size.height(),
1228 fColorType, alphaType, fColorSpace), 1228 fColorType, alphaType, fProfileType),
1229 &factory, 1229 &factory,
1230 nullptr/*colortable*/); 1230 nullptr/*colortable*/);
1231 SkCanvas canvas(*dst); 1231 SkCanvas canvas(*dst);
1232 return src.draw(&canvas); 1232 return src.draw(&canvas);
1233 } 1233 }
1234 1234
1235 /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~*/ 1235 /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~*/
1236 1236
1237 // Handy for front-patching a Src. Do whatever up-front work you need, then cal l draw_to_canvas(), 1237 // Handy for front-patching a Src. Do whatever up-front work you need, then cal l draw_to_canvas(),
1238 // passing the Sink draw() arguments, a size, and a function draws into an SkCan vas. 1238 // passing the Sink draw() arguments, a size, and a function draws into an SkCan vas.
(...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after
1543 skr.visit(i, drawsAsSingletonPictures); 1543 skr.visit(i, drawsAsSingletonPictures);
1544 } 1544 }
1545 sk_sp<SkPicture> macroPic(macroRec.finishRecordingAsPicture()); 1545 sk_sp<SkPicture> macroPic(macroRec.finishRecordingAsPicture());
1546 1546
1547 canvas->drawPicture(macroPic); 1547 canvas->drawPicture(macroPic);
1548 return check_against_reference(bitmap, src, fSink); 1548 return check_against_reference(bitmap, src, fSink);
1549 }); 1549 });
1550 } 1550 }
1551 1551
1552 } // namespace DM 1552 } // namespace DM
OLDNEW
« no previous file with comments | « dm/DMSrcSink.h ('k') | example/HelloWorld.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698