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

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

Issue 1548223002: remove cruft from SkTypes.h, including SkBool (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 11 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 | « src/animator/SkScript2.h ('k') | src/pipe/SkGPipeRead.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 #include "SkPaint.h" 8 #include "SkPaint.h"
9 #include "SkAnnotation.h" 9 #include "SkAnnotation.h"
10 #include "SkAutoKern.h" 10 #include "SkAutoKern.h"
(...skipping 18 matching lines...) Expand all
29 #include "SkStringUtils.h" 29 #include "SkStringUtils.h"
30 #include "SkStroke.h" 30 #include "SkStroke.h"
31 #include "SkTextFormatParams.h" 31 #include "SkTextFormatParams.h"
32 #include "SkTextToPathIter.h" 32 #include "SkTextToPathIter.h"
33 #include "SkTLazy.h" 33 #include "SkTLazy.h"
34 #include "SkTypeface.h" 34 #include "SkTypeface.h"
35 #include "SkStrokeRec.h" 35 #include "SkStrokeRec.h"
36 #include "SkSurfacePriv.h" 36 #include "SkSurfacePriv.h"
37 #include "SkXfermode.h" 37 #include "SkXfermode.h"
38 38
39 static inline uint32_t set_clear_mask(uint32_t bits, bool cond, uint32_t mask) {
40 return cond ? bits | mask : bits & ~mask;
41 }
42
39 // define this to get a printf for out-of-range parameter in setters 43 // define this to get a printf for out-of-range parameter in setters
40 // e.g. setTextSize(-1) 44 // e.g. setTextSize(-1)
41 //#define SK_REPORT_API_RANGE_CHECK 45 //#define SK_REPORT_API_RANGE_CHECK
42 46
43 SkPaint::SkPaint() { 47 SkPaint::SkPaint() {
44 fTypeface = nullptr; 48 fTypeface = nullptr;
45 fPathEffect = nullptr; 49 fPathEffect = nullptr;
46 fShader = nullptr; 50 fShader = nullptr;
47 fXfermode = nullptr; 51 fXfermode = nullptr;
48 fMaskFilter = nullptr; 52 fMaskFilter = nullptr;
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 181
178 void SkPaint::setHinting(Hinting hintingLevel) { 182 void SkPaint::setHinting(Hinting hintingLevel) {
179 fBitfields.fHinting = hintingLevel; 183 fBitfields.fHinting = hintingLevel;
180 } 184 }
181 185
182 void SkPaint::setFlags(uint32_t flags) { 186 void SkPaint::setFlags(uint32_t flags) {
183 fBitfields.fFlags = flags; 187 fBitfields.fFlags = flags;
184 } 188 }
185 189
186 void SkPaint::setAntiAlias(bool doAA) { 190 void SkPaint::setAntiAlias(bool doAA) {
187 this->setFlags(SkSetClearMask(fBitfields.fFlags, doAA, kAntiAlias_Flag)); 191 this->setFlags(set_clear_mask(fBitfields.fFlags, doAA, kAntiAlias_Flag));
188 } 192 }
189 193
190 void SkPaint::setDither(bool doDither) { 194 void SkPaint::setDither(bool doDither) {
191 this->setFlags(SkSetClearMask(fBitfields.fFlags, doDither, kDither_Flag)); 195 this->setFlags(set_clear_mask(fBitfields.fFlags, doDither, kDither_Flag));
192 } 196 }
193 197
194 void SkPaint::setSubpixelText(bool doSubpixel) { 198 void SkPaint::setSubpixelText(bool doSubpixel) {
195 this->setFlags(SkSetClearMask(fBitfields.fFlags, doSubpixel, kSubpixelText_F lag)); 199 this->setFlags(set_clear_mask(fBitfields.fFlags, doSubpixel, kSubpixelText_F lag));
196 } 200 }
197 201
198 void SkPaint::setLCDRenderText(bool doLCDRender) { 202 void SkPaint::setLCDRenderText(bool doLCDRender) {
199 this->setFlags(SkSetClearMask(fBitfields.fFlags, doLCDRender, kLCDRenderText _Flag)); 203 this->setFlags(set_clear_mask(fBitfields.fFlags, doLCDRender, kLCDRenderText _Flag));
200 } 204 }
201 205
202 void SkPaint::setEmbeddedBitmapText(bool doEmbeddedBitmapText) { 206 void SkPaint::setEmbeddedBitmapText(bool doEmbeddedBitmapText) {
203 this->setFlags(SkSetClearMask(fBitfields.fFlags, doEmbeddedBitmapText, kEmbe ddedBitmapText_Flag)); 207 this->setFlags(set_clear_mask(fBitfields.fFlags, doEmbeddedBitmapText, kEmbe ddedBitmapText_Flag));
204 } 208 }
205 209
206 void SkPaint::setAutohinted(bool useAutohinter) { 210 void SkPaint::setAutohinted(bool useAutohinter) {
207 this->setFlags(SkSetClearMask(fBitfields.fFlags, useAutohinter, kAutoHinting _Flag)); 211 this->setFlags(set_clear_mask(fBitfields.fFlags, useAutohinter, kAutoHinting _Flag));
208 } 212 }
209 213
210 void SkPaint::setLinearText(bool doLinearText) { 214 void SkPaint::setLinearText(bool doLinearText) {
211 this->setFlags(SkSetClearMask(fBitfields.fFlags, doLinearText, kLinearText_F lag)); 215 this->setFlags(set_clear_mask(fBitfields.fFlags, doLinearText, kLinearText_F lag));
212 } 216 }
213 217
214 void SkPaint::setVerticalText(bool doVertical) { 218 void SkPaint::setVerticalText(bool doVertical) {
215 this->setFlags(SkSetClearMask(fBitfields.fFlags, doVertical, kVerticalText_F lag)); 219 this->setFlags(set_clear_mask(fBitfields.fFlags, doVertical, kVerticalText_F lag));
216 } 220 }
217 221
218 void SkPaint::setUnderlineText(bool doUnderline) { 222 void SkPaint::setUnderlineText(bool doUnderline) {
219 this->setFlags(SkSetClearMask(fBitfields.fFlags, doUnderline, kUnderlineText _Flag)); 223 this->setFlags(set_clear_mask(fBitfields.fFlags, doUnderline, kUnderlineText _Flag));
220 } 224 }
221 225
222 void SkPaint::setStrikeThruText(bool doStrikeThru) { 226 void SkPaint::setStrikeThruText(bool doStrikeThru) {
223 this->setFlags(SkSetClearMask(fBitfields.fFlags, doStrikeThru, kStrikeThruTe xt_Flag)); 227 this->setFlags(set_clear_mask(fBitfields.fFlags, doStrikeThru, kStrikeThruTe xt_Flag));
224 } 228 }
225 229
226 void SkPaint::setFakeBoldText(bool doFakeBold) { 230 void SkPaint::setFakeBoldText(bool doFakeBold) {
227 this->setFlags(SkSetClearMask(fBitfields.fFlags, doFakeBold, kFakeBoldText_F lag)); 231 this->setFlags(set_clear_mask(fBitfields.fFlags, doFakeBold, kFakeBoldText_F lag));
228 } 232 }
229 233
230 void SkPaint::setDevKernText(bool doDevKern) { 234 void SkPaint::setDevKernText(bool doDevKern) {
231 this->setFlags(SkSetClearMask(fBitfields.fFlags, doDevKern, kDevKernText_Fla g)); 235 this->setFlags(set_clear_mask(fBitfields.fFlags, doDevKern, kDevKernText_Fla g));
232 } 236 }
233 237
234 void SkPaint::setStyle(Style style) { 238 void SkPaint::setStyle(Style style) {
235 if ((unsigned)style < kStyleCount) { 239 if ((unsigned)style < kStyleCount) {
236 fBitfields.fStyle = style; 240 fBitfields.fStyle = style;
237 } else { 241 } else {
238 #ifdef SK_REPORT_API_RANGE_CHECK 242 #ifdef SK_REPORT_API_RANGE_CHECK
239 SkDebugf("SkPaint::setStyle(%d) out of range\n", style); 243 SkDebugf("SkPaint::setStyle(%d) out of range\n", style);
240 #endif 244 #endif
241 } 245 }
(...skipping 2174 matching lines...) Expand 10 before | Expand all | Expand 10 after
2416 } 2420 }
2417 2421
2418 uint32_t SkPaint::getHash() const { 2422 uint32_t SkPaint::getHash() const {
2419 // We're going to hash 10 pointers and 7 32-bit values, finishing up with fB itfields, 2423 // We're going to hash 10 pointers and 7 32-bit values, finishing up with fB itfields,
2420 // so fBitfields should be 10 pointers and 6 32-bit values from the start. 2424 // so fBitfields should be 10 pointers and 6 32-bit values from the start.
2421 static_assert(offsetof(SkPaint, fBitfields) == 10 * sizeof(void*) + 6 * size of(uint32_t), 2425 static_assert(offsetof(SkPaint, fBitfields) == 10 * sizeof(void*) + 6 * size of(uint32_t),
2422 "SkPaint_notPackedTightly"); 2426 "SkPaint_notPackedTightly");
2423 return SkChecksum::Murmur3(reinterpret_cast<const uint32_t*>(this), 2427 return SkChecksum::Murmur3(reinterpret_cast<const uint32_t*>(this),
2424 offsetof(SkPaint, fBitfields) + sizeof(fBitfields )); 2428 offsetof(SkPaint, fBitfields) + sizeof(fBitfields ));
2425 } 2429 }
OLDNEW
« no previous file with comments | « src/animator/SkScript2.h ('k') | src/pipe/SkGPipeRead.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698