#include "SkMatrix.h"
#include "SkPath.h"
#include "SkPoint.h"
+#include "SkPoint3.h"
#include "SkRRect.h"
#include "SkRect.h"
#include "SkRegion.h"
*(SkPoint*)this->reserve(sizeof(pt)) = pt;
}
+ void writePoint3(const SkPoint3& pt) {
+ *(SkPoint3*)this->reserve(sizeof(pt)) = pt;
+ }
+
void writeRect(const SkRect& rect) {
*(SkRect*)this->reserve(sizeof(rect)) = rect;
}
SkPoint3 fZPlaneParams;
SkPoint3 fLightPos;
SkScalar fLightRadius;
- float fAmbientAlpha;
- float fSpotAlpha;
+ SkScalar fAmbientAlpha;
+ SkScalar fSpotAlpha;
SkColor fColor;
uint32_t fFlags;
};
TRANSLATE_Z, // deprecated (M60)
- DRAW_SHADOWED_PICTURE_LIGHTS, // deprecated (M60)
+ DRAW_SHADOW_REC,
DRAW_IMAGE_LATTICE,
DRAW_ARC,
DRAW_REGION,
*/
#include "SkCanvas.h"
+#include "SkDrawShadowRec.h"
#include "SkPatchUtils.h"
#include "SkPictureData.h"
#include "SkPicturePlayback.h"
canvas->drawRRect(rrect, *paint);
}
} break;
+ case DRAW_SHADOW_REC: {
+ const auto& path = fPictureData->getPath(reader);
+ SkDrawShadowRec rec;
+ reader->readPoint3(&rec.fZPlaneParams);
+ reader->readPoint3(&rec.fLightPos);
+ rec.fLightRadius = reader->readScalar();
+ rec.fAmbientAlpha = reader->readScalar();
+ rec.fSpotAlpha = reader->readScalar();
+ rec.fColor = reader->read32();
+ rec.fFlags = reader->read32();
+ BREAK_ON_READ_ERROR(reader);
+
+ canvas->private_draw_shadow_rec(path, rec);
+ } break;
case DRAW_SPRITE: {
/* const SkPaint* paint = */ fPictureData->getPaint(reader);
/* const SkImage* image = */ fPictureData->getBitmapAsImage(reader);
*/
#include "SkPictureRecord.h"
+#include "SkDrawShadowRec.h"
#include "SkImage_Base.h"
#include "SkPatchUtils.h"
#include "SkPixelRef.h"
this->validate(initialOffset, size);
}
+void SkPictureRecord::onDrawShadowRec(const SkPath& path, const SkDrawShadowRec& rec) {
+ // op + path index + zParams + lightPos + lightRadius + spot/ambient alphas + color + flags
+ size_t size = 2 * kUInt32Size + 2 * sizeof(SkPoint3) + 3 * sizeof(SkScalar) + 2 * kUInt32Size;
+ size_t initialOffset = this->addDraw(DRAW_SHADOW_REC, &size);
+
+ this->addPath(path);
+
+ fWriter.writePoint3(rec.fZPlaneParams);
+ fWriter.writePoint3(rec.fLightPos);
+ fWriter.writeScalar(rec.fLightRadius);
+ fWriter.writeScalar(rec.fAmbientAlpha);
+ fWriter.writeScalar(rec.fSpotAlpha);
+ fWriter.write32(rec.fColor);
+ fWriter.write32(rec.fFlags);
+
+ this->validate(initialOffset, size);
+}
+
void SkPictureRecord::onDrawAnnotation(const SkRect& rect, const char key[], SkData* value) {
size_t keyLen = fWriter.WriteStringSize(key);
size_t valueLen = fWriter.WriteDataSize(value);
const SkPaint*) override;
void onDrawImageLattice(const SkImage*, const SkCanvas::Lattice& lattice, const SkRect& dst,
const SkPaint*) override;
+ void onDrawShadowRec(const SkPath&, const SkDrawShadowRec&) override;
void onDrawVerticesObject(const SkVertices*, SkBlendMode, const SkPaint&) override;
void onClipRect(const SkRect&, SkClipOp, ClipEdgeStyle) override;
point->fY = fReader.readScalar();
}
+void SkReadBuffer::readPoint3(SkPoint3* point) {
+ point->fX = fReader.readScalar();
+ point->fY = fReader.readScalar();
+ point->fZ = fReader.readScalar();
+}
+
void SkReadBuffer::readMatrix(SkMatrix* matrix) {
fReader.readMatrix(matrix);
}
virtual void readColor4f(SkColor4f* color);
virtual void readPoint(SkPoint* point);
SkPoint readPoint() { SkPoint p; this->readPoint(&p); return p; }
+ virtual void readPoint3(SkPoint3* point);
virtual void readMatrix(SkMatrix* matrix);
virtual void readIRect(SkIRect* rect);
virtual void readRect(SkRect* rect);
point->fY = this->readScalar();
}
+void SkValidatingReadBuffer::readPoint3(SkPoint3* point) {
+ point->fX = this->readScalar();
+ point->fY = this->readScalar();
+ point->fZ = this->readScalar();
+}
+
void SkValidatingReadBuffer::readMatrix(SkMatrix* matrix) {
size_t size = 0;
if (!fError) {
SkFlattenable* readFlattenable(SkFlattenable::Type type) override;
void readColor4f(SkColor4f* color) override;
void readPoint(SkPoint* point) override;
+ void readPoint3(SkPoint3* point) override;
void readMatrix(SkMatrix* matrix) override;
void readIRect(SkIRect* rect) override;
void readRect(SkRect* rect) override;