| 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 178 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  189  |  189  | 
|  190     typedef SkBaseDevice INHERITED; |  190     typedef SkBaseDevice INHERITED; | 
|  191 }; |  191 }; | 
|  192  |  192  | 
|  193 SkData* SkPictureUtils::GatherPixelRefs(const SkPicture* pict, const SkRect& are
     a) { |  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, pict->cullRect())) { | 
|  200                             SkRect::MakeWH(SkIntToScalar(pict->width()), |  | 
|  201                                            SkIntToScalar(pict->height())))) { |  | 
|  202         return NULL; |  200         return NULL; | 
|  203     } |  201     } | 
|  204  |  202  | 
|  205     SkTDArray<SkPixelRef*> array; |  203     SkTDArray<SkPixelRef*> array; | 
|  206     PixelRefSet prset(&array); |  204     PixelRefSet prset(&array); | 
|  207  |  205  | 
|  208     GatherPixelRefDevice device(pict->width(), pict->height(), &prset); |  206     GatherPixelRefDevice device(SkScalarCeilToInt(pict->cullRect().width()),  | 
 |  207                                 SkScalarCeilToInt(pict->cullRect().height()),  | 
 |  208                                 &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 |