Index: src/core/SkPictureRecord.cpp |
diff --git a/src/core/SkPictureRecord.cpp b/src/core/SkPictureRecord.cpp |
index 0383dda3d519fe5ef38586eb2de9190b4782b555..5459a794a03375857ed915458f3c4f16c22c374a 100644 |
--- a/src/core/SkPictureRecord.cpp |
+++ b/src/core/SkPictureRecord.cpp |
@@ -8,6 +8,7 @@ |
#include "SkPictureRecord.h" |
#include "SkDevice.h" |
#include "SkImage_Base.h" |
+#include "SkLight.h" |
#include "SkPatchUtils.h" |
#include "SkPixelRef.h" |
#include "SkRRect.h" |
@@ -103,6 +104,7 @@ static inline size_t get_paint_offset(DrawType op, size_t opSize) { |
1, // DRAW_ATLAS - right after op code |
1, // DRAW_IMAGE_NINE - right after op code |
1, // DRAW_IMAGE_RECT - right after op code |
+ 1, // DRAW_LIT_ATLAS - right after op code |
}; |
SK_COMPILE_ASSERT(sizeof(gPaintOffsets) == LAST_DRAWTYPE_ENUM + 1, |
@@ -888,6 +890,50 @@ void SkPictureRecord::onDrawAtlas(const SkImage* atlas, const SkRSXform xform[], |
this->validate(initialOffset, size); |
} |
+void SkPictureRecord::onDrawLitAtlas(const SkImage* atlas, const SkRSXform xform[], |
+ const SkRect diffTex[], const SkRect normTex[], |
+ const SkColor colors[], int count, SkXfermode::Mode mode, |
+ const SkRect* cull, const SkPaint* paint, |
+ const SkLight lights[], int numLights) { |
+ // [op + paint-index + atlas-index + flags + count + lightCount] + [xform] + [diffTex + normTex] + |
+ // [*colors + mode] + cull + [lights] |
+ size_t size = 6 * kUInt32Size + count * sizeof(SkRSXform) + 2 * count * sizeof(SkRect) + |
+ numLights * sizeof(SkPoint3); |
+ 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_LIT_ATLAS, &size); |
+ SkASSERT(initialOffset+get_paint_offset(DRAW_LIT_ATLAS, size) == fWriter.bytesWritten()); |
+ this->addPaintPtr(paint); |
+ this->addImage(atlas); |
+ this->addInt(flags); |
+ this->addInt(count); |
+ fWriter.write(xform, count * sizeof(SkRSXform)); |
+ fWriter.write(diffTex, count * sizeof(SkRect)); |
+ fWriter.write(normTex, 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->addInt(numLights); |
+ fWriter.write(lights, numLights* sizeof(SkLight)); |
+ |
+ this->validate(initialOffset, size); |
+} |
/////////////////////////////////////////////////////////////////////////////// |
SkSurface* SkPictureRecord::onNewSurface(const SkImageInfo& info, const SkSurfaceProps&) { |