| 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" |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 if (!layer->texture()) { | 28 if (!layer->texture()) { |
| 29 return; | 29 return; |
| 30 } | 30 } |
| 31 | 31 |
| 32 SkBitmap bm; | 32 SkBitmap bm; |
| 33 wrap_texture(layer->texture(), | 33 wrap_texture(layer->texture(), |
| 34 !layer->isAtlased() ? layer->rect().width() : layer->texture()
->width(), | 34 !layer->isAtlased() ? layer->rect().width() : layer->texture()
->width(), |
| 35 !layer->isAtlased() ? layer->rect().height() : layer->texture()
->height(), | 35 !layer->isAtlased() ? layer->rect().height() : layer->texture()
->height(), |
| 36 &bm); | 36 &bm); |
| 37 | 37 |
| 38 canvas->save(); |
| 39 canvas->setMatrix(SkMatrix::I()); |
| 38 if (layer->isAtlased()) { | 40 if (layer->isAtlased()) { |
| 39 const SkRect src = SkRect::Make(layer->rect()); | 41 const SkRect src = SkRect::Make(layer->rect()); |
| 40 const SkRect dst = SkRect::Make(layer->srcIR()); | 42 const SkRect dst = SkRect::Make(layer->srcIR()); |
| 41 | 43 |
| 42 SkASSERT(layer->offset().isZero()); | 44 SkASSERT(layer->offset().isZero()); |
| 43 | 45 |
| 44 canvas->save(); | |
| 45 canvas->setMatrix(SkMatrix::I()); | |
| 46 canvas->drawBitmapRect(bm, src, dst, layer->paint(), SkCanvas::kStrict_S
rcRectConstraint); | 46 canvas->drawBitmapRect(bm, src, dst, layer->paint(), SkCanvas::kStrict_S
rcRectConstraint); |
| 47 canvas->restore(); | |
| 48 } else { | 47 } else { |
| 49 canvas->drawSprite(bm, | 48 canvas->drawBitmap(bm, |
| 50 layer->srcIR().fLeft + layer->offset().fX, | 49 SkIntToScalar(layer->srcIR().fLeft + layer->offset().
fX), |
| 51 layer->srcIR().fTop + layer->offset().fY, | 50 SkIntToScalar(layer->srcIR().fTop + layer->offset().f
Y), |
| 52 layer->paint()); | 51 layer->paint()); |
| 53 } | 52 } |
| 53 canvas->restore(); |
| 54 } | 54 } |
| 55 | 55 |
| 56 // Used by GrRecordReplaceDraw. It intercepts nested drawPicture calls and | 56 // Used by GrRecordReplaceDraw. It intercepts nested drawPicture calls and |
| 57 // also draws them with replaced layers. | 57 // also draws them with replaced layers. |
| 58 class ReplaceDraw : public SkRecords::Draw { | 58 class ReplaceDraw : public SkRecords::Draw { |
| 59 public: | 59 public: |
| 60 ReplaceDraw(SkCanvas* canvas, GrLayerCache* layerCache, | 60 ReplaceDraw(SkCanvas* canvas, GrLayerCache* layerCache, |
| 61 SkPicture const* const drawablePicts[], int drawableCount, | 61 SkPicture const* const drawablePicts[], int drawableCount, |
| 62 const SkPicture* topLevelPicture, | 62 const SkPicture* topLevelPicture, |
| 63 const SkBigPicture* picture, | 63 const SkBigPicture* picture, |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 221 ReplaceDraw draw(canvas, layerCache, nullptr, 0, | 221 ReplaceDraw draw(canvas, layerCache, nullptr, 0, |
| 222 bp, bp, | 222 bp, bp, |
| 223 initialMatrix, callback, nullptr, 0); | 223 initialMatrix, callback, nullptr, 0); |
| 224 return draw.draw(); | 224 return draw.draw(); |
| 225 } else { | 225 } else { |
| 226 // TODO: can we assume / assert this doesn't happen? | 226 // TODO: can we assume / assert this doesn't happen? |
| 227 picture->playback(canvas, callback); | 227 picture->playback(canvas, callback); |
| 228 return 0; | 228 return 0; |
| 229 } | 229 } |
| 230 } | 230 } |
| OLD | NEW |