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 "SkBigPicture.h" | 11 #include "SkBigPicture.h" |
12 #include "SkCanvasPriv.h" | 12 #include "SkCanvasPriv.h" |
13 #include "SkGrPixelRef.h" | 13 #include "SkGr.h" |
14 #include "SkImage.h" | 14 #include "SkImage.h" |
15 #include "SkRecordDraw.h" | 15 #include "SkRecordDraw.h" |
16 #include "SkRecords.h" | 16 #include "SkRecords.h" |
17 | 17 |
18 static inline void wrap_texture(GrTexture* texture, int width, int height, SkBit
map* result) { | |
19 SkImageInfo info = SkImageInfo::MakeN32Premul(width, height); | |
20 result->setInfo(info); | |
21 result->setPixelRef(new SkGrPixelRef(info, texture))->unref(); | |
22 } | |
23 | 18 |
24 static inline void draw_replacement_bitmap(GrCachedLayer* layer, SkCanvas* canva
s) { | 19 static inline void draw_replacement_bitmap(GrCachedLayer* layer, SkCanvas* canva
s) { |
25 | 20 |
26 // Some image filter can totally filter away a layer (e.g., SkPictureImageFi
lter's with | 21 // Some image filter can totally filter away a layer (e.g., SkPictureImageFi
lter's with |
27 // no picture). | 22 // no picture). |
28 if (!layer->texture()) { | 23 if (!layer->texture()) { |
29 return; | 24 return; |
30 } | 25 } |
31 | 26 |
32 SkBitmap bm; | 27 SkBitmap bm; |
33 wrap_texture(layer->texture(), | 28 GrWrapTextureInBitmap(layer->texture(), |
34 !layer->isAtlased() ? layer->rect().width() : layer->texture()
->width(), | 29 !layer->isAtlased() ? layer->rect().width() : layer->
texture()->width(), |
35 !layer->isAtlased() ? layer->rect().height() : layer->texture()
->height(), | 30 !layer->isAtlased() ? layer->rect().height() : layer->
texture()->height(), |
36 &bm); | 31 false, |
| 32 &bm); |
37 | 33 |
38 canvas->save(); | 34 canvas->save(); |
39 canvas->setMatrix(SkMatrix::I()); | 35 canvas->setMatrix(SkMatrix::I()); |
40 if (layer->isAtlased()) { | 36 if (layer->isAtlased()) { |
41 const SkRect src = SkRect::Make(layer->rect()); | 37 const SkRect src = SkRect::Make(layer->rect()); |
42 const SkRect dst = SkRect::Make(layer->srcIR()); | 38 const SkRect dst = SkRect::Make(layer->srcIR()); |
43 | 39 |
44 SkASSERT(layer->offset().isZero()); | 40 SkASSERT(layer->offset().isZero()); |
45 | 41 |
46 canvas->drawBitmapRect(bm, src, dst, layer->paint(), SkCanvas::kStrict_S
rcRectConstraint); | 42 canvas->drawBitmapRect(bm, src, dst, layer->paint(), SkCanvas::kStrict_S
rcRectConstraint); |
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
221 ReplaceDraw draw(canvas, layerCache, nullptr, 0, | 217 ReplaceDraw draw(canvas, layerCache, nullptr, 0, |
222 bp, bp, | 218 bp, bp, |
223 initialMatrix, callback, nullptr, 0); | 219 initialMatrix, callback, nullptr, 0); |
224 return draw.draw(); | 220 return draw.draw(); |
225 } else { | 221 } else { |
226 // TODO: can we assume / assert this doesn't happen? | 222 // TODO: can we assume / assert this doesn't happen? |
227 picture->playback(canvas, callback); | 223 picture->playback(canvas, callback); |
228 return 0; | 224 return 0; |
229 } | 225 } |
230 } | 226 } |
OLD | NEW |