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

Side by Side Diff: include/core/SkPoint.h

Issue 615993003: optimize setRectFan and join -- from profiling drawText (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 | « no previous file | src/core/SkPoint.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 #ifndef SkPoint_DEFINED 8 #ifndef SkPoint_DEFINED
9 #define SkPoint_DEFINED 9 #define SkPoint_DEFINED
10 10
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
205 void setIRectFan(int l, int t, int r, int b, size_t stride); 205 void setIRectFan(int l, int t, int r, int b, size_t stride);
206 206
207 // counter-clockwise fan 207 // counter-clockwise fan
208 void setRectFan(SkScalar l, SkScalar t, SkScalar r, SkScalar b) { 208 void setRectFan(SkScalar l, SkScalar t, SkScalar r, SkScalar b) {
209 SkPoint* v = this; 209 SkPoint* v = this;
210 v[0].set(l, t); 210 v[0].set(l, t);
211 v[1].set(l, b); 211 v[1].set(l, b);
212 v[2].set(r, b); 212 v[2].set(r, b);
213 v[3].set(r, t); 213 v[3].set(r, t);
214 } 214 }
215 void setRectFan(SkScalar l, SkScalar t, SkScalar r, SkScalar b, size_t strid e); 215
216 void setRectFan(SkScalar l, SkScalar t, SkScalar r, SkScalar b, size_t strid e) {
217 SkASSERT(stride >= sizeof(SkPoint));
218
219 ((SkPoint*)((intptr_t)this + 0 * stride))->set(l, t);
220 ((SkPoint*)((intptr_t)this + 1 * stride))->set(l, b);
221 ((SkPoint*)((intptr_t)this + 2 * stride))->set(r, b);
222 ((SkPoint*)((intptr_t)this + 3 * stride))->set(r, t);
223 }
224
216 225
217 static void Offset(SkPoint points[], int count, const SkPoint& offset) { 226 static void Offset(SkPoint points[], int count, const SkPoint& offset) {
218 Offset(points, count, offset.fX, offset.fY); 227 Offset(points, count, offset.fX, offset.fY);
219 } 228 }
220 229
221 static void Offset(SkPoint points[], int count, SkScalar dx, SkScalar dy) { 230 static void Offset(SkPoint points[], int count, SkScalar dx, SkScalar dy) {
222 for (int i = 0; i < count; ++i) { 231 for (int i = 0; i < count; ++i) {
223 points[i].offset(dx, dy); 232 points[i].offset(dx, dy);
224 } 233 }
225 } 234 }
(...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after
524 533
525 /** 534 /**
526 * cast-safe way to treat the point as an array of (2) SkScalars. 535 * cast-safe way to treat the point as an array of (2) SkScalars.
527 */ 536 */
528 const SkScalar* asScalars() const { return &fX; } 537 const SkScalar* asScalars() const { return &fX; }
529 }; 538 };
530 539
531 typedef SkPoint SkVector; 540 typedef SkPoint SkVector;
532 541
533 #endif 542 #endif
OLDNEW
« no previous file with comments | « no previous file | src/core/SkPoint.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698