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

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

Issue 1316233002: Style Change: NULL->nullptr (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: 2015-08-27 (Thursday) 10:25:06 EDT Created 5 years, 3 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/core/SkBitmapProcShader.h ('k') | src/core/SkBitmapProcState.h » ('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 2011 Google Inc. 2 * Copyright 2011 Google Inc.
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 "SkBitmapProcShader.h" 8 #include "SkBitmapProcShader.h"
9 #include "SkBitmapProcState.h" 9 #include "SkBitmapProcState.h"
10 #include "SkColorPriv.h" 10 #include "SkColorPriv.h"
(...skipping 29 matching lines...) Expand all
40 xy[1] = (TileMode)fTileModeY; 40 xy[1] = (TileMode)fTileModeY;
41 } 41 }
42 return kDefault_BitmapType; 42 return kDefault_BitmapType;
43 } 43 }
44 44
45 SkFlattenable* SkBitmapProcShader::CreateProc(SkReadBuffer& buffer) { 45 SkFlattenable* SkBitmapProcShader::CreateProc(SkReadBuffer& buffer) {
46 SkMatrix lm; 46 SkMatrix lm;
47 buffer.readMatrix(&lm); 47 buffer.readMatrix(&lm);
48 SkBitmap bm; 48 SkBitmap bm;
49 if (!buffer.readBitmap(&bm)) { 49 if (!buffer.readBitmap(&bm)) {
50 return NULL; 50 return nullptr;
51 } 51 }
52 bm.setImmutable(); 52 bm.setImmutable();
53 TileMode mx = (TileMode)buffer.readUInt(); 53 TileMode mx = (TileMode)buffer.readUInt();
54 TileMode my = (TileMode)buffer.readUInt(); 54 TileMode my = (TileMode)buffer.readUInt();
55 return SkShader::CreateBitmapShader(bm, mx, my, &lm); 55 return SkShader::CreateBitmapShader(bm, mx, my, &lm);
56 } 56 }
57 57
58 void SkBitmapProcShader::flatten(SkWriteBuffer& buffer) const { 58 void SkBitmapProcShader::flatten(SkWriteBuffer& buffer) const {
59 buffer.writeMatrix(this->getLocalMatrix()); 59 buffer.writeMatrix(this->getLocalMatrix());
60 buffer.writeBitmap(fRawBitmap); 60 buffer.writeBitmap(fRawBitmap);
61 buffer.writeUInt(fTileModeX); 61 buffer.writeUInt(fTileModeX);
62 buffer.writeUInt(fTileModeY); 62 buffer.writeUInt(fTileModeY);
63 } 63 }
64 64
65 static bool only_scale_and_translate(const SkMatrix& matrix) { 65 static bool only_scale_and_translate(const SkMatrix& matrix) {
66 unsigned mask = SkMatrix::kTranslate_Mask | SkMatrix::kScale_Mask; 66 unsigned mask = SkMatrix::kTranslate_Mask | SkMatrix::kScale_Mask;
67 return (matrix.getType() & ~mask) == 0; 67 return (matrix.getType() & ~mask) == 0;
68 } 68 }
69 69
70 bool SkBitmapProcShader::isOpaque() const { 70 bool SkBitmapProcShader::isOpaque() const {
71 return fRawBitmap.isOpaque(); 71 return fRawBitmap.isOpaque();
72 } 72 }
73 73
74 SkShader::Context* SkBitmapProcShader::onCreateContext(const ContextRec& rec, vo id* storage) const { 74 SkShader::Context* SkBitmapProcShader::onCreateContext(const ContextRec& rec, vo id* storage) const {
75 SkMatrix totalInverse; 75 SkMatrix totalInverse;
76 // Do this first, so we know the matrix can be inverted. 76 // Do this first, so we know the matrix can be inverted.
77 if (!this->computeTotalInverse(rec, &totalInverse)) { 77 if (!this->computeTotalInverse(rec, &totalInverse)) {
78 return NULL; 78 return nullptr;
79 } 79 }
80 80
81 void* stateStorage = (char*)storage + sizeof(BitmapProcShaderContext); 81 void* stateStorage = (char*)storage + sizeof(BitmapProcShaderContext);
82 SkBitmapProcState* state = new (stateStorage) SkBitmapProcState; 82 SkBitmapProcState* state = new (stateStorage) SkBitmapProcState;
83 83
84 SkASSERT(state); 84 SkASSERT(state);
85 state->fTileModeX = fTileModeX; 85 state->fTileModeX = fTileModeX;
86 state->fTileModeY = fTileModeY; 86 state->fTileModeY = fTileModeY;
87 state->fOrigBitmap = fRawBitmap; 87 state->fOrigBitmap = fRawBitmap;
88 if (!state->chooseProcs(totalInverse, *rec.fPaint)) { 88 if (!state->chooseProcs(totalInverse, *rec.fPaint)) {
89 state->~SkBitmapProcState(); 89 state->~SkBitmapProcState();
90 return NULL; 90 return nullptr;
91 } 91 }
92 92
93 return new (storage) BitmapProcShaderContext(*this, rec, state); 93 return new (storage) BitmapProcShaderContext(*this, rec, state);
94 } 94 }
95 95
96 size_t SkBitmapProcShader::contextSize() const { 96 size_t SkBitmapProcShader::contextSize() const {
97 // The SkBitmapProcState is stored outside of the context object, with the c ontext holding 97 // The SkBitmapProcState is stored outside of the context object, with the c ontext holding
98 // a pointer to it. 98 // a pointer to it.
99 return sizeof(BitmapProcShaderContext) + sizeof(SkBitmapProcState); 99 return sizeof(BitmapProcShaderContext) + sizeof(SkBitmapProcState);
100 } 100 }
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
205 x += n; 205 x += n;
206 dstC += n; 206 dstC += n;
207 } 207 }
208 } 208 }
209 209
210 SkShader::Context::ShadeProc SkBitmapProcShader::BitmapProcShaderContext::asASha deProc(void** ctx) { 210 SkShader::Context::ShadeProc SkBitmapProcShader::BitmapProcShaderContext::asASha deProc(void** ctx) {
211 if (fState->getShaderProc32()) { 211 if (fState->getShaderProc32()) {
212 *ctx = fState; 212 *ctx = fState;
213 return (ShadeProc)fState->getShaderProc32(); 213 return (ShadeProc)fState->getShaderProc32();
214 } 214 }
215 return NULL; 215 return nullptr;
216 } 216 }
217 217
218 void SkBitmapProcShader::BitmapProcShaderContext::shadeSpan16(int x, int y, uint 16_t dstC[], 218 void SkBitmapProcShader::BitmapProcShaderContext::shadeSpan16(int x, int y, uint 16_t dstC[],
219 int count) { 219 int count) {
220 const SkBitmapProcState& state = *fState; 220 const SkBitmapProcState& state = *fState;
221 if (state.getShaderProc16()) { 221 if (state.getShaderProc16()) {
222 state.getShaderProc16()(state, x, y, dstC, count); 222 state.getShaderProc16()(state, x, y, dstC, count);
223 return; 223 return;
224 } 224 }
225 225
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
294 294
295 return bm.width() > kMaxSize || bm.height() > kMaxSize; 295 return bm.width() > kMaxSize || bm.height() > kMaxSize;
296 } 296 }
297 297
298 SkShader* SkCreateBitmapShader(const SkBitmap& src, SkShader::TileMode tmx, 298 SkShader* SkCreateBitmapShader(const SkBitmap& src, SkShader::TileMode tmx,
299 SkShader::TileMode tmy, const SkMatrix* localMatr ix, 299 SkShader::TileMode tmy, const SkMatrix* localMatr ix,
300 SkTBlitterAllocator* allocator) { 300 SkTBlitterAllocator* allocator) {
301 SkShader* shader; 301 SkShader* shader;
302 SkColor color; 302 SkColor color;
303 if (src.isNull() || bitmap_is_too_big(src)) { 303 if (src.isNull() || bitmap_is_too_big(src)) {
304 if (NULL == allocator) { 304 if (nullptr == allocator) {
305 shader = new SkEmptyShader; 305 shader = new SkEmptyShader;
306 } else { 306 } else {
307 shader = allocator->createT<SkEmptyShader>(); 307 shader = allocator->createT<SkEmptyShader>();
308 } 308 }
309 } else if (can_use_color_shader(src, &color)) { 309 } else if (can_use_color_shader(src, &color)) {
310 if (NULL == allocator) { 310 if (nullptr == allocator) {
311 shader = new SkColorShader(color); 311 shader = new SkColorShader(color);
312 } else { 312 } else {
313 shader = allocator->createT<SkColorShader>(color); 313 shader = allocator->createT<SkColorShader>(color);
314 } 314 }
315 } else { 315 } else {
316 if (NULL == allocator) { 316 if (nullptr == allocator) {
317 shader = new SkBitmapProcShader(src, tmx, tmy, localMatrix); 317 shader = new SkBitmapProcShader(src, tmx, tmy, localMatrix);
318 } else { 318 } else {
319 shader = allocator->createT<SkBitmapProcShader>(src, tmx, tmy, local Matrix); 319 shader = allocator->createT<SkBitmapProcShader>(src, tmx, tmy, local Matrix);
320 } 320 }
321 } 321 }
322 return shader; 322 return shader;
323 } 323 }
324 324
325 /////////////////////////////////////////////////////////////////////////////// 325 ///////////////////////////////////////////////////////////////////////////////
326 326
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
412 #else 412 #else
413 413
414 bool SkBitmapProcShader::asFragmentProcessor(GrContext*, const SkPaint&, const S kMatrix&, 414 bool SkBitmapProcShader::asFragmentProcessor(GrContext*, const SkPaint&, const S kMatrix&,
415 const SkMatrix*, GrColor*, GrProces sorDataManager*, 415 const SkMatrix*, GrColor*, GrProces sorDataManager*,
416 GrFragmentProcessor**) const { 416 GrFragmentProcessor**) const {
417 SkDEBUGFAIL("Should not call in GPU-less build"); 417 SkDEBUGFAIL("Should not call in GPU-less build");
418 return false; 418 return false;
419 } 419 }
420 420
421 #endif 421 #endif
OLDNEW
« no previous file with comments | « src/core/SkBitmapProcShader.h ('k') | src/core/SkBitmapProcState.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698