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;
|
2021-06-04 14:07:25 +00:00
|
|
|
class SortKey;
|
2021-05-20 13:45:10 +00:00
|
|
|
|
|
|
|
#include "include/core/SkColor.h"
|
|
|
|
#include "include/core/SkRect.h"
|
|
|
|
|
2021-06-03 18:36:08 +00:00
|
|
|
#include "experimental/ngatoy/Fake.h"
|
2021-06-09 18:11:00 +00:00
|
|
|
#include "experimental/ngatoy/ngatypes.h"
|
2021-06-03 18:36:08 +00:00
|
|
|
|
2021-05-20 13:45:10 +00:00
|
|
|
class Cmd {
|
|
|
|
public:
|
2021-06-09 18:11:00 +00:00
|
|
|
Cmd() : fID(ID::Invalid()) {}
|
|
|
|
Cmd(ID id) : fID(id) {}
|
2021-05-20 13:45:10 +00:00
|
|
|
virtual ~Cmd() {}
|
|
|
|
|
2021-06-09 18:11:00 +00:00
|
|
|
ID id() const { return fID; }
|
2021-06-04 14:07:25 +00:00
|
|
|
|
|
|
|
virtual SortKey getKey() = 0;
|
|
|
|
|
2021-06-09 18:11:00 +00:00
|
|
|
virtual const FakeMCBlob* state() const { return nullptr; }
|
2021-05-20 13:45:10 +00:00
|
|
|
|
|
|
|
// To generate the actual image
|
|
|
|
virtual void execute(FakeCanvas*) const = 0;
|
2021-06-09 18:11:00 +00:00
|
|
|
virtual void rasterize(uint32_t zBuffer[256][256], SkBitmap* dstBM) const = 0;
|
2021-05-20 13:45:10 +00:00
|
|
|
|
|
|
|
// To generate the expected image
|
|
|
|
virtual void execute(SkCanvas*, const FakeMCBlob* priorState) const = 0;
|
|
|
|
virtual void dump() const = 0;
|
|
|
|
|
|
|
|
protected:
|
2021-06-09 18:11:00 +00:00
|
|
|
const ID fID;
|
2021-05-20 13:45:10 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
};
|
|
|
|
|
|
|
|
class RectCmd : public Cmd {
|
|
|
|
public:
|
2021-06-10 12:36:44 +00:00
|
|
|
RectCmd(ID, PaintersOrder, SkIRect, const FakePaint&, sk_sp<FakeMCBlob> state);
|
|
|
|
|
|
|
|
uint32_t getSortZ() const;
|
|
|
|
uint32_t getDrawZ() const;
|
2021-05-20 13:45:10 +00:00
|
|
|
|
2021-06-04 14:07:25 +00:00
|
|
|
SortKey getKey() override;
|
2021-06-09 18:11:00 +00:00
|
|
|
const FakeMCBlob* state() const override { return fMCState.get(); }
|
2021-06-04 14:07:25 +00:00
|
|
|
|
2021-05-20 13:45:10 +00:00
|
|
|
void execute(FakeCanvas*) const override;
|
|
|
|
void execute(SkCanvas* c, const FakeMCBlob* priorState) const override;
|
2021-06-09 18:11:00 +00:00
|
|
|
void rasterize(uint32_t zBuffer[256][256], SkBitmap* dstBM) const override;
|
2021-05-20 13:45:10 +00:00
|
|
|
|
|
|
|
void dump() const override {
|
2021-06-03 18:36:08 +00:00
|
|
|
SkDebugf("%d: drawRect %d %d %d %d -- %d",
|
2021-06-09 18:11:00 +00:00
|
|
|
fID.toInt(),
|
2021-06-03 18:36:08 +00:00
|
|
|
fRect.fLeft, fRect.fTop, fRect.fRight, fRect.fBottom,
|
2021-06-10 12:36:44 +00:00
|
|
|
fPaintersOrder.toUInt());
|
2021-05-20 13:45:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
|
|
|
private:
|
2021-06-10 12:36:44 +00:00
|
|
|
PaintersOrder fPaintersOrder;
|
2021-06-09 18:11:00 +00:00
|
|
|
SkIRect fRect;
|
|
|
|
FakePaint fPaint;
|
|
|
|
sk_sp<FakeMCBlob> fMCState;
|
2021-05-20 13:45:10 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // Cmds_DEFINED
|