OLD | NEW |
1 /* libs/graphics/effects/SkLayerRasterizer.cpp | 1 /* libs/graphics/effects/SkLayerRasterizer.cpp |
2 ** | 2 ** |
3 ** Copyright 2006, The Android Open Source Project | 3 ** Copyright 2006, The Android Open Source Project |
4 ** | 4 ** |
5 ** Licensed under the Apache License, Version 2.0 (the "License"); | 5 ** Licensed under the Apache License, Version 2.0 (the "License"); |
6 ** you may not use this file except in compliance with the License. | 6 ** you may not use this file except in compliance with the License. |
7 ** You may obtain a copy of the License at | 7 ** You may obtain a copy of the License at |
8 ** | 8 ** |
9 ** http://www.apache.org/licenses/LICENSE-2.0 | 9 ** http://www.apache.org/licenses/LICENSE-2.0 |
10 ** | 10 ** |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
101 if (SkMask::kJustRenderImage_CreateMode != mode) | 101 if (SkMask::kJustRenderImage_CreateMode != mode) |
102 { | 102 { |
103 if (!compute_bounds(fLayers, path, matrix, clipBounds, &mask->fBounds)) | 103 if (!compute_bounds(fLayers, path, matrix, clipBounds, &mask->fBounds)) |
104 return false; | 104 return false; |
105 } | 105 } |
106 | 106 |
107 if (SkMask::kComputeBoundsAndRenderImage_CreateMode == mode) | 107 if (SkMask::kComputeBoundsAndRenderImage_CreateMode == mode) |
108 { | 108 { |
109 mask->fFormat = SkMask::kA8_Format; | 109 mask->fFormat = SkMask::kA8_Format; |
110 mask->fRowBytes = SkToU16(mask->fBounds.width()); | 110 mask->fRowBytes = SkToU16(mask->fBounds.width()); |
111 mask->fImage = SkMask::AllocImage(mask->computeImageSize()); | 111 size_t size = mask->computeImageSize(); |
112 memset(mask->fImage, 0, mask->computeImageSize()); | 112 if (0 == size) { |
| 113 return false; // too big to allocate, abort |
| 114 } |
| 115 mask->fImage = SkMask::AllocImage(size); |
| 116 memset(mask->fImage, 0, size); |
113 } | 117 } |
114 | 118 |
115 if (SkMask::kJustComputeBounds_CreateMode != mode) | 119 if (SkMask::kJustComputeBounds_CreateMode != mode) |
116 { | 120 { |
117 SkBitmap device; | 121 SkBitmap device; |
118 SkDraw draw; | 122 SkDraw draw; |
119 SkMatrix translatedMatrix; // this translates us to our local pixels | 123 SkMatrix translatedMatrix; // this translates us to our local pixels |
120 SkMatrix drawMatrix; // this translates the path by each layer's
offset | 124 SkMatrix drawMatrix; // this translates the path by each layer's
offset |
121 SkRegion rectClip; | 125 SkRegion rectClip; |
122 | 126 |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
233 SkFlattenable* SkLayerRasterizer::CreateProc(SkFlattenableReadBuffer& buffer) | 237 SkFlattenable* SkLayerRasterizer::CreateProc(SkFlattenableReadBuffer& buffer) |
234 { | 238 { |
235 return SkNEW_ARGS(SkLayerRasterizer, (buffer)); | 239 return SkNEW_ARGS(SkLayerRasterizer, (buffer)); |
236 } | 240 } |
237 | 241 |
238 SkFlattenable::Factory SkLayerRasterizer::getFactory() | 242 SkFlattenable::Factory SkLayerRasterizer::getFactory() |
239 { | 243 { |
240 return CreateProc; | 244 return CreateProc; |
241 } | 245 } |
242 | 246 |
OLD | NEW |