| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2012 Google Inc. | 2 * Copyright 2012 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 "SkBitmapDevice.h" | 8 #include "SkBitmapDevice.h" |
| 9 #include "SkCanvas.h" | 9 #include "SkCanvas.h" |
| 10 #include "SkData.h" | 10 #include "SkData.h" |
| (...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 183 if (SkShader::kNone_GradientType == shader->asAGradient(NULL) && | 183 if (SkShader::kNone_GradientType == shader->asAGradient(NULL) && |
| 184 shader->asABitmap(&bm, NULL, NULL)) { | 184 shader->asABitmap(&bm, NULL, NULL)) { |
| 185 fPRSet->add(bm.pixelRef()); | 185 fPRSet->add(bm.pixelRef()); |
| 186 } | 186 } |
| 187 } | 187 } |
| 188 } | 188 } |
| 189 | 189 |
| 190 typedef SkBaseDevice INHERITED; | 190 typedef SkBaseDevice INHERITED; |
| 191 }; | 191 }; |
| 192 | 192 |
| 193 SkData* SkPictureUtils::GatherPixelRefs(SkPicture* pict, const SkRect& area) { | 193 SkData* SkPictureUtils::GatherPixelRefs(const SkPicture* pict, const SkRect& are
a) { |
| 194 if (NULL == pict) { | 194 if (NULL == pict) { |
| 195 return NULL; | 195 return NULL; |
| 196 } | 196 } |
| 197 | 197 |
| 198 // this test also handles if either area or pict's width/height are empty | 198 // this test also handles if either area or pict's width/height are empty |
| 199 if (!SkRect::Intersects(area, | 199 if (!SkRect::Intersects(area, |
| 200 SkRect::MakeWH(SkIntToScalar(pict->width()), | 200 SkRect::MakeWH(SkIntToScalar(pict->width()), |
| 201 SkIntToScalar(pict->height())))) { | 201 SkIntToScalar(pict->height())))) { |
| 202 return NULL; | 202 return NULL; |
| 203 } | 203 } |
| 204 | 204 |
| 205 SkTDArray<SkPixelRef*> array; | 205 SkTDArray<SkPixelRef*> array; |
| 206 PixelRefSet prset(&array); | 206 PixelRefSet prset(&array); |
| 207 | 207 |
| 208 GatherPixelRefDevice device(pict->width(), pict->height(), &prset); | 208 GatherPixelRefDevice device(pict->width(), pict->height(), &prset); |
| 209 SkNoSaveLayerCanvas canvas(&device); | 209 SkNoSaveLayerCanvas canvas(&device); |
| 210 | 210 |
| 211 canvas.clipRect(area, SkRegion::kIntersect_Op, false); | 211 canvas.clipRect(area, SkRegion::kIntersect_Op, false); |
| 212 canvas.drawPicture(pict); | 212 canvas.drawPicture(pict); |
| 213 | 213 |
| 214 SkData* data = NULL; | 214 SkData* data = NULL; |
| 215 int count = array.count(); | 215 int count = array.count(); |
| 216 if (count > 0) { | 216 if (count > 0) { |
| 217 data = SkData::NewFromMalloc(array.detach(), count * sizeof(SkPixelRef*)
); | 217 data = SkData::NewFromMalloc(array.detach(), count * sizeof(SkPixelRef*)
); |
| 218 } | 218 } |
| 219 return data; | 219 return data; |
| 220 } | 220 } |
| OLD | NEW |