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

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

Issue 652273002: add gamma value to deviceproperties (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 2 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 | « src/core/SkDeviceProperties.h ('k') | src/gpu/GrDistanceFieldTextContext.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 1451 matching lines...) Expand 10 before | Expand all | Expand 10 after
1462 } 1462 }
1463 1463
1464 rec->fMaskFormat = SkToU8(computeMaskFormat(paint)); 1464 rec->fMaskFormat = SkToU8(computeMaskFormat(paint));
1465 1465
1466 if (SkMask::kLCD16_Format == rec->fMaskFormat || SkMask::kLCD32_Format == re c->fMaskFormat) { 1466 if (SkMask::kLCD16_Format == rec->fMaskFormat || SkMask::kLCD32_Format == re c->fMaskFormat) {
1467 if (too_big_for_lcd(*rec, checkPost2x2)) { 1467 if (too_big_for_lcd(*rec, checkPost2x2)) {
1468 rec->fMaskFormat = SkMask::kA8_Format; 1468 rec->fMaskFormat = SkMask::kA8_Format;
1469 flags |= SkScalerContext::kGenA8FromLCD_Flag; 1469 flags |= SkScalerContext::kGenA8FromLCD_Flag;
1470 } else { 1470 } else {
1471 SkPixelGeometry geometry = deviceProperties 1471 SkPixelGeometry geometry = deviceProperties
1472 ? deviceProperties->fPixelGeometry 1472 ? deviceProperties->pixelGeometry()
1473 : SkSurfacePropsDefaultPixelGeometry(); 1473 : SkSurfacePropsDefaultPixelGeometry();
1474 switch (geometry) { 1474 switch (geometry) {
1475 case kUnknown_SkPixelGeometry: 1475 case kUnknown_SkPixelGeometry:
1476 // eeek, can't support LCD 1476 // eeek, can't support LCD
1477 rec->fMaskFormat = SkMask::kA8_Format; 1477 rec->fMaskFormat = SkMask::kA8_Format;
1478 flags |= SkScalerContext::kGenA8FromLCD_Flag; 1478 flags |= SkScalerContext::kGenA8FromLCD_Flag;
1479 break; 1479 break;
1480 case kRGB_H_SkPixelGeometry: 1480 case kRGB_H_SkPixelGeometry:
1481 // our default, do nothing. 1481 // our default, do nothing.
1482 break; 1482 break;
(...skipping 30 matching lines...) Expand all
1513 1513
1514 // these modify fFlags, so do them after assigning fFlags 1514 // these modify fFlags, so do them after assigning fFlags
1515 rec->setHinting(computeHinting(paint)); 1515 rec->setHinting(computeHinting(paint));
1516 1516
1517 rec->setLuminanceColor(computeLuminanceColor(paint)); 1517 rec->setLuminanceColor(computeLuminanceColor(paint));
1518 1518
1519 if (NULL == deviceProperties) { 1519 if (NULL == deviceProperties) {
1520 rec->setDeviceGamma(SK_GAMMA_EXPONENT); 1520 rec->setDeviceGamma(SK_GAMMA_EXPONENT);
1521 rec->setPaintGamma(SK_GAMMA_EXPONENT); 1521 rec->setPaintGamma(SK_GAMMA_EXPONENT);
1522 } else { 1522 } else {
1523 rec->setDeviceGamma(deviceProperties->getGamma()); 1523 rec->setDeviceGamma(deviceProperties->gamma());
1524 1524
1525 //For now always set the paint gamma equal to the device gamma. 1525 //For now always set the paint gamma equal to the device gamma.
1526 //The math in SkMaskGamma can handle them being different, 1526 //The math in SkMaskGamma can handle them being different,
1527 //but it requires superluminous masks when 1527 //but it requires superluminous masks when
1528 //Ex : deviceGamma(x) < paintGamma(x) and x is sufficiently large. 1528 //Ex : deviceGamma(x) < paintGamma(x) and x is sufficiently large.
1529 rec->setPaintGamma(deviceProperties->getGamma()); 1529 rec->setPaintGamma(deviceProperties->gamma());
1530 } 1530 }
1531 1531
1532 #ifdef SK_GAMMA_CONTRAST 1532 #ifdef SK_GAMMA_CONTRAST
1533 rec->setContrast(SK_GAMMA_CONTRAST); 1533 rec->setContrast(SK_GAMMA_CONTRAST);
1534 #else 1534 #else
1535 /** 1535 /**
1536 * A value of 0.5 for SK_GAMMA_CONTRAST appears to be a good compromise. 1536 * A value of 0.5 for SK_GAMMA_CONTRAST appears to be a good compromise.
1537 * With lower values small text appears washed out (though correctly so). 1537 * With lower values small text appears washed out (though correctly so).
1538 * With higher values lcd fringing is worse and the smoothing effect of 1538 * With higher values lcd fringing is worse and the smoothing effect of
1539 * partial coverage is diminished. 1539 * partial coverage is diminished.
(...skipping 922 matching lines...) Expand 10 before | Expand all | Expand 10 after
2462 } 2462 }
2463 2463
2464 uint32_t SkPaint::getHash() const { 2464 uint32_t SkPaint::getHash() const {
2465 // We're going to hash 10 pointers and 7 32-bit values, finishing up with fB itfields, 2465 // We're going to hash 10 pointers and 7 32-bit values, finishing up with fB itfields,
2466 // so fBitfields should be 10 pointers and 6 32-bit values from the start. 2466 // so fBitfields should be 10 pointers and 6 32-bit values from the start.
2467 SK_COMPILE_ASSERT(offsetof(SkPaint, fBitfields) == 10 * sizeof(void*) + 6 * sizeof(uint32_t), 2467 SK_COMPILE_ASSERT(offsetof(SkPaint, fBitfields) == 10 * sizeof(void*) + 6 * sizeof(uint32_t),
2468 SkPaint_notPackedTightly); 2468 SkPaint_notPackedTightly);
2469 return SkChecksum::Murmur3(reinterpret_cast<const uint32_t*>(this), 2469 return SkChecksum::Murmur3(reinterpret_cast<const uint32_t*>(this),
2470 offsetof(SkPaint, fBitfields) + sizeof(fBitfields )); 2470 offsetof(SkPaint, fBitfields) + sizeof(fBitfields ));
2471 } 2471 }
OLDNEW
« no previous file with comments | « src/core/SkDeviceProperties.h ('k') | src/gpu/GrDistanceFieldTextContext.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698