| 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 "SkLayerInfo.h" | 8 #include "SkLayerInfo.h" |
| 9 #include "SkRecordDraw.h" | 9 #include "SkRecordDraw.h" |
| 10 #include "SkPatchUtils.h" | 10 #include "SkPatchUtils.h" |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 | 67 |
| 68 stop = SkTMin(stop, record.count()); | 68 stop = SkTMin(stop, record.count()); |
| 69 SkRecords::Draw draw(canvas, drawablePicts, NULL, drawableCount, &initialCTM
); | 69 SkRecords::Draw draw(canvas, drawablePicts, NULL, drawableCount, &initialCTM
); |
| 70 for (unsigned i = start; i < stop; i++) { | 70 for (unsigned i = start; i < stop; i++) { |
| 71 record.visit<void>(i, draw); | 71 record.visit<void>(i, draw); |
| 72 } | 72 } |
| 73 } | 73 } |
| 74 | 74 |
| 75 namespace SkRecords { | 75 namespace SkRecords { |
| 76 | 76 |
| 77 // FIXME: SkBitmaps are stateful, so we need to copy them to play back in multip
le threads. | |
| 78 static SkBitmap shallow_copy(const SkBitmap& bitmap) { | |
| 79 return bitmap; | |
| 80 } | |
| 81 | |
| 82 // NoOps draw nothing. | 77 // NoOps draw nothing. |
| 83 template <> void Draw::draw(const NoOp&) {} | 78 template <> void Draw::draw(const NoOp&) {} |
| 84 | 79 |
| 85 #define DRAW(T, call) template <> void Draw::draw(const T& r) { fCanvas->call; } | 80 #define DRAW(T, call) template <> void Draw::draw(const T& r) { fCanvas->call; } |
| 86 DRAW(Restore, restore()); | 81 DRAW(Restore, restore()); |
| 87 DRAW(Save, save()); | 82 DRAW(Save, save()); |
| 88 DRAW(SaveLayer, saveLayer(r.bounds, r.paint, r.flags)); | 83 DRAW(SaveLayer, saveLayer(r.bounds, r.paint, r.flags)); |
| 89 DRAW(PopCull, popCull()); | 84 DRAW(PopCull, popCull()); |
| 90 DRAW(PushCull, pushCull(r.rect)); | 85 DRAW(PushCull, pushCull(r.rect)); |
| 91 DRAW(Clear, clear(r.color)); | 86 DRAW(Clear, clear(r.color)); |
| 92 DRAW(SetMatrix, setMatrix(SkMatrix::Concat(fInitialCTM, r.matrix))); | 87 DRAW(SetMatrix, setMatrix(SkMatrix::Concat(fInitialCTM, r.matrix))); |
| 93 | 88 |
| 94 DRAW(ClipPath, clipPath(r.path, r.opAA.op, r.opAA.aa)); | 89 DRAW(ClipPath, clipPath(r.path, r.opAA.op, r.opAA.aa)); |
| 95 DRAW(ClipRRect, clipRRect(r.rrect, r.opAA.op, r.opAA.aa)); | 90 DRAW(ClipRRect, clipRRect(r.rrect, r.opAA.op, r.opAA.aa)); |
| 96 DRAW(ClipRect, clipRect(r.rect, r.opAA.op, r.opAA.aa)); | 91 DRAW(ClipRect, clipRect(r.rect, r.opAA.op, r.opAA.aa)); |
| 97 DRAW(ClipRegion, clipRegion(r.region, r.op)); | 92 DRAW(ClipRegion, clipRegion(r.region, r.op)); |
| 98 | 93 |
| 99 DRAW(BeginCommentGroup, beginCommentGroup(r.description)); | 94 DRAW(BeginCommentGroup, beginCommentGroup(r.description)); |
| 100 DRAW(AddComment, addComment(r.key, r.value)); | 95 DRAW(AddComment, addComment(r.key, r.value)); |
| 101 DRAW(EndCommentGroup, endCommentGroup()); | 96 DRAW(EndCommentGroup, endCommentGroup()); |
| 102 | 97 |
| 103 DRAW(DrawBitmap, drawBitmap(shallow_copy(r.bitmap), r.left, r.top, r.paint)); | 98 DRAW(DrawBitmap, drawBitmap(r.bitmap.shallowCopy(), r.left, r.top, r.paint)); |
| 104 DRAW(DrawBitmapNine, drawBitmapNine(shallow_copy(r.bitmap), r.center, r.dst, r.p
aint)); | 99 DRAW(DrawBitmapNine, drawBitmapNine(r.bitmap.shallowCopy(), r.center, r.dst, r.p
aint)); |
| 105 DRAW(DrawBitmapRectToRect, | 100 DRAW(DrawBitmapRectToRect, |
| 106 drawBitmapRectToRect(shallow_copy(r.bitmap), r.src, r.dst, r.paint, | 101 drawBitmapRectToRect(r.bitmap.shallowCopy(), r.src, r.dst, r.paint, |
| 107 SkCanvas::kNone_DrawBitmapRectFlag)); | 102 SkCanvas::kNone_DrawBitmapRectFlag)); |
| 108 DRAW(DrawBitmapRectToRectBleed, | 103 DRAW(DrawBitmapRectToRectBleed, |
| 109 drawBitmapRectToRect(shallow_copy(r.bitmap), r.src, r.dst, r.paint, | 104 drawBitmapRectToRect(r.bitmap.shallowCopy(), r.src, r.dst, r.paint, |
| 110 SkCanvas::kBleed_DrawBitmapRectFlag)); | 105 SkCanvas::kBleed_DrawBitmapRectFlag)); |
| 111 DRAW(DrawDRRect, drawDRRect(r.outer, r.inner, r.paint)); | 106 DRAW(DrawDRRect, drawDRRect(r.outer, r.inner, r.paint)); |
| 112 DRAW(DrawImage, drawImage(r.image, r.left, r.top, r.paint)); | 107 DRAW(DrawImage, drawImage(r.image, r.left, r.top, r.paint)); |
| 113 DRAW(DrawImageRect, drawImageRect(r.image, r.src, r.dst, r.paint)); | 108 DRAW(DrawImageRect, drawImageRect(r.image, r.src, r.dst, r.paint)); |
| 114 DRAW(DrawOval, drawOval(r.oval, r.paint)); | 109 DRAW(DrawOval, drawOval(r.oval, r.paint)); |
| 115 DRAW(DrawPaint, drawPaint(r.paint)); | 110 DRAW(DrawPaint, drawPaint(r.paint)); |
| 116 DRAW(DrawPath, drawPath(r.path, r.paint)); | 111 DRAW(DrawPath, drawPath(r.path, r.paint)); |
| 117 DRAW(DrawPatch, drawPatch(r.cubics, r.colors, r.texCoords, r.xmode, r.paint)); | 112 DRAW(DrawPatch, drawPatch(r.cubics, r.colors, r.texCoords, r.xmode, r.paint)); |
| 118 DRAW(DrawPicture, drawPicture(r.picture, &r.matrix, r.paint)); | 113 DRAW(DrawPicture, drawPicture(r.picture, &r.matrix, r.paint)); |
| 119 DRAW(DrawPoints, drawPoints(r.mode, r.count, r.pts, r.paint)); | 114 DRAW(DrawPoints, drawPoints(r.mode, r.count, r.pts, r.paint)); |
| 120 DRAW(DrawPosText, drawPosText(r.text, r.byteLength, r.pos, r.paint)); | 115 DRAW(DrawPosText, drawPosText(r.text, r.byteLength, r.pos, r.paint)); |
| 121 DRAW(DrawPosTextH, drawPosTextH(r.text, r.byteLength, r.xpos, r.y, r.paint)); | 116 DRAW(DrawPosTextH, drawPosTextH(r.text, r.byteLength, r.xpos, r.y, r.paint)); |
| 122 DRAW(DrawRRect, drawRRect(r.rrect, r.paint)); | 117 DRAW(DrawRRect, drawRRect(r.rrect, r.paint)); |
| 123 DRAW(DrawRect, drawRect(r.rect, r.paint)); | 118 DRAW(DrawRect, drawRect(r.rect, r.paint)); |
| 124 DRAW(DrawSprite, drawSprite(shallow_copy(r.bitmap), r.left, r.top, r.paint)); | 119 DRAW(DrawSprite, drawSprite(r.bitmap.shallowCopy(), r.left, r.top, r.paint)); |
| 125 DRAW(DrawText, drawText(r.text, r.byteLength, r.x, r.y, r.paint)); | 120 DRAW(DrawText, drawText(r.text, r.byteLength, r.x, r.y, r.paint)); |
| 126 DRAW(DrawTextBlob, drawTextBlob(r.blob, r.x, r.y, r.paint)); | 121 DRAW(DrawTextBlob, drawTextBlob(r.blob, r.x, r.y, r.paint)); |
| 127 DRAW(DrawTextOnPath, drawTextOnPath(r.text, r.byteLength, r.path, &r.matrix, r.p
aint)); | 122 DRAW(DrawTextOnPath, drawTextOnPath(r.text, r.byteLength, r.path, &r.matrix, r.p
aint)); |
| 128 DRAW(DrawVertices, drawVertices(r.vmode, r.vertexCount, r.vertices, r.texs, r.co
lors, | 123 DRAW(DrawVertices, drawVertices(r.vmode, r.vertexCount, r.vertices, r.texs, r.co
lors, |
| 129 r.xmode.get(), r.indices, r.indexCount, r.paint)
); | 124 r.xmode.get(), r.indices, r.indexCount, r.paint)
); |
| 130 DRAW(DrawData, drawData(r.data, r.length)); | 125 DRAW(DrawData, drawData(r.data, r.length)); |
| 131 #undef DRAW | 126 #undef DRAW |
| 132 | 127 |
| 133 template <> void Draw::draw(const DrawDrawable& r) { | 128 template <> void Draw::draw(const DrawDrawable& r) { |
| 134 SkASSERT(r.index >= 0); | 129 SkASSERT(r.index >= 0); |
| (...skipping 660 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 795 SkRecords::CollectLayers visitor(cullRect, record, pictList, data); | 790 SkRecords::CollectLayers visitor(cullRect, record, pictList, data); |
| 796 | 791 |
| 797 for (unsigned curOp = 0; curOp < record.count(); curOp++) { | 792 for (unsigned curOp = 0; curOp < record.count(); curOp++) { |
| 798 visitor.setCurrentOp(curOp); | 793 visitor.setCurrentOp(curOp); |
| 799 record.visit<void>(curOp, visitor); | 794 record.visit<void>(curOp, visitor); |
| 800 } | 795 } |
| 801 | 796 |
| 802 visitor.cleanUp(bbh); | 797 visitor.cleanUp(bbh); |
| 803 } | 798 } |
| 804 | 799 |
| OLD | NEW |