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

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

Issue 1076593002: Start canonicalizing color for all A8 textblobs (Closed) Base URL: https://skia.googlesource.com/skia.git@atcachemasks
Patch Set: nits Created 5 years, 8 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/SkTextBlob.h ('k') | src/core/SkTextBlob.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 2006 The Android Open Source Project 2 * Copyright 2006 The Android Open Source Project
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 "SkPaint.h" 8 #include "SkPaint.h"
9 #include "SkAnnotation.h" 9 #include "SkAnnotation.h"
10 #include "SkAutoKern.h" 10 #include "SkAutoKern.h"
(...skipping 1273 matching lines...) Expand 10 before | Expand all | Expand 10 after
1284 } 1284 }
1285 if (paint.getColorFilter()) { 1285 if (paint.getColorFilter()) {
1286 c = paint.getColorFilter()->filterColor(c); 1286 c = paint.getColorFilter()->filterColor(c);
1287 } 1287 }
1288 if (color) { 1288 if (color) {
1289 *color = c; 1289 *color = c;
1290 } 1290 }
1291 return true; 1291 return true;
1292 } 1292 }
1293 1293
1294 static SkColor computeLuminanceColor(const SkPaint& paint) { 1294 SkColor SkPaint::computeLuminanceColor() const {
1295 SkColor c; 1295 SkColor c;
1296 if (!justAColor(paint, &c)) { 1296 if (!justAColor(*this, &c)) {
1297 c = SkColorSetRGB(0x7F, 0x80, 0x7F); 1297 c = SkColorSetRGB(0x7F, 0x80, 0x7F);
1298 } 1298 }
1299 return c; 1299 return c;
1300 } 1300 }
1301 1301
1302 #define assert_byte(x) SkASSERT(0 == ((x) >> 8)) 1302 #define assert_byte(x) SkASSERT(0 == ((x) >> 8))
1303 1303
1304 // Beyond this size, LCD doesn't appreciably improve quality, but it always 1304 // Beyond this size, LCD doesn't appreciably improve quality, but it always
1305 // cost more RAM and draws slower, so we set a cap. 1305 // cost more RAM and draws slower, so we set a cap.
1306 #ifndef SK_MAX_SIZE_FOR_LCDTEXT 1306 #ifndef SK_MAX_SIZE_FOR_LCDTEXT
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
1456 flags |= SkScalerContext::kVertical_Flag; 1456 flags |= SkScalerContext::kVertical_Flag;
1457 } 1457 }
1458 if (paint.getFlags() & SkPaint::kGenA8FromLCD_Flag) { 1458 if (paint.getFlags() & SkPaint::kGenA8FromLCD_Flag) {
1459 flags |= SkScalerContext::kGenA8FromLCD_Flag; 1459 flags |= SkScalerContext::kGenA8FromLCD_Flag;
1460 } 1460 }
1461 rec->fFlags = SkToU16(flags); 1461 rec->fFlags = SkToU16(flags);
1462 1462
1463 // these modify fFlags, so do them after assigning fFlags 1463 // these modify fFlags, so do them after assigning fFlags
1464 rec->setHinting(computeHinting(paint)); 1464 rec->setHinting(computeHinting(paint));
1465 1465
1466 rec->setLuminanceColor(computeLuminanceColor(paint)); 1466 rec->setLuminanceColor(paint.computeLuminanceColor());
1467 1467
1468 if (NULL == deviceProperties) { 1468 if (NULL == deviceProperties) {
1469 rec->setDeviceGamma(SK_GAMMA_EXPONENT); 1469 rec->setDeviceGamma(SK_GAMMA_EXPONENT);
1470 rec->setPaintGamma(SK_GAMMA_EXPONENT); 1470 rec->setPaintGamma(SK_GAMMA_EXPONENT);
1471 } else { 1471 } else {
1472 rec->setDeviceGamma(deviceProperties->gamma()); 1472 rec->setDeviceGamma(deviceProperties->gamma());
1473 1473
1474 //For now always set the paint gamma equal to the device gamma. 1474 //For now always set the paint gamma equal to the device gamma.
1475 //The math in SkMaskGamma can handle them being different, 1475 //The math in SkMaskGamma can handle them being different,
1476 //but it requires superluminous masks when 1476 //but it requires superluminous masks when
(...skipping 953 matching lines...) Expand 10 before | Expand all | Expand 10 after
2430 } 2430 }
2431 2431
2432 uint32_t SkPaint::getHash() const { 2432 uint32_t SkPaint::getHash() const {
2433 // We're going to hash 10 pointers and 7 32-bit values, finishing up with fB itfields, 2433 // We're going to hash 10 pointers and 7 32-bit values, finishing up with fB itfields,
2434 // so fBitfields should be 10 pointers and 6 32-bit values from the start. 2434 // so fBitfields should be 10 pointers and 6 32-bit values from the start.
2435 SK_COMPILE_ASSERT(offsetof(SkPaint, fBitfields) == 10 * sizeof(void*) + 6 * sizeof(uint32_t), 2435 SK_COMPILE_ASSERT(offsetof(SkPaint, fBitfields) == 10 * sizeof(void*) + 6 * sizeof(uint32_t),
2436 SkPaint_notPackedTightly); 2436 SkPaint_notPackedTightly);
2437 return SkChecksum::Murmur3(reinterpret_cast<const uint32_t*>(this), 2437 return SkChecksum::Murmur3(reinterpret_cast<const uint32_t*>(this),
2438 offsetof(SkPaint, fBitfields) + sizeof(fBitfields )); 2438 offsetof(SkPaint, fBitfields) + sizeof(fBitfields ));
2439 } 2439 }
OLDNEW
« no previous file with comments | « include/core/SkTextBlob.h ('k') | src/core/SkTextBlob.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698