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

Side by Side Diff: src/core/SkXfermode.cpp

Issue 1253493002: No one calls SkXfermode::GetProc16 (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: more dead Created 5 years, 5 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 | « include/core/SkXfermode.h ('k') | no next file » | 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 /* 2 /*
3 * Copyright 2006 The Android Open Source Project 3 * Copyright 2006 The Android Open Source Project
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 8
9 #include "SkXfermode.h" 9 #include "SkXfermode.h"
10 #include "SkXfermode_proccoeff.h" 10 #include "SkXfermode_proccoeff.h"
(...skipping 1095 matching lines...) Expand 10 before | Expand all | Expand 10 after
1106 1106
1107 bool SkXfermode::IsOpaque(const SkXfermode* xfer, SrcColorOpacity opacityType) { 1107 bool SkXfermode::IsOpaque(const SkXfermode* xfer, SrcColorOpacity opacityType) {
1108 // if xfer is NULL we treat it as srcOver which is opaque if our src is opaq ue 1108 // if xfer is NULL we treat it as srcOver which is opaque if our src is opaq ue
1109 if (!xfer) { 1109 if (!xfer) {
1110 return SkXfermode::kOpaque_SrcColorOpacity == opacityType; 1110 return SkXfermode::kOpaque_SrcColorOpacity == opacityType;
1111 } 1111 }
1112 1112
1113 return xfer->isOpaque(opacityType); 1113 return xfer->isOpaque(opacityType);
1114 } 1114 }
1115 1115
1116 ///////////////////////////////////////////////////////////////////////////////
1117 //////////// 16bit xfermode procs
1118
1119 #ifdef SK_DEBUG
1120 static bool require_255(SkPMColor src) { return SkGetPackedA32(src) == 0xFF; }
1121 static bool require_0(SkPMColor src) { return SkGetPackedA32(src) == 0; }
1122 #endif
1123
1124 static uint16_t src_modeproc16_255(SkPMColor src, uint16_t dst) {
1125 SkASSERT(require_255(src));
1126 return SkPixel32ToPixel16(src);
1127 }
1128
1129 static uint16_t dst_modeproc16(SkPMColor src, uint16_t dst) {
1130 return dst;
1131 }
1132
1133 static uint16_t srcover_modeproc16_0(SkPMColor src, uint16_t dst) {
1134 SkASSERT(require_0(src));
1135 return dst;
1136 }
1137
1138 static uint16_t srcover_modeproc16_255(SkPMColor src, uint16_t dst) {
1139 SkASSERT(require_255(src));
1140 return SkPixel32ToPixel16(src);
1141 }
1142
1143 static uint16_t dstover_modeproc16_0(SkPMColor src, uint16_t dst) {
1144 SkASSERT(require_0(src));
1145 return dst;
1146 }
1147
1148 static uint16_t dstover_modeproc16_255(SkPMColor src, uint16_t dst) {
1149 SkASSERT(require_255(src));
1150 return dst;
1151 }
1152
1153 static uint16_t srcin_modeproc16_255(SkPMColor src, uint16_t dst) {
1154 SkASSERT(require_255(src));
1155 return SkPixel32ToPixel16(src);
1156 }
1157
1158 static uint16_t dstin_modeproc16_255(SkPMColor src, uint16_t dst) {
1159 SkASSERT(require_255(src));
1160 return dst;
1161 }
1162
1163 static uint16_t dstout_modeproc16_0(SkPMColor src, uint16_t dst) {
1164 SkASSERT(require_0(src));
1165 return dst;
1166 }
1167
1168 static uint16_t srcatop_modeproc16(SkPMColor src, uint16_t dst) {
1169 unsigned isa = 255 - SkGetPackedA32(src);
1170
1171 return SkPackRGB16(
1172 SkPacked32ToR16(src) + SkAlphaMulAlpha(SkGetPackedR16(dst), isa),
1173 SkPacked32ToG16(src) + SkAlphaMulAlpha(SkGetPackedG16(dst), isa),
1174 SkPacked32ToB16(src) + SkAlphaMulAlpha(SkGetPackedB16(dst), isa));
1175 }
1176
1177 static uint16_t srcatop_modeproc16_0(SkPMColor src, uint16_t dst) {
1178 SkASSERT(require_0(src));
1179 return dst;
1180 }
1181
1182 static uint16_t srcatop_modeproc16_255(SkPMColor src, uint16_t dst) {
1183 SkASSERT(require_255(src));
1184 return SkPixel32ToPixel16(src);
1185 }
1186
1187 static uint16_t dstatop_modeproc16_255(SkPMColor src, uint16_t dst) {
1188 SkASSERT(require_255(src));
1189 return dst;
1190 }
1191
1192 /*********
1193 darken and lighten boil down to this.
1194
1195 darken = (1 - Sa) * Dc + min(Sc, Dc)
1196 lighten = (1 - Sa) * Dc + max(Sc, Dc)
1197
1198 if (Sa == 0) these become
1199 darken = Dc + min(0, Dc) = 0
1200 lighten = Dc + max(0, Dc) = Dc
1201
1202 if (Sa == 1) these become
1203 darken = min(Sc, Dc)
1204 lighten = max(Sc, Dc)
1205 */
1206
1207 static uint16_t darken_modeproc16_0(SkPMColor src, uint16_t dst) {
1208 SkASSERT(require_0(src));
1209 return 0;
1210 }
1211
1212 static uint16_t darken_modeproc16_255(SkPMColor src, uint16_t dst) {
1213 SkASSERT(require_255(src));
1214 unsigned r = SkFastMin32(SkPacked32ToR16(src), SkGetPackedR16(dst));
1215 unsigned g = SkFastMin32(SkPacked32ToG16(src), SkGetPackedG16(dst));
1216 unsigned b = SkFastMin32(SkPacked32ToB16(src), SkGetPackedB16(dst));
1217 return SkPackRGB16(r, g, b);
1218 }
1219
1220 static uint16_t lighten_modeproc16_0(SkPMColor src, uint16_t dst) {
1221 SkASSERT(require_0(src));
1222 return dst;
1223 }
1224
1225 static uint16_t lighten_modeproc16_255(SkPMColor src, uint16_t dst) {
1226 SkASSERT(require_255(src));
1227 unsigned r = SkMax32(SkPacked32ToR16(src), SkGetPackedR16(dst));
1228 unsigned g = SkMax32(SkPacked32ToG16(src), SkGetPackedG16(dst));
1229 unsigned b = SkMax32(SkPacked32ToB16(src), SkGetPackedB16(dst));
1230 return SkPackRGB16(r, g, b);
1231 }
1232
1233 struct Proc16Rec {
1234 SkXfermodeProc16 fProc16_0;
1235 SkXfermodeProc16 fProc16_255;
1236 SkXfermodeProc16 fProc16_General;
1237 };
1238
1239 static const Proc16Rec gModeProcs16[] = {
1240 { NULL, NULL, NULL }, // CLEAR
1241 { NULL, src_modeproc16_255, NULL },
1242 { dst_modeproc16, dst_modeproc16, dst_modeproc16 },
1243 { srcover_modeproc16_0, srcover_modeproc16_255, NULL },
1244 { dstover_modeproc16_0, dstover_modeproc16_255, NULL },
1245 { NULL, srcin_modeproc16_255, NULL },
1246 { NULL, dstin_modeproc16_255, NULL },
1247 { NULL, NULL, NULL },// SRC_OUT
1248 { dstout_modeproc16_0, NULL, NULL },
1249 { srcatop_modeproc16_0, srcatop_modeproc16_255, srcatop_modeproc16 },
1250 { NULL, dstatop_modeproc16_255, NULL },
1251 { NULL, NULL, NULL }, // XOR
1252
1253 { NULL, NULL, NULL }, // plus
1254 { NULL, NULL, NULL }, // modula te
1255 { NULL, NULL, NULL }, // screen
1256 { NULL, NULL, NULL }, // overla y
1257 { darken_modeproc16_0, darken_modeproc16_255, NULL }, // darken
1258 { lighten_modeproc16_0, lighten_modeproc16_255, NULL }, // lighte n
1259 { NULL, NULL, NULL }, // colord odge
1260 { NULL, NULL, NULL }, // colorb urn
1261 { NULL, NULL, NULL }, // hardli ght
1262 { NULL, NULL, NULL }, // softli ght
1263 { NULL, NULL, NULL }, // differ ence
1264 { NULL, NULL, NULL }, // exclus ion
1265 { NULL, NULL, NULL }, // multip ly
1266 { NULL, NULL, NULL }, // hue
1267 { NULL, NULL, NULL }, // satura tion
1268 { NULL, NULL, NULL }, // color
1269 { NULL, NULL, NULL }, // lumino sity
1270 };
1271
1272 SkXfermodeProc16 SkXfermode::GetProc16(Mode mode, SkColor srcColor) {
1273 SkXfermodeProc16 proc16 = NULL;
1274 if ((unsigned)mode < kModeCount) {
1275 const Proc16Rec& rec = gModeProcs16[mode];
1276 unsigned a = SkColorGetA(srcColor);
1277
1278 if (0 == a) {
1279 proc16 = rec.fProc16_0;
1280 } else if (255 == a) {
1281 proc16 = rec.fProc16_255;
1282 } else {
1283 proc16 = rec.fProc16_General;
1284 }
1285 }
1286 return proc16;
1287 }
1288
1289 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkXfermode) 1116 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkXfermode)
1290 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkProcCoeffXfermode) 1117 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkProcCoeffXfermode)
1291 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END 1118 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END
OLDNEW
« no previous file with comments | « include/core/SkXfermode.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698