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

Side by Side Diff: src/effects/SkRectShaderImageFilter.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/effects/SkPictureImageFilter.cpp ('k') | src/effects/SkTableColorFilter.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 2013 Google Inc. 2 * Copyright 2013 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 "SkRectShaderImageFilter.h" 8 #include "SkRectShaderImageFilter.h"
9 #include "SkBitmap.h" 9 #include "SkBitmap.h"
10 #include "SkCanvas.h" 10 #include "SkCanvas.h"
11 #include "SkDevice.h" 11 #include "SkDevice.h"
12 #include "SkReadBuffer.h" 12 #include "SkReadBuffer.h"
13 #include "SkWriteBuffer.h" 13 #include "SkWriteBuffer.h"
14 #include "SkShader.h" 14 #include "SkShader.h"
15 15
16 SkRectShaderImageFilter* SkRectShaderImageFilter::Create(SkShader* s, const SkRe ct& rect) { 16 SkRectShaderImageFilter* SkRectShaderImageFilter::Create(SkShader* s, const SkRe ct& rect) {
17 SkASSERT(s); 17 SkASSERT(s);
18 uint32_t flags = CropRect::kHasAll_CropEdge; 18 uint32_t flags = CropRect::kHasAll_CropEdge;
19 if (rect.width() == 0 || rect.height() == 0) { 19 if (rect.width() == 0 || rect.height() == 0) {
20 flags = 0x0; 20 flags = 0x0;
21 } 21 }
22 CropRect cropRect(rect, flags); 22 CropRect cropRect(rect, flags);
23 return s ? new SkRectShaderImageFilter(s, &cropRect) : NULL; 23 return s ? new SkRectShaderImageFilter(s, &cropRect) : nullptr;
24 } 24 }
25 25
26 SkRectShaderImageFilter* SkRectShaderImageFilter::Create(SkShader* s, const Crop Rect* cropRect) { 26 SkRectShaderImageFilter* SkRectShaderImageFilter::Create(SkShader* s, const Crop Rect* cropRect) {
27 SkASSERT(s); 27 SkASSERT(s);
28 return s ? new SkRectShaderImageFilter(s, cropRect) : NULL; 28 return s ? new SkRectShaderImageFilter(s, cropRect) : nullptr;
29 } 29 }
30 30
31 SkRectShaderImageFilter::SkRectShaderImageFilter(SkShader* s, const CropRect* cr opRect) 31 SkRectShaderImageFilter::SkRectShaderImageFilter(SkShader* s, const CropRect* cr opRect)
32 : INHERITED(0, NULL, cropRect) 32 : INHERITED(0, nullptr, cropRect)
33 , fShader(SkRef(s)) { 33 , fShader(SkRef(s)) {
34 } 34 }
35 35
36 SkFlattenable* SkRectShaderImageFilter::CreateProc(SkReadBuffer& buffer) { 36 SkFlattenable* SkRectShaderImageFilter::CreateProc(SkReadBuffer& buffer) {
37 SK_IMAGEFILTER_UNFLATTEN_COMMON(common, 0); 37 SK_IMAGEFILTER_UNFLATTEN_COMMON(common, 0);
38 SkAutoTUnref<SkShader> shader(buffer.readShader()); 38 SkAutoTUnref<SkShader> shader(buffer.readShader());
39 return Create(shader.get(), &common.cropRect()); 39 return Create(shader.get(), &common.cropRect());
40 } 40 }
41 41
42 void SkRectShaderImageFilter::flatten(SkWriteBuffer& buffer) const { 42 void SkRectShaderImageFilter::flatten(SkWriteBuffer& buffer) const {
(...skipping 10 matching lines...) Expand all
53 const Context& ctx, 53 const Context& ctx,
54 SkBitmap* result, 54 SkBitmap* result,
55 SkIPoint* offset) const { 55 SkIPoint* offset) const {
56 SkIRect bounds; 56 SkIRect bounds;
57 if (!this->applyCropRect(ctx, source, SkIPoint::Make(0, 0), &bounds)) { 57 if (!this->applyCropRect(ctx, source, SkIPoint::Make(0, 0), &bounds)) {
58 return false; 58 return false;
59 } 59 }
60 60
61 SkAutoTUnref<SkBaseDevice> device(proxy->createDevice(bounds.width(), 61 SkAutoTUnref<SkBaseDevice> device(proxy->createDevice(bounds.width(),
62 bounds.height())); 62 bounds.height()));
63 if (NULL == device.get()) { 63 if (nullptr == device.get()) {
64 return false; 64 return false;
65 } 65 }
66 SkCanvas canvas(device.get()); 66 SkCanvas canvas(device.get());
67 67
68 SkPaint paint; 68 SkPaint paint;
69 SkMatrix matrix(ctx.ctm()); 69 SkMatrix matrix(ctx.ctm());
70 matrix.postTranslate(SkIntToScalar(-bounds.left()), SkIntToScalar(-bounds.to p())); 70 matrix.postTranslate(SkIntToScalar(-bounds.left()), SkIntToScalar(-bounds.to p()));
71 SkSafeUnref(paint.setShader(SkShader::CreateLocalMatrixShader(fShader, matri x))); 71 SkSafeUnref(paint.setShader(SkShader::CreateLocalMatrixShader(fShader, matri x)));
72 72
73 SkRect rect = SkRect::MakeWH(SkIntToScalar(bounds.width()), SkIntToScalar(bo unds.height())); 73 SkRect rect = SkRect::MakeWH(SkIntToScalar(bounds.width()), SkIntToScalar(bo unds.height()));
74 canvas.drawRect(rect, paint); 74 canvas.drawRect(rect, paint);
75 75
76 *result = device.get()->accessBitmap(false); 76 *result = device.get()->accessBitmap(false);
77 offset->fX = bounds.fLeft; 77 offset->fX = bounds.fLeft;
78 offset->fY = bounds.fTop; 78 offset->fY = bounds.fTop;
79 return true; 79 return true;
80 } 80 }
81 81
82 bool SkRectShaderImageFilter::affectsTransparentBlack() const { 82 bool SkRectShaderImageFilter::affectsTransparentBlack() const {
83 return true; 83 return true;
84 } 84 }
85 85
86 #ifndef SK_IGNORE_TO_STRING 86 #ifndef SK_IGNORE_TO_STRING
87 void SkRectShaderImageFilter::toString(SkString* str) const { 87 void SkRectShaderImageFilter::toString(SkString* str) const {
88 str->appendf("SkRectShaderImageFilter: ("); 88 str->appendf("SkRectShaderImageFilter: (");
89 str->append(")"); 89 str->append(")");
90 } 90 }
91 #endif 91 #endif
OLDNEW
« no previous file with comments | « src/effects/SkPictureImageFilter.cpp ('k') | src/effects/SkTableColorFilter.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698