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

Side by Side Diff: src/utils/SkCanvasStateUtils.cpp

Issue 137433003: Convert SkWriter32 to use an SkTDArray for its internal storage. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: of course 0's fine too... 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
« no previous file with comments | « src/pipe/SkGPipeWrite.cpp ('k') | tests/AndroidPaintTest.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 "SkCanvasStateUtils.h" 8 #include "SkCanvasStateUtils.h"
9 9
10 #include "SkBitmapDevice.h" 10 #include "SkBitmapDevice.h"
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 } 148 }
149 149
150 /* 150 /*
151 * capture the clip 151 * capture the clip
152 * 152 *
153 * storage is allocated on the stack for the first 4 rects. This value was 153 * storage is allocated on the stack for the first 4 rects. This value was
154 * chosen somewhat arbitrarily, but does allow us to represent simple clips 154 * chosen somewhat arbitrarily, but does allow us to represent simple clips
155 * and some more common complex clips (e.g. a clipRect with a sub-rect 155 * and some more common complex clips (e.g. a clipRect with a sub-rect
156 * clipped out of its interior) without needing to malloc any additional mem ory. 156 * clipped out of its interior) without needing to malloc any additional mem ory.
157 */ 157 */
158 const int clipBufferSize = 4 * sizeof(ClipRect); 158 SkSWriter32<4*sizeof(ClipRect)> clipWriter;
159 char clipBuffer[clipBufferSize];
160 SkWriter32 clipWriter(sizeof(ClipRect), clipBuffer, clipBufferSize);
161 159
162 if (!clip.isEmpty()) { 160 if (!clip.isEmpty()) {
163 // only returns the b/w clip so aa clips fail 161 // only returns the b/w clip so aa clips fail
164 SkRegion::Iterator clip_iterator(clip); 162 SkRegion::Iterator clip_iterator(clip);
165 for (; !clip_iterator.done(); clip_iterator.next()) { 163 for (; !clip_iterator.done(); clip_iterator.next()) {
166 // this assumes the SkIRect is stored in l,t,r,b ordering which 164 // this assumes the SkIRect is stored in l,t,r,b ordering which
167 // matches the ordering of our ClipRect struct 165 // matches the ordering of our ClipRect struct
168 clipWriter.writeIRect(clip_iterator.rect()); 166 clipWriter.writeIRect(clip_iterator.rect());
169 state->clipRectCount++; 167 state->clipRectCount++;
170 } 168 }
(...skipping 23 matching lines...) Expand all
194 // decompose the total matrix and clip 192 // decompose the total matrix and clip
195 setup_MC_state(&canvasState->mcState, canvas->getTotalMatrix(), canvas->getT otalClip()); 193 setup_MC_state(&canvasState->mcState, canvas->getTotalMatrix(), canvas->getT otalClip());
196 194
197 /* 195 /*
198 * decompose the layers 196 * decompose the layers
199 * 197 *
200 * storage is allocated on the stack for the first 3 layers. It is common in 198 * storage is allocated on the stack for the first 3 layers. It is common in
201 * some view systems (e.g. Android) that a few non-clipped layers are presen t 199 * some view systems (e.g. Android) that a few non-clipped layers are presen t
202 * and we will not need to malloc any additional memory in those cases. 200 * and we will not need to malloc any additional memory in those cases.
203 */ 201 */
204 const int layerBufferSize = 3 * sizeof(SkCanvasLayerState); 202 SkSWriter32<3*sizeof(SkCanvasLayerState)> layerWriter;
205 char layerBuffer[layerBufferSize];
206 SkWriter32 layerWriter(sizeof(SkCanvasLayerState), layerBuffer, layerBufferS ize);
207 int layerCount = 0; 203 int layerCount = 0;
208 for (SkCanvas::LayerIter layer(canvas, true/*skipEmptyClips*/); !layer.done( ); layer.next()) { 204 for (SkCanvas::LayerIter layer(canvas, true/*skipEmptyClips*/); !layer.done( ); layer.next()) {
209 205
210 // we currently only work for bitmap backed devices 206 // we currently only work for bitmap backed devices
211 const SkBitmap& bitmap = layer.device()->accessBitmap(true/*changePixels */); 207 const SkBitmap& bitmap = layer.device()->accessBitmap(true/*changePixels */);
212 if (bitmap.empty() || bitmap.isNull() || !bitmap.lockPixelsAreWritable() ) { 208 if (bitmap.empty() || bitmap.isNull() || !bitmap.lockPixelsAreWritable() ) {
213 return NULL; 209 return NULL;
214 } 210 }
215 211
216 SkCanvasLayerState* layerState = 212 SkCanvasLayerState* layerState =
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
334 } 330 }
335 331
336 return canvas.detach(); 332 return canvas.detach();
337 } 333 }
338 334
339 //////////////////////////////////////////////////////////////////////////////// 335 ////////////////////////////////////////////////////////////////////////////////
340 336
341 void SkCanvasStateUtils::ReleaseCanvasState(SkCanvasState* state) { 337 void SkCanvasStateUtils::ReleaseCanvasState(SkCanvasState* state) {
342 SkDELETE(state); 338 SkDELETE(state);
343 } 339 }
OLDNEW
« no previous file with comments | « src/pipe/SkGPipeWrite.cpp ('k') | tests/AndroidPaintTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698