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

Side by Side Diff: ui/gfx/skia_util.cc

Issue 1752953003: Replace uses of SkFixed for HarfBuzz conversions. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 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 | « ui/gfx/skia_util.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ui/gfx/skia_util.h" 5 #include "ui/gfx/skia_util.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include "base/numerics/safe_conversions.h"
10 #include "third_party/skia/include/core/SkBitmap.h" 11 #include "third_party/skia/include/core/SkBitmap.h"
11 #include "third_party/skia/include/core/SkColorFilter.h" 12 #include "third_party/skia/include/core/SkColorFilter.h"
12 #include "third_party/skia/include/core/SkColorPriv.h" 13 #include "third_party/skia/include/core/SkColorPriv.h"
13 #include "third_party/skia/include/core/SkUnPreMultiply.h" 14 #include "third_party/skia/include/core/SkUnPreMultiply.h"
14 #include "third_party/skia/include/effects/SkBlurMaskFilter.h" 15 #include "third_party/skia/include/effects/SkBlurMaskFilter.h"
15 #include "third_party/skia/include/effects/SkGradientShader.h" 16 #include "third_party/skia/include/effects/SkGradientShader.h"
16 #include "third_party/skia/include/effects/SkLayerDrawLooper.h" 17 #include "third_party/skia/include/effects/SkLayerDrawLooper.h"
17 #include "ui/gfx/geometry/quad_f.h" 18 #include "ui/gfx/geometry/quad_f.h"
18 #include "ui/gfx/geometry/rect.h" 19 #include "ui/gfx/geometry/rect.h"
19 #include "ui/gfx/geometry/rect_f.h" 20 #include "ui/gfx/geometry/rect_f.h"
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after
219 } 220 }
220 } 221 }
221 222
222 void QuadFToSkPoints(const gfx::QuadF& quad, SkPoint points[4]) { 223 void QuadFToSkPoints(const gfx::QuadF& quad, SkPoint points[4]) {
223 points[0] = PointFToSkPoint(quad.p1()); 224 points[0] = PointFToSkPoint(quad.p1());
224 points[1] = PointFToSkPoint(quad.p2()); 225 points[1] = PointFToSkPoint(quad.p2());
225 points[2] = PointFToSkPoint(quad.p3()); 226 points[2] = PointFToSkPoint(quad.p3());
226 points[3] = PointFToSkPoint(quad.p4()); 227 points[3] = PointFToSkPoint(quad.p4());
227 } 228 }
228 229
230 // We treat HarfBuzz ints as 16.16 fixed-point.
231 static const int kHbUnit1 = 1 << 16;
232
233 int SkiaScalarToHarfBuzzUnits(SkScalar value) {
234 return base::saturated_cast<int>(value * kHbUnit1);
235 }
236
237 SkScalar HarfBuzzUnitsToSkiaScalar(int value) {
238 static const SkScalar kSkToHbRatio = SK_Scalar1 / kHbUnit1;
239 return kSkToHbRatio * value;
240 }
241
242 float HarfBuzzUnitsToFloat(int value) {
243 static const float kFloatToHbRatio = 1.0f / kHbUnit1;
244 return kFloatToHbRatio * value;
245 }
246
229 } // namespace gfx 247 } // namespace gfx
OLDNEW
« no previous file with comments | « ui/gfx/skia_util.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698