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/SkPaint.cpp

Issue 551463004: introduce Props to surface (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: fix no-gpu after rebase Created 6 years, 3 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
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 1520 matching lines...) Expand 10 before | Expand all | Expand 10 after
1531 /* 1531 /*
1532 * Return the scalar with only limited fractional precision. Used to consolidat e matrices 1532 * Return the scalar with only limited fractional precision. Used to consolidat e matrices
1533 * that vary only slightly when we create our key into the font cache, since th e font scaler 1533 * that vary only slightly when we create our key into the font cache, since th e font scaler
1534 * typically returns the same looking resuts for tiny changes in the matrix. 1534 * typically returns the same looking resuts for tiny changes in the matrix.
1535 */ 1535 */
1536 static SkScalar sk_relax(SkScalar x) { 1536 static SkScalar sk_relax(SkScalar x) {
1537 int n = sk_float_round2int(x * 1024); 1537 int n = sk_float_round2int(x * 1024);
1538 return n / 1024.0f; 1538 return n / 1024.0f;
1539 } 1539 }
1540 1540
1541 static SkPixelGeometry get_default_pixel_geometry() {
1542 return SkSurfaceProps(SkSurfaceProps::kLegacyFontHost_InitType).pixelGeometr y();
1543 }
1544
1545 SkDeviceProperties::SkDeviceProperties(SkDeviceProperties::InitType)
bungeman-skia 2014/09/19 18:29:51 This is only used by SkBaseDevice, why is it here?
reed1 2014/09/19 19:16:34 will remove
1546 : fPixelGeometry(get_default_pixel_geometry())
1547 {}
1548
1541 void SkScalerContext::MakeRec(const SkPaint& paint, 1549 void SkScalerContext::MakeRec(const SkPaint& paint,
1542 const SkDeviceProperties* deviceProperties, 1550 const SkDeviceProperties* deviceProperties,
1543 const SkMatrix* deviceMatrix, 1551 const SkMatrix* deviceMatrix,
1544 Rec* rec) { 1552 Rec* rec) {
1545 SkASSERT(deviceMatrix == NULL || !deviceMatrix->hasPerspective()); 1553 SkASSERT(deviceMatrix == NULL || !deviceMatrix->hasPerspective());
1546 1554
1547 SkTypeface* typeface = paint.getTypeface(); 1555 SkTypeface* typeface = paint.getTypeface();
1548 if (NULL == typeface) { 1556 if (NULL == typeface) {
1549 typeface = SkTypeface::GetDefaultTypeface(); 1557 typeface = SkTypeface::GetDefaultTypeface();
1550 } 1558 }
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
1600 flags |= SkScalerContext::kFrameAndFill_Flag; 1608 flags |= SkScalerContext::kFrameAndFill_Flag;
1601 } 1609 }
1602 } else { 1610 } else {
1603 rec->fFrameWidth = 0; 1611 rec->fFrameWidth = 0;
1604 rec->fMiterLimit = 0; 1612 rec->fMiterLimit = 0;
1605 rec->fStrokeJoin = 0; 1613 rec->fStrokeJoin = 0;
1606 } 1614 }
1607 1615
1608 rec->fMaskFormat = SkToU8(computeMaskFormat(paint)); 1616 rec->fMaskFormat = SkToU8(computeMaskFormat(paint));
1609 1617
1610 SkDeviceProperties::Geometry geometry = deviceProperties
1611 ? deviceProperties->fGeometry
1612 : SkDeviceProperties::Geometry::MakeDe fault();
1613 if (SkMask::kLCD16_Format == rec->fMaskFormat || SkMask::kLCD32_Format == re c->fMaskFormat) { 1618 if (SkMask::kLCD16_Format == rec->fMaskFormat || SkMask::kLCD32_Format == re c->fMaskFormat) {
1614 if (!geometry.isOrientationKnown() || !geometry.isLayoutKnown() || tooBi gForLCD(*rec)) { 1619 if (tooBigForLCD(*rec)) {
1615 // eeek, can't support LCD
1616 rec->fMaskFormat = SkMask::kA8_Format; 1620 rec->fMaskFormat = SkMask::kA8_Format;
1621 flags |= SkScalerContext::kGenA8FromLCD_Flag;
1617 } else { 1622 } else {
1618 if (SkDeviceProperties::Geometry::kVertical_Orientation == geometry. getOrientation()) { 1623 SkPixelGeometry geometry = deviceProperties
1619 flags |= SkScalerContext::kLCD_Vertical_Flag; 1624 ? deviceProperties->fPixelGeometry
bungeman-skia 2014/09/19 18:29:51 nit: this '?' and ':' should line up with the '='
reed1 2014/09/19 19:16:34 Done.
1620 } 1625 : get_default_pixel_geometry();
1621 if (SkDeviceProperties::Geometry::kBGR_Layout == geometry.getLayout( )) { 1626 switch (geometry) {
1622 flags |= SkScalerContext::kLCD_BGROrder_Flag; 1627 case kUnknown_SkPixelGeometry:
1628 // eeek, can't support LCD
1629 rec->fMaskFormat = SkMask::kA8_Format;
1630 flags |= SkScalerContext::kGenA8FromLCD_Flag;
1631 break;
1632 case kRGB_H_SkPixelGeometry:
1633 // our default, do nothing.
1634 break;
1635 case kBGR_H_SkPixelGeometry:
1636 flags |= SkScalerContext::kLCD_BGROrder_Flag;
1637 break;
1638 case kRGB_V_SkPixelGeometry:
1639 flags |= SkScalerContext::kLCD_Vertical_Flag;
1640 break;
1641 case kBGR_V_SkPixelGeometry:
1642 flags |= SkScalerContext::kLCD_Vertical_Flag;
1643 flags |= SkScalerContext::kLCD_BGROrder_Flag;
1644 break;
1623 } 1645 }
1624 } 1646 }
1625 } 1647 }
1626 1648
1627 if (paint.isEmbeddedBitmapText()) { 1649 if (paint.isEmbeddedBitmapText()) {
1628 flags |= SkScalerContext::kEmbeddedBitmapText_Flag; 1650 flags |= SkScalerContext::kEmbeddedBitmapText_Flag;
1629 } 1651 }
1630 if (paint.isSubpixelText()) { 1652 if (paint.isSubpixelText()) {
1631 flags |= SkScalerContext::kSubpixelPositioning_Flag; 1653 flags |= SkScalerContext::kSubpixelPositioning_Flag;
1632 } 1654 }
(...skipping 10 matching lines...) Expand all
1643 1665
1644 // these modify fFlags, so do them after assigning fFlags 1666 // these modify fFlags, so do them after assigning fFlags
1645 rec->setHinting(computeHinting(paint)); 1667 rec->setHinting(computeHinting(paint));
1646 1668
1647 rec->setLuminanceColor(computeLuminanceColor(paint)); 1669 rec->setLuminanceColor(computeLuminanceColor(paint));
1648 1670
1649 if (NULL == deviceProperties) { 1671 if (NULL == deviceProperties) {
1650 rec->setDeviceGamma(SK_GAMMA_EXPONENT); 1672 rec->setDeviceGamma(SK_GAMMA_EXPONENT);
1651 rec->setPaintGamma(SK_GAMMA_EXPONENT); 1673 rec->setPaintGamma(SK_GAMMA_EXPONENT);
1652 } else { 1674 } else {
1653 rec->setDeviceGamma(deviceProperties->fGamma); 1675 rec->setDeviceGamma(deviceProperties->getGamma());
1654 1676
1655 //For now always set the paint gamma equal to the device gamma. 1677 //For now always set the paint gamma equal to the device gamma.
1656 //The math in SkMaskGamma can handle them being different, 1678 //The math in SkMaskGamma can handle them being different,
1657 //but it requires superluminous masks when 1679 //but it requires superluminous masks when
1658 //Ex : deviceGamma(x) < paintGamma(x) and x is sufficiently large. 1680 //Ex : deviceGamma(x) < paintGamma(x) and x is sufficiently large.
1659 rec->setPaintGamma(deviceProperties->fGamma); 1681 rec->setPaintGamma(deviceProperties->getGamma());
1660 } 1682 }
1661 1683
1662 #ifdef SK_GAMMA_CONTRAST 1684 #ifdef SK_GAMMA_CONTRAST
1663 rec->setContrast(SK_GAMMA_CONTRAST); 1685 rec->setContrast(SK_GAMMA_CONTRAST);
1664 #else 1686 #else
1665 /** 1687 /**
1666 * A value of 0.5 for SK_GAMMA_CONTRAST appears to be a good compromise. 1688 * A value of 0.5 for SK_GAMMA_CONTRAST appears to be a good compromise.
1667 * With lower values small text appears washed out (though correctly so). 1689 * With lower values small text appears washed out (though correctly so).
1668 * With higher values lcd fringing is worse and the smoothing effect of 1690 * With higher values lcd fringing is worse and the smoothing effect of
1669 * partial coverage is diminished. 1691 * partial coverage is diminished.
(...skipping 1000 matching lines...) Expand 10 before | Expand all | Expand 10 after
2670 F_UNREF(Looper, readDrawLooper); 2692 F_UNREF(Looper, readDrawLooper);
2671 F_UNREF(ImageFilter, readImageFilter); 2693 F_UNREF(ImageFilter, readImageFilter);
2672 F(Typeface, readTypeface); 2694 F(Typeface, readTypeface);
2673 #undef F 2695 #undef F
2674 #undef F_UNREF 2696 #undef F_UNREF
2675 if (dirty & kAnnotation_DirtyBit) { 2697 if (dirty & kAnnotation_DirtyBit) {
2676 paint->setAnnotation(SkAnnotation::Create(buffer))->unref(); 2698 paint->setAnnotation(SkAnnotation::Create(buffer))->unref();
2677 } 2699 }
2678 SkASSERT(dirty == paint->fDirtyBits); 2700 SkASSERT(dirty == paint->fDirtyBits);
2679 } 2701 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698