OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2014 Google Inc. | 2 * Copyright 2014 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 "GrContext.h" | 8 #include "GrContext.h" |
9 #include "GrLayerCache.h" | 9 #include "GrLayerCache.h" |
10 #include "GrRecordReplaceDraw.h" | 10 #include "GrRecordReplaceDraw.h" |
11 #include "SkCanvasPriv.h" | 11 #include "SkCanvasPriv.h" |
12 #include "SkGrPixelRef.h" | 12 #include "SkGrPixelRef.h" |
13 #include "SkImage.h" | 13 #include "SkImage.h" |
14 #include "SkRecordDraw.h" | 14 #include "SkRecordDraw.h" |
15 #include "SkRecords.h" | 15 #include "SkRecords.h" |
16 | 16 |
17 static inline void wrap_texture(GrTexture* texture, int width, int height, SkBit
map* result) { | 17 static inline void wrap_texture(GrTexture* texture, int width, int height, SkBit
map* result) { |
18 SkImageInfo info = SkImageInfo::MakeN32Premul(width, height); | 18 SkImageInfo info = SkImageInfo::MakeN32Premul(width, height); |
19 result->setInfo(info); | 19 result->setInfo(info); |
20 result->setPixelRef(SkNEW_ARGS(SkGrPixelRef, (info, texture)))->unref(); | 20 result->setPixelRef(SkNEW_ARGS(SkGrPixelRef, (info, texture)))->unref(); |
21 } | 21 } |
22 | 22 |
23 static inline void draw_replacement_bitmap(GrCachedLayer* layer, SkCanvas* canva
s) { | 23 static inline void draw_replacement_bitmap(GrCachedLayer* layer, SkCanvas* canva
s) { |
24 | 24 |
| 25 // Some image filter can totally filter away a layer (e.g., SkPictureImageFi
lter's with |
| 26 // no picture). |
| 27 if (!layer->texture()) { |
| 28 return; |
| 29 } |
| 30 |
25 SkBitmap bm; | 31 SkBitmap bm; |
26 wrap_texture(layer->texture(), | 32 wrap_texture(layer->texture(), |
27 !layer->isAtlased() ? layer->rect().width() : layer->texture()
->width(), | 33 !layer->isAtlased() ? layer->rect().width() : layer->texture()
->width(), |
28 !layer->isAtlased() ? layer->rect().height() : layer->texture()
->height(), | 34 !layer->isAtlased() ? layer->rect().height() : layer->texture()
->height(), |
29 &bm); | 35 &bm); |
30 | 36 |
31 if (layer->isAtlased()) { | 37 if (layer->isAtlased()) { |
32 const SkRect src = SkRect::Make(layer->rect()); | 38 const SkRect src = SkRect::Make(layer->rect()); |
33 const SkRect dst = SkRect::Make(layer->srcIR()); | 39 const SkRect dst = SkRect::Make(layer->srcIR()); |
34 | 40 |
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
204 const SkMatrix& initialMatrix, | 210 const SkMatrix& initialMatrix, |
205 SkPicture::AbortCallback* callback) { | 211 SkPicture::AbortCallback* callback) { |
206 SkAutoCanvasRestore saveRestore(canvas, true /*save now, restore at exit*/); | 212 SkAutoCanvasRestore saveRestore(canvas, true /*save now, restore at exit*/); |
207 | 213 |
208 // TODO: drawablePicts? | 214 // TODO: drawablePicts? |
209 ReplaceDraw draw(canvas, layerCache, NULL, 0, | 215 ReplaceDraw draw(canvas, layerCache, NULL, 0, |
210 picture, picture, | 216 picture, picture, |
211 initialMatrix, callback, NULL, 0); | 217 initialMatrix, callback, NULL, 0); |
212 return draw.draw(); | 218 return draw.draw(); |
213 } | 219 } |
OLD | NEW |