class GrBackendSemaphore; class GrBackendTexture; class GrRecordingContext; class SkCapabilities; class SkColorSpace; class SkPaint; class SkPixmap; class GrSurfaceCharacterization; class SkSurfaceProps; enum GrSurfaceOrigin : int; enum SkYUVColorSpace : int; namespace skgpu { namespace graphite { class Recorder; } } struct SkIRect; struct SkISize; struct SkImageInfo;
class SkSurface_Base : public SkSurface {
public:
SkSurface_Base(int width, int height, const SkSurfaceProps*);
SkSurface_Base(const SkImageInfo&, const SkSurfaceProps*);
~SkSurface_Base() override;
enumclass Type {
kNull, // intentionally associating 0 with a null canvas
kGanesh,
kGraphite,
kRaster,
};
// TODO(kjlubick) Android directly subclasses SkSurface_Base for tests, so we // cannot make this a pure virtual. They seem to want a surface that is spy-able // or mockable, so maybe we should provide something like that.
virtual Type type() const { return Type::kNull; }
// True for surfaces instantiated by pixels in CPU memory bool isRasterBacked() const { return this->type() == Type::kRaster; } // True for surfaces instantiated by Ganesh in GPU memory bool isGaneshBacked() const { return this->type() == Type::kGanesh; } // True for surfaces instantiated by Graphite in GPU memory bool isGraphiteBacked() const { return this->type() == Type::kGraphite; }
// TODO: Remove this (make it pure virtual) after updating Android (which has a class derived // from SkSurface_Base).
virtual sk_sp<const SkCapabilities> onCapabilities();
// called by SkSurface to compute a new genID
uint32_t newGenerationID();
private: // fCachedCanvas is the raw pointer to the canvas that is returned to the client. // It can point to either the base canvas or a capture canvas wrapper.
SkCanvas* fCachedCanvas = nullptr; // SkSurface_Base must always own the base canvas. During capture, SkCaptureManager owns any // wrapping capture canvas that fCachedCanvas may point to.
std::unique_ptr<SkCanvas> fOwnedBaseCanvas = nullptr;
sk_sp<SkImage> fCachedImage = nullptr;
// Returns false if drawing should not take place (allocation failure).
[[nodiscard]] bool aboutToDraw(ContentChangeMode mode);
// Returns true if there is an outstanding image-snapshot, indicating that a call to aboutToDraw // would trigger a copy-on-write. bool outstandingImageSnapshot() const;
friendclass SkCanvas; friendclass SkSurface;
};
SkCanvas* SkSurface_Base::getCachedCanvas() { if (nullptr == fCachedCanvas) {
fOwnedBaseCanvas = std::unique_ptr<SkCanvas>(this->onNewCanvas()); if (fOwnedBaseCanvas) {
fOwnedBaseCanvas->setSurfaceBase(this);
} // Try to wrap base canvas in capture wrapper if (this->baseRecorder()) {
fCachedCanvas = this->baseRecorder()->makeCaptureCanvas(fOwnedBaseCanvas.get());
} if (!fCachedCanvas) {
fCachedCanvas = fOwnedBaseCanvas.get();
}
} return fCachedCanvas;
}
sk_sp<SkImage> SkSurface_Base::refCachedImage() { if (fCachedImage) { return fCachedImage;
}
this->createCaptureBreakpoint();
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.