diff options
author | 2015-06-24 10:29:17 -0700 | |
---|---|---|
committer | 2015-06-24 10:29:18 -0700 | |
commit | 71c3c760a83123ee0b3127b8c65c6394ce541c50 (patch) | |
tree | d0a2492c668d2263874cdc0409056747f0a2fa5e /src/core/SkPictureRecord.cpp | |
parent | 52d4deb1288633551ad275be748d8b0f73d7b2aa (diff) |
add SkCanvas::drawAtlas
BUG=skia:
Review URL: https://codereview.chromium.org/1181913003
Diffstat (limited to 'src/core/SkPictureRecord.cpp')
-rw-r--r-- | src/core/SkPictureRecord.cpp | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/src/core/SkPictureRecord.cpp b/src/core/SkPictureRecord.cpp index 32033b52db..0fbf98089a 100644 --- a/src/core/SkPictureRecord.cpp +++ b/src/core/SkPictureRecord.cpp @@ -11,6 +11,7 @@ #include "SkPatchUtils.h" #include "SkPixelRef.h" #include "SkRRect.h" +#include "SkRSXform.h" #include "SkTextBlob.h" #include "SkTSearch.h" @@ -99,6 +100,7 @@ static inline size_t get_paint_offset(DrawType op, size_t opSize) { 1, // DRAW_TEXT_BLOB- right after op code 1, // DRAW_IMAGE - right after op code 1, // DRAW_IMAGE_RECT - right after op code + 1, // DRAW_ATLAS - right after op code }; SK_COMPILE_ASSERT(sizeof(gPaintOffsets) == LAST_DRAWTYPE_ENUM + 1, @@ -834,6 +836,42 @@ void SkPictureRecord::onDrawPatch(const SkPoint cubics[12], const SkColor colors this->validate(initialOffset, size); } +void SkPictureRecord::onDrawAtlas(const SkImage* atlas, const SkRSXform xform[], const SkRect tex[], + const SkColor colors[], int count, SkXfermode::Mode mode, + const SkRect* cull, const SkPaint* paint) { + // [op + paint-index + atlas-index + flags + count] + [xform] + [tex] + [*colors + mode] + cull + size_t size = 5 * kUInt32Size + count * sizeof(SkRSXform) + count * sizeof(SkRect); + uint32_t flags = 0; + if (colors) { + flags |= DRAW_ATLAS_HAS_COLORS; + size += count * sizeof(SkColor); + size += sizeof(uint32_t); // xfermode::mode + } + if (cull) { + flags |= DRAW_ATLAS_HAS_CULL; + size += sizeof(SkRect); + } + + size_t initialOffset = this->addDraw(DRAW_ATLAS, &size); + SkASSERT(initialOffset+get_paint_offset(DRAW_ATLAS, size) == fWriter.bytesWritten()); + this->addPaintPtr(paint); + this->addImage(atlas); + this->addInt(flags); + this->addInt(count); + fWriter.write(xform, count * sizeof(SkRSXform)); + fWriter.write(tex, count * sizeof(SkRect)); + + // write optional parameters + if (colors) { + fWriter.write(colors, count * sizeof(SkColor)); + this->addInt(mode); + } + if (cull) { + fWriter.write(cull, sizeof(SkRect)); + } + this->validate(initialOffset, size); +} + /////////////////////////////////////////////////////////////////////////////// SkSurface* SkPictureRecord::onNewSurface(const SkImageInfo& info, const SkSurfaceProps&) { |