OLD | NEW |
---|---|
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 "SkLayerRasterizer.h" | 10 #include "SkLayerRasterizer.h" |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
109 mask->fRowBytes = mask->fBounds.width(); | 109 mask->fRowBytes = mask->fBounds.width(); |
110 size_t size = mask->computeImageSize(); | 110 size_t size = mask->computeImageSize(); |
111 if (0 == size) { | 111 if (0 == size) { |
112 return false; // too big to allocate, abort | 112 return false; // too big to allocate, abort |
113 } | 113 } |
114 mask->fImage = SkMask::AllocImage(size); | 114 mask->fImage = SkMask::AllocImage(size); |
115 memset(mask->fImage, 0, size); | 115 memset(mask->fImage, 0, size); |
116 } | 116 } |
117 | 117 |
118 if (SkMask::kJustComputeBounds_CreateMode != mode) { | 118 if (SkMask::kJustComputeBounds_CreateMode != mode) { |
119 SkBitmap device; | |
120 SkRasterClip rectClip; | 119 SkRasterClip rectClip; |
121 SkDraw draw; | 120 SkDraw draw; |
122 SkMatrix translatedMatrix; // this translates us to our local pi xels | 121 SkMatrix translatedMatrix; // this translates us to our local pi xels |
123 SkMatrix drawMatrix; // this translates the path by each l ayer's offset | 122 SkMatrix drawMatrix; // this translates the path by each l ayer's offset |
124 | 123 |
125 rectClip.setRect(SkIRect::MakeWH(mask->fBounds.width(), mask->fBounds.he ight())); | 124 rectClip.setRect(SkIRect::MakeWH(mask->fBounds.width(), mask->fBounds.he ight())); |
126 | 125 |
127 translatedMatrix = matrix; | 126 translatedMatrix = matrix; |
128 translatedMatrix.postTranslate(-SkIntToScalar(mask->fBounds.fLeft), | 127 translatedMatrix.postTranslate(-SkIntToScalar(mask->fBounds.fLeft), |
129 -SkIntToScalar(mask->fBounds.fTop)); | 128 -SkIntToScalar(mask->fBounds.fTop)); |
130 | 129 |
131 device.installMaskPixels(*mask); | 130 if (!draw.fDst.reset(*mask)) { |
scroggo
2015/06/08 15:21:38
Again, it seems like we could move this error exit
reed1
2015/06/08 17:11:01
Done.
| |
132 | 131 return false; |
133 draw.fBitmap = &device; | 132 } |
134 draw.fMatrix = &drawMatrix; | 133 draw.fMatrix = &drawMatrix; |
135 draw.fRC = &rectClip; | 134 draw.fRC = &rectClip; |
136 draw.fClip = &rectClip.bwRgn(); | 135 draw.fClip = &rectClip.bwRgn(); |
137 // we set the matrixproc in the loop, as the matrix changes each time (p otentially) | 136 // we set the matrixproc in the loop, as the matrix changes each time (p otentially) |
138 | 137 |
139 SkDeque::F2BIter iter(*fLayers); | 138 SkDeque::F2BIter iter(*fLayers); |
140 SkLayerRasterizer_Rec* rec; | 139 SkLayerRasterizer_Rec* rec; |
141 | 140 |
142 while ((rec = (SkLayerRasterizer_Rec*)iter.next()) != NULL) { | 141 while ((rec = (SkLayerRasterizer_Rec*)iter.next()) != NULL) { |
143 drawMatrix = translatedMatrix; | 142 drawMatrix = translatedMatrix; |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
226 SkDEBUGCODE(count++); | 225 SkDEBUGCODE(count++); |
227 SkLayerRasterizer_Rec* recCopy = static_cast<SkLayerRasterizer_Rec*>(lay ers->push_back()); | 226 SkLayerRasterizer_Rec* recCopy = static_cast<SkLayerRasterizer_Rec*>(lay ers->push_back()); |
228 SkNEW_PLACEMENT_ARGS(&recCopy->fPaint, SkPaint, (recOrig->fPaint)); | 227 SkNEW_PLACEMENT_ARGS(&recCopy->fPaint, SkPaint, (recOrig->fPaint)); |
229 recCopy->fOffset = recOrig->fOffset; | 228 recCopy->fOffset = recOrig->fOffset; |
230 } | 229 } |
231 SkASSERT(fLayers->count() == count); | 230 SkASSERT(fLayers->count() == count); |
232 SkASSERT(layers->count() == count); | 231 SkASSERT(layers->count() == count); |
233 SkLayerRasterizer* rasterizer = SkNEW_ARGS(SkLayerRasterizer, (layers)); | 232 SkLayerRasterizer* rasterizer = SkNEW_ARGS(SkLayerRasterizer, (layers)); |
234 return rasterizer; | 233 return rasterizer; |
235 } | 234 } |
OLD | NEW |