1 /* 2 * Copyright 2014 Google Inc. 3 * 4 * Use of this source code is governed by a BSD-style license that can be 5 * found in the LICENSE file. 6 */ 7 8 #include "SkRecordDraw.h" 9 10 void SkRecordDraw(const SkRecord& record, SkCanvas* canvas) { 11 for (SkRecords::Draw draw(canvas); draw.index() < record.count(); draw.next()) { 12 record.visit<void>(draw.index(), draw); 13 } 14 } 15 16 namespace SkRecords { 17 18 bool Draw::skip(const PairedPushCull& r) { 19 if (fCanvas->quickReject(r.base->rect)) { 20 fIndex += r.skip; 21 return true; 22 } 23 return false; 24 } 25 26 bool Draw::skip(const BoundedDrawPosTextH& r) { 27 return fCanvas->quickRejectY(r.minY, r.maxY); 28 } 29 30 // NoOps draw nothing. 31 template <> void Draw::draw(const NoOp&) {} 32 33 #define DRAW(T, call) template <> void Draw::draw(const T& r) { fCanvas->call; } 34 DRAW(Restore, restore()); 35 DRAW(Save, save(r.flags)); 36 DRAW(SaveLayer, saveLayer(r.bounds, r.paint, r.flags)); 37 DRAW(PopCull, popCull()); 38 DRAW(PushCull, pushCull(r.rect)); 39 DRAW(Clear, clear(r.color)); 40 DRAW(Concat, concat(r.matrix)); 41 DRAW(SetMatrix, setMatrix(SkMatrix::Concat(fInitialCTM, r.matrix))); 42 43 DRAW(ClipPath, clipPath(r.path, r.op, r.doAA)); 44 DRAW(ClipRRect, clipRRect(r.rrect, r.op, r.doAA)); 45 DRAW(ClipRect, clipRect(r.rect, r.op, r.doAA)); 46 DRAW(ClipRegion, clipRegion(r.region, r.op)); 47 48 DRAW(DrawBitmap, drawBitmap(r.bitmap, r.left, r.top, r.paint)); 49 DRAW(DrawBitmapMatrix, drawBitmapMatrix(r.bitmap, r.matrix, r.paint)); 50 DRAW(DrawBitmapNine, drawBitmapNine(r.bitmap, r.center, r.dst, r.paint)); 51 DRAW(DrawBitmapRectToRect, drawBitmapRectToRect(r.bitmap, r.src, r.dst, r.paint, r.flags)); 52 DRAW(DrawDRRect, drawDRRect(r.outer, r.inner, r.paint)); 53 DRAW(DrawOval, drawOval(r.oval, r.paint)); 54 DRAW(DrawPaint, drawPaint(r.paint)); 55 DRAW(DrawPath, drawPath(r.path, r.paint)); 56 DRAW(DrawPoints, drawPoints(r.mode, r.count, r.pts, r.paint)); 57 DRAW(DrawPosText, drawPosText(r.text, r.byteLength, r.pos, r.paint)); 58 DRAW(DrawPosTextH, drawPosTextH(r.text, r.byteLength, r.xpos, r.y, r.paint)); 59 DRAW(DrawRRect, drawRRect(r.rrect, r.paint)); 60 DRAW(DrawRect, drawRect(r.rect, r.paint)); 61 DRAW(DrawSprite, drawSprite(r.bitmap, r.left, r.top, r.paint)); 62 DRAW(DrawText, drawText(r.text, r.byteLength, r.x, r.y, r.paint)); 63 DRAW(DrawTextOnPath, drawTextOnPath(r.text, r.byteLength, r.path, r.matrix, r.paint)); 64 DRAW(DrawVertices, drawVertices(r.vmode, r.vertexCount, r.vertices, r.texs, r.colors, 65 r.xmode.get(), r.indices, r.indexCount, r.paint)); 66 #undef DRAW 67 68 template <> void Draw::draw(const PairedPushCull& r) { this->draw(*r.base); } 69 template <> void Draw::draw(const BoundedDrawPosTextH& r) { this->draw(*r.base); } 70 71 } // namespace SkRecords 72