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

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

Issue 1683743005: Simple cleanups related to SkFixed. (Closed) Base URL: https://skia.googlesource.com/skia@master
Patch Set: Created 4 years, 10 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 1010 matching lines...) Expand 10 before | Expand all | Expand 10 after
1021 if (scale) { 1021 if (scale) {
1022 maxWidth /= scale; 1022 maxWidth /= scale;
1023 } 1023 }
1024 1024
1025 SkAutoGlyphCache autoCache(paint, nullptr, nullptr); 1025 SkAutoGlyphCache autoCache(paint, nullptr, nullptr);
1026 SkGlyphCache* cache = autoCache.getCache(); 1026 SkGlyphCache* cache = autoCache.getCache();
1027 1027
1028 SkMeasureCacheProc glyphCacheProc = paint.getMeasureCacheProc(false); 1028 SkMeasureCacheProc glyphCacheProc = paint.getMeasureCacheProc(false);
1029 const int xyIndex = paint.isVerticalText() ? 1 : 0; 1029 const int xyIndex = paint.isVerticalText() ? 1 : 0;
1030 // use 64bits for our accumulator, to avoid overflowing 16.16 1030 // use 64bits for our accumulator, to avoid overflowing 16.16
1031 Sk48Dot16 max = SkScalarToFixed(maxWidth); 1031 Sk48Dot16 max = SkScalarTo48Dot16(maxWidth);
reed1 2016/02/11 21:43:44 Wow, this seems like a bug bug. Is/was there a tes
dogben 2016/02/11 21:53:13 The previous code was actually fine, assuming maxW
reed1 2016/02/11 22:22:59 So we could write a test that measures a big strin
dogben 2016/02/12 02:35:24 Oh! For some reason I was thinking that was the wi
1032 Sk48Dot16 width = 0; 1032 Sk48Dot16 width = 0;
1033 1033
1034 SkAutoKern autokern; 1034 SkAutoKern autokern;
1035 1035
1036 if (this->isDevKernText()) { 1036 if (this->isDevKernText()) {
1037 int rsb = 0; 1037 int rsb = 0;
1038 while (text < stop) { 1038 while (text < stop) {
1039 const char* curr = text; 1039 const char* curr = text;
1040 const SkGlyph& g = glyphCacheProc(cache, &text); 1040 const SkGlyph& g = glyphCacheProc(cache, &text);
1041 SkFixed x = SkAutoKern_AdjustF(rsb, g.fLsbDelta) + advance(g, xyInde x); 1041 SkFixed x = SkAutoKern_AdjustF(rsb, g.fLsbDelta) + advance(g, xyInde x);
(...skipping 1488 matching lines...) Expand 10 before | Expand all | Expand 10 after
2530 } 2530 }
2531 2531
2532 uint32_t SkPaint::getHash() const { 2532 uint32_t SkPaint::getHash() const {
2533 // We're going to hash 10 pointers and 7 32-bit values, finishing up with fB itfields, 2533 // We're going to hash 10 pointers and 7 32-bit values, finishing up with fB itfields,
2534 // so fBitfields should be 10 pointers and 6 32-bit values from the start. 2534 // so fBitfields should be 10 pointers and 6 32-bit values from the start.
2535 static_assert(offsetof(SkPaint, fBitfields) == 10 * sizeof(void*) + 6 * size of(uint32_t), 2535 static_assert(offsetof(SkPaint, fBitfields) == 10 * sizeof(void*) + 6 * size of(uint32_t),
2536 "SkPaint_notPackedTightly"); 2536 "SkPaint_notPackedTightly");
2537 return SkChecksum::Murmur3(reinterpret_cast<const uint32_t*>(this), 2537 return SkChecksum::Murmur3(reinterpret_cast<const uint32_t*>(this),
2538 offsetof(SkPaint, fBitfields) + sizeof(fBitfields )); 2538 offsetof(SkPaint, fBitfields) + sizeof(fBitfields ));
2539 } 2539 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698