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

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

Issue 117053002: remove SK_SCALAR_IS_[FLOAT,FIXED] and assume floats (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 7 years 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 | Annotate | Revision Log
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 "SkPaint.h" 9 #include "SkPaint.h"
10 #include "SkAnnotation.h" 10 #include "SkAnnotation.h"
(...skipping 992 matching lines...) Expand 10 before | Expand all | Expand 10 after
1003 bounds->set(SkIntToScalar(g.fLeft), 1003 bounds->set(SkIntToScalar(g.fLeft),
1004 SkIntToScalar(g.fTop), 1004 SkIntToScalar(g.fTop),
1005 SkIntToScalar(g.fLeft + g.fWidth), 1005 SkIntToScalar(g.fLeft + g.fWidth),
1006 SkIntToScalar(g.fTop + g.fHeight)); 1006 SkIntToScalar(g.fTop + g.fHeight));
1007 } 1007 }
1008 1008
1009 // 64bits wide, with a 16bit bias. Useful when accumulating lots of 16.16 so 1009 // 64bits wide, with a 16bit bias. Useful when accumulating lots of 16.16 so
1010 // we don't overflow along the way 1010 // we don't overflow along the way
1011 typedef int64_t Sk48Dot16; 1011 typedef int64_t Sk48Dot16;
1012 1012
1013 #ifdef SK_SCALAR_IS_FLOAT 1013 static inline float Sk48Dot16ToScalar(Sk48Dot16 x) {
1014 static inline float Sk48Dot16ToScalar(Sk48Dot16 x) { 1014 return (float) (x * 1.5258789e-5); // x * (1 / 65536.0f)
1015 return (float) (x * 1.5258789e-5); // x * (1 / 65536.0f) 1015 }
1016 }
1017 #else
1018 static inline SkFixed Sk48Dot16ToScalar(Sk48Dot16 x) {
1019 // just return the low 32bits
1020 return static_cast<SkFixed>(x);
1021 }
1022 #endif
1023 1016
1024 static void join_bounds_x(const SkGlyph& g, SkRect* bounds, Sk48Dot16 dx) { 1017 static void join_bounds_x(const SkGlyph& g, SkRect* bounds, Sk48Dot16 dx) {
1025 SkScalar sx = Sk48Dot16ToScalar(dx); 1018 SkScalar sx = Sk48Dot16ToScalar(dx);
1026 bounds->join(SkIntToScalar(g.fLeft) + sx, 1019 bounds->join(SkIntToScalar(g.fLeft) + sx,
1027 SkIntToScalar(g.fTop), 1020 SkIntToScalar(g.fTop),
1028 SkIntToScalar(g.fLeft + g.fWidth) + sx, 1021 SkIntToScalar(g.fLeft + g.fWidth) + sx,
1029 SkIntToScalar(g.fTop + g.fHeight)); 1022 SkIntToScalar(g.fTop + g.fHeight));
1030 } 1023 }
1031 1024
1032 static void join_bounds_y(const SkGlyph& g, SkRect* bounds, Sk48Dot16 dy) { 1025 static void join_bounds_y(const SkGlyph& g, SkRect* bounds, Sk48Dot16 dy) {
(...skipping 516 matching lines...) Expand 10 before | Expand all | Expand 10 after
1549 SkScalar size = SkScalarMul(area, rec.fTextSize); 1542 SkScalar size = SkScalarMul(area, rec.fTextSize);
1550 return SkScalarAbs(size) > SkIntToScalar(SK_MAX_SIZE_FOR_LCDTEXT); 1543 return SkScalarAbs(size) > SkIntToScalar(SK_MAX_SIZE_FOR_LCDTEXT);
1551 } 1544 }
1552 1545
1553 /* 1546 /*
1554 * Return the scalar with only limited fractional precision. Used to consolidat e matrices 1547 * Return the scalar with only limited fractional precision. Used to consolidat e matrices
1555 * that vary only slightly when we create our key into the font cache, since th e font scaler 1548 * that vary only slightly when we create our key into the font cache, since th e font scaler
1556 * typically returns the same looking resuts for tiny changes in the matrix. 1549 * typically returns the same looking resuts for tiny changes in the matrix.
1557 */ 1550 */
1558 static SkScalar sk_relax(SkScalar x) { 1551 static SkScalar sk_relax(SkScalar x) {
1559 #ifdef SK_SCALAR_IS_FLOAT
1560 int n = sk_float_round2int(x * 1024); 1552 int n = sk_float_round2int(x * 1024);
1561 return n / 1024.0f; 1553 return n / 1024.0f;
1562 #else
1563 // round to the nearest 10 fractional bits
1564 return (x + (1 << 5)) & ~(1024 - 1);
1565 #endif
1566 } 1554 }
1567 1555
1568 void SkScalerContext::MakeRec(const SkPaint& paint, 1556 void SkScalerContext::MakeRec(const SkPaint& paint,
1569 const SkDeviceProperties* deviceProperties, 1557 const SkDeviceProperties* deviceProperties,
1570 const SkMatrix* deviceMatrix, 1558 const SkMatrix* deviceMatrix,
1571 Rec* rec) { 1559 Rec* rec) {
1572 SkASSERT(deviceMatrix == NULL || !deviceMatrix->hasPerspective()); 1560 SkASSERT(deviceMatrix == NULL || !deviceMatrix->hasPerspective());
1573 1561
1574 SkTypeface* typeface = paint.getTypeface(); 1562 SkTypeface* typeface = paint.getTypeface();
1575 if (NULL == typeface) { 1563 if (NULL == typeface) {
(...skipping 1015 matching lines...) Expand 10 before | Expand all | Expand 10 after
2591 case SkXfermode::kPlus_Mode: 2579 case SkXfermode::kPlus_Mode:
2592 return 0 == this->getAlpha(); 2580 return 0 == this->getAlpha();
2593 case SkXfermode::kDst_Mode: 2581 case SkXfermode::kDst_Mode:
2594 return true; 2582 return true;
2595 default: 2583 default:
2596 break; 2584 break;
2597 } 2585 }
2598 } 2586 }
2599 return false; 2587 return false;
2600 } 2588 }
OLDNEW
« src/core/SkCanvas.cpp ('K') | « src/core/SkMatrix.cpp ('k') | src/core/SkPathMeasure.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698