OLD | NEW |
1 /* libs/graphics/effects/SkEmbossMaskFilter.cpp | 1 /* libs/graphics/effects/SkEmbossMaskFilter.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 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 margin->set(SkScalarCeil(radius), SkScalarCeil(radius)); | 81 margin->set(SkScalarCeil(radius), SkScalarCeil(radius)); |
82 | 82 |
83 if (src.fImage == NULL) | 83 if (src.fImage == NULL) |
84 return true; | 84 return true; |
85 | 85 |
86 // create a larger buffer for the other two channels (should force fBlur to
do this for us) | 86 // create a larger buffer for the other two channels (should force fBlur to
do this for us) |
87 | 87 |
88 { | 88 { |
89 uint8_t* alphaPlane = dst->fImage; | 89 uint8_t* alphaPlane = dst->fImage; |
90 size_t planeSize = dst->computeImageSize(); | 90 size_t planeSize = dst->computeImageSize(); |
91 | 91 if (0 == planeSize) { |
| 92 return false; // too big to allocate, abort |
| 93 } |
92 dst->fImage = SkMask::AllocImage(planeSize * 3); | 94 dst->fImage = SkMask::AllocImage(planeSize * 3); |
93 memcpy(dst->fImage, alphaPlane, planeSize); | 95 memcpy(dst->fImage, alphaPlane, planeSize); |
94 SkMask::FreeImage(alphaPlane); | 96 SkMask::FreeImage(alphaPlane); |
95 } | 97 } |
96 | 98 |
97 // run the light direction through the matrix... | 99 // run the light direction through the matrix... |
98 Light light = fLight; | 100 Light light = fLight; |
99 matrix.mapVectors((SkVector*)(void*)light.fDirection, (SkVector*)(void*)fLig
ht.fDirection, 1); | 101 matrix.mapVectors((SkVector*)(void*)light.fDirection, (SkVector*)(void*)fLig
ht.fDirection, 1); |
100 | 102 |
101 // now restore the length of the XY component | 103 // now restore the length of the XY component |
(...skipping 30 matching lines...) Expand all Loading... |
132 | 134 |
133 void SkEmbossMaskFilter::flatten(SkFlattenableWriteBuffer& buffer) | 135 void SkEmbossMaskFilter::flatten(SkFlattenableWriteBuffer& buffer) |
134 { | 136 { |
135 this->INHERITED::flatten(buffer); | 137 this->INHERITED::flatten(buffer); |
136 | 138 |
137 fLight.fPad = 0; // for the font-cache lookup to be clean | 139 fLight.fPad = 0; // for the font-cache lookup to be clean |
138 buffer.writeMul4(&fLight, sizeof(fLight)); | 140 buffer.writeMul4(&fLight, sizeof(fLight)); |
139 buffer.writeScalar(fBlurRadius); | 141 buffer.writeScalar(fBlurRadius); |
140 } | 142 } |
141 | 143 |
OLD | NEW |