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

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

Issue 122293002: Revert "Revert of https://codereview.chromium.org/113823003/" (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 6 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 | Annotate | Revision Log
« no previous file with comments | « src/core/SkMipMap.cpp ('k') | src/images/SkImageDecoder_libpng.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 /* 2 /*
3 * Copyright 2006 The Android Open Source Project 3 * Copyright 2006 The Android Open Source Project
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 8
9 9
10 #include "SkRegionPriv.h" 10 #include "SkRegionPriv.h"
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 100
101 SkRgnBuilder::~SkRgnBuilder() { 101 SkRgnBuilder::~SkRgnBuilder() {
102 sk_free(fStorage); 102 sk_free(fStorage);
103 } 103 }
104 104
105 bool SkRgnBuilder::init(int maxHeight, int maxTransitions, bool pathIsInverse) { 105 bool SkRgnBuilder::init(int maxHeight, int maxTransitions, bool pathIsInverse) {
106 if ((maxHeight | maxTransitions) < 0) { 106 if ((maxHeight | maxTransitions) < 0) {
107 return false; 107 return false;
108 } 108 }
109 109
110 Sk64 count, size;
111
112 if (pathIsInverse) { 110 if (pathIsInverse) {
113 // allow for additional X transitions to "invert" each scanline 111 // allow for additional X transitions to "invert" each scanline
114 // [ L' ... normal transitions ... R' ] 112 // [ L' ... normal transitions ... R' ]
115 // 113 //
116 maxTransitions += 2; 114 maxTransitions += 2;
117 } 115 }
118 116
119 // compute the count with +1 and +3 slop for the working buffer 117 // compute the count with +1 and +3 slop for the working buffer
120 count.setMul(maxHeight + 1, 3 + maxTransitions); 118 int64_t count = sk_64_mul(maxHeight + 1, 3 + maxTransitions);
121 119
122 if (pathIsInverse) { 120 if (pathIsInverse) {
123 // allow for two "empty" rows for the top and bottom 121 // allow for two "empty" rows for the top and bottom
124 // [ Y, 1, L, R, S] == 5 (*2 for top and bottom) 122 // [ Y, 1, L, R, S] == 5 (*2 for top and bottom)
125 count.add(10); 123 count += 10;
126 } 124 }
127 125
128 if (!count.is32() || count.isNeg()) { 126 if (count < 0 || !sk_64_isS32(count)) {
129 return false; 127 return false;
130 } 128 }
131 fStorageCount = count.get32(); 129 fStorageCount = sk_64_asS32(count);
132 130
133 size.setMul(fStorageCount, sizeof(SkRegion::RunType)); 131 int64_t size = sk_64_mul(fStorageCount, sizeof(SkRegion::RunType));
134 if (!size.is32() || size.isNeg()) { 132 if (size < 0 || !sk_64_isS32(size)) {
135 return false; 133 return false;
136 } 134 }
137 135
138 fStorage = (SkRegion::RunType*)sk_malloc_flags(size.get32(), 0); 136 fStorage = (SkRegion::RunType*)sk_malloc_flags(sk_64_asS32(size), 0);
139 if (NULL == fStorage) { 137 if (NULL == fStorage) {
140 return false; 138 return false;
141 } 139 }
142 140
143 fCurrScanline = NULL; // signal empty collection 141 fCurrScanline = NULL; // signal empty collection
144 fPrevScanline = NULL; // signal first scanline 142 fPrevScanline = NULL; // signal first scanline
145 return true; 143 return true;
146 } 144 }
147 145
148 void SkRgnBuilder::blitH(int x, int y, int width) { 146 void SkRgnBuilder::blitH(int x, int y, int width) {
(...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after
508 #endif 506 #endif
509 507
510 path->incReserve(count << 1); 508 path->incReserve(count << 1);
511 do { 509 do {
512 SkASSERT(count > 1); 510 SkASSERT(count > 1);
513 count -= extract_path(start, stop, path); 511 count -= extract_path(start, stop, path);
514 } while (count > 0); 512 } while (count > 0);
515 513
516 return true; 514 return true;
517 } 515 }
OLDNEW
« no previous file with comments | « src/core/SkMipMap.cpp ('k') | src/images/SkImageDecoder_libpng.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698