2021-05-20 13:45:10 +00:00
|
|
|
// Copyright 2021 Google LLC.
|
|
|
|
// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
|
|
|
|
|
|
|
|
#ifndef Cmds_DEFINED
|
|
|
|
#define Cmds_DEFINED
|
|
|
|
|
|
|
|
class SkBitmap;
|
|
|
|
class SkCanvas;
|
|
|
|
class FakeCanvas;
|
|
|
|
class FakeMCBlob;
|
|
|
|
|
|
|
|
#include "include/core/SkColor.h"
|
|
|
|
#include "include/core/SkRect.h"
|
|
|
|
|
2021-06-03 18:36:08 +00:00
|
|
|
#include "experimental/ngatoy/Fake.h"
|
|
|
|
|
2021-05-20 13:45:10 +00:00
|
|
|
class Cmd {
|
|
|
|
public:
|
|
|
|
Cmd(int id, int materialID, sk_sp<FakeMCBlob> state)
|
|
|
|
: fID(id)
|
|
|
|
, fMaterialID(materialID)
|
|
|
|
, fMCState(std::move(state)) {
|
|
|
|
}
|
|
|
|
virtual ~Cmd() {}
|
|
|
|
|
|
|
|
int id() const { return fID; }
|
|
|
|
const FakeMCBlob* state() const { return fMCState.get(); }
|
|
|
|
|
|
|
|
// To generate the actual image
|
|
|
|
virtual void execute(FakeCanvas*) const = 0;
|
|
|
|
virtual void rasterize(uint32_t zBuffer[256][256], SkBitmap* dstBM, unsigned int z) const = 0;
|
|
|
|
|
|
|
|
// To generate the expected image
|
|
|
|
virtual void execute(SkCanvas*, const FakeMCBlob* priorState) const = 0;
|
|
|
|
virtual void dump() const = 0;
|
|
|
|
|
|
|
|
protected:
|
|
|
|
const int fID;
|
|
|
|
int fMaterialID;
|
|
|
|
sk_sp<FakeMCBlob> fMCState;
|
|
|
|
|
|
|
|
private:
|
|
|
|
};
|
|
|
|
|
|
|
|
class RectCmd : public Cmd {
|
|
|
|
public:
|
2021-06-03 18:36:08 +00:00
|
|
|
RectCmd(int id, uint32_t paintersOrder, SkIRect, const FakePaint&, sk_sp<FakeMCBlob> state);
|
2021-05-20 13:45:10 +00:00
|
|
|
|
|
|
|
void execute(FakeCanvas*) const override;
|
|
|
|
void execute(SkCanvas* c, const FakeMCBlob* priorState) const override;
|
|
|
|
void rasterize(uint32_t zBuffer[256][256], SkBitmap* dstBM, unsigned int z) const override;
|
|
|
|
|
|
|
|
void dump() const override {
|
2021-06-03 18:36:08 +00:00
|
|
|
SkDebugf("%d: drawRect %d %d %d %d -- %d",
|
2021-05-20 13:45:10 +00:00
|
|
|
fID,
|
2021-06-03 18:36:08 +00:00
|
|
|
fRect.fLeft, fRect.fTop, fRect.fRight, fRect.fBottom,
|
|
|
|
fPaintersOrder);
|
2021-05-20 13:45:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
|
|
|
private:
|
2021-06-03 18:36:08 +00:00
|
|
|
uint32_t fPaintersOrder;
|
|
|
|
SkIRect fRect;
|
|
|
|
FakePaint fPaint;
|
2021-05-20 13:45:10 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // Cmds_DEFINED
|