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

Side by Side Diff: src/core/SkDrawLooper.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/SkDraw.cpp ('k') | src/core/SkDrawable.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 "SkDrawLooper.h" 8 #include "SkDrawLooper.h"
9 #include "SkCanvas.h" 9 #include "SkCanvas.h"
10 #include "SkMatrix.h" 10 #include "SkMatrix.h"
11 #include "SkPaint.h" 11 #include "SkPaint.h"
12 #include "SkRect.h" 12 #include "SkRect.h"
13 #include "SkSmallAllocator.h" 13 #include "SkSmallAllocator.h"
14 14
15 bool SkDrawLooper::canComputeFastBounds(const SkPaint& paint) const { 15 bool SkDrawLooper::canComputeFastBounds(const SkPaint& paint) const {
16 SkCanvas canvas; 16 SkCanvas canvas;
17 SkSmallAllocator<1, 32> allocator; 17 SkSmallAllocator<1, 32> allocator;
18 void* buffer = allocator.reserveT<SkDrawLooper::Context>(this->contextSize() ); 18 void* buffer = allocator.reserveT<SkDrawLooper::Context>(this->contextSize() );
19 19
20 SkDrawLooper::Context* context = this->createContext(&canvas, buffer); 20 SkDrawLooper::Context* context = this->createContext(&canvas, buffer);
21 for (;;) { 21 for (;;) {
22 SkPaint p(paint); 22 SkPaint p(paint);
23 if (context->next(&canvas, &p)) { 23 if (context->next(&canvas, &p)) {
24 p.setLooper(NULL); 24 p.setLooper(nullptr);
25 if (!p.canComputeFastBounds()) { 25 if (!p.canComputeFastBounds()) {
26 return false; 26 return false;
27 } 27 }
28 } else { 28 } else {
29 break; 29 break;
30 } 30 }
31 } 31 }
32 return true; 32 return true;
33 } 33 }
34 34
35 void SkDrawLooper::computeFastBounds(const SkPaint& paint, const SkRect& s, 35 void SkDrawLooper::computeFastBounds(const SkPaint& paint, const SkRect& s,
36 SkRect* dst) const { 36 SkRect* dst) const {
37 // src and dst rects may alias and we need to keep the original src, so copy it. 37 // src and dst rects may alias and we need to keep the original src, so copy it.
38 const SkRect src = s; 38 const SkRect src = s;
39 39
40 SkCanvas canvas; 40 SkCanvas canvas;
41 SkSmallAllocator<1, 32> allocator; 41 SkSmallAllocator<1, 32> allocator;
42 void* buffer = allocator.reserveT<SkDrawLooper::Context>(this->contextSize() ); 42 void* buffer = allocator.reserveT<SkDrawLooper::Context>(this->contextSize() );
43 43
44 *dst = src; // catch case where there are no loops 44 *dst = src; // catch case where there are no loops
45 SkDrawLooper::Context* context = this->createContext(&canvas, buffer); 45 SkDrawLooper::Context* context = this->createContext(&canvas, buffer);
46 for (bool firstTime = true;; firstTime = false) { 46 for (bool firstTime = true;; firstTime = false) {
47 SkPaint p(paint); 47 SkPaint p(paint);
48 if (context->next(&canvas, &p)) { 48 if (context->next(&canvas, &p)) {
49 SkRect r(src); 49 SkRect r(src);
50 50
51 p.setLooper(NULL); 51 p.setLooper(nullptr);
52 p.computeFastBounds(r, &r); 52 p.computeFastBounds(r, &r);
53 canvas.getTotalMatrix().mapRect(&r); 53 canvas.getTotalMatrix().mapRect(&r);
54 54
55 if (firstTime) { 55 if (firstTime) {
56 *dst = r; 56 *dst = r;
57 } else { 57 } else {
58 dst->join(r); 58 dst->join(r);
59 } 59 }
60 } else { 60 } else {
61 break; 61 break;
62 } 62 }
63 } 63 }
64 } 64 }
65 65
66 bool SkDrawLooper::asABlurShadow(BlurShadowRec*) const { 66 bool SkDrawLooper::asABlurShadow(BlurShadowRec*) const {
67 return false; 67 return false;
68 } 68 }
OLDNEW
« no previous file with comments | « src/core/SkDraw.cpp ('k') | src/core/SkDrawable.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698