8#ifndef skgpu_AtlasTypes_DEFINED
9#define skgpu_AtlasTypes_DEFINED
71 void setEmpty() { memset(
this, 0,
sizeof(*
this)); }
73 void set(int16_t left, int16_t top, int16_t right, int16_t bottom) {
115 static_assert(
static_cast<int>(
MaskFormat::kA8) == 0,
"enum_order_dependency");
116 static_assert(
static_cast<int>(
MaskFormat::kA565) == 1,
"enum_order_dependency");
117 static_assert(
static_cast<int>(
MaskFormat::kARGB) == 2,
"enum_order_dependency");
119 return SkTo<int>(1u <<
static_cast<int>(
format));
141 return fGeneration++;
145 uint64_t fGeneration{1};
159 return fSequenceNumber == that.fSequenceNumber;
163 return fSequenceNumber < that.fSequenceNumber;
166 return fSequenceNumber <= that.fSequenceNumber;
169 return fSequenceNumber > that.fSequenceNumber;
172 return fSequenceNumber >= that.fSequenceNumber;
180 auto old = fSequenceNumber;
189 return *
this >=
start && *
this <=
end;
194 explicit AtlasToken(uint64_t sequenceNumber) : fSequenceNumber(sequenceNumber) {}
195 uint64_t fSequenceNumber;
218 friend class ::GrOpFlushState;
219 friend class ::TestingUploadTarget;
223 AtlasToken issueDrawToken() {
return ++fCurrentDrawToken; }
226 AtlasToken issueFlushToken() {
return ++fCurrentFlushToken; }
248 PlotLocator(uint32_t pageIdx, uint32_t plotIdx, uint64_t generation)
250 , fPlotIndex(plotIdx)
251 , fPageIndex(pageIdx) {
254 SkASSERT(generation < ((uint64_t)1 << 48));
264 fPlotIndex != 0 || fPageIndex != 0;
274 return fGenID == other.fGenID &&
275 fPlotIndex == other.fPlotIndex &&
276 fPageIndex == other.fPageIndex; }
280 uint64_t
genID()
const {
return fGenID; }
284 uint64_t fPlotIndex:8;
285 uint64_t fPageIndex:8;
310 return {fUVs[0] & 0x1FFF, fUVs[1]};
314 auto width = fUVs[2] - fUVs[0],
315 height = fUVs[3] - fUVs[1];
320 return fUVs[2] - fUVs[0];
324 return fUVs[3] - fUVs[1];
341 fUVs[0] = (fUVs[0] & 0x1FFF) |
page;
342 fUVs[2] = (fUVs[2] & 0x1FFF) |
page;
348 fUVs[0] = (fUVs[0] & 0xE000) |
rect.fLeft;
350 fUVs[2] = (fUVs[2] & 0xE000) |
rect.fRight;
351 fUVs[3] =
rect.fBottom;
359 std::array<uint16_t, 4> fUVs{0, 0, 0, 0};
380 memset(fPlotAlreadyUpdated, 0,
sizeof(fPlotAlreadyUpdated));
383 : fPlotsToUpdate(that.fPlotsToUpdate) {
384 memcpy(fPlotAlreadyUpdated, that.fPlotAlreadyUpdated,
sizeof(fPlotAlreadyUpdated));
390 if (this->find(pageIdx, plotIdx)) {
393 this->set(pageIdx, plotIdx);
398 fPlotsToUpdate.clear();
399 memset(fPlotAlreadyUpdated, 0,
sizeof(fPlotAlreadyUpdated));
408 int count()
const {
return fPlotsToUpdate.size(); }
413 bool find(
int pageIdx,
int index)
const {
415 return (fPlotAlreadyUpdated[pageIdx] >> index) & 1;
418 void set(
int pageIdx,
int index) {
419 SkASSERT(!this->find(pageIdx, index));
420 fPlotAlreadyUpdated[pageIdx] |= (1 << index);
421 fPlotsToUpdate.push_back(PlotData(pageIdx, index));
424 inline static constexpr int kMinItems = 4;
436 SK_DECLARE_INTERNAL_LLIST_INTERFACE(
Plot);
450 uint64_t
genID()
const {
return fGenID; }
504 void resetListPtrs() {
505 fPrev =
fNext =
nullptr;
515 int fFlushesSinceLastUse;
524 unsigned char* fData;
532 const size_t fBytesPerPixel;
@ kAlpha_8_SkColorType
pixel with alpha in 8-bit byte
@ kRGB_565_SkColorType
pixel with 5 bits red, 6 bits green, 5 bits blue, in 16-bit word
@ kRGBA_8888_SkColorType
pixel with 8 bits for red, green, blue, alpha; in 32-bit word
static SkColorType colorType(AImageDecoder *decoder, const AImageDecoderHeaderInfo *headerInfo)
constexpr int16_t SkToS16(S x)
static constexpr uint64_t kInvalidGeneration
uint32_t plotIndex() const
void updateRect(skgpu::IRect16 rect)
void invalidatePlotLocator()
std::array< uint16_t, 4 > getUVs() const
void insetSrc(int padding)
SkPoint widthHeight() const
PlotLocator plotLocator() const
void updatePlotLocator(PlotLocator p)
uint32_t pageIndex() const
bool operator>(const AtlasToken that) const
static AtlasToken InvalidToken()
bool operator>=(const AtlasToken that) const
bool inInterval(const AtlasToken &start, const AtlasToken &end)
AtlasToken(const AtlasToken &)=default
bool operator!=(const AtlasToken &that) const
AtlasToken & operator=(const AtlasToken &)=default
bool operator<=(const AtlasToken that) const
AtlasToken & operator++()
bool operator<(const AtlasToken that) const
AtlasToken operator++(int)
bool operator==(const AtlasToken &that) const
const PlotData & plotData(int index) const
bool add(const skgpu::AtlasLocator &atlasLocator)
BulkUsePlotUpdater(const BulkUsePlotUpdater &that)
virtual void evict(PlotLocator)=0
virtual ~PlotEvictionCallback()=default
static constexpr auto kMaxMultitexturePages
bool operator==(const PlotLocator &other) const
uint32_t plotIndex() const
PlotLocator(uint32_t pageIdx, uint32_t plotIdx, uint64_t generation)
static constexpr int kMaxPlots
uint32_t pageIndex() const
Plot(int pageIndex, int plotIndex, AtlasGenerationCounter *generationCounter, int offX, int offY, int width, int height, SkColorType colorType, size_t bpp)
bool addSubImage(int width, int height, const void *image, AtlasLocator *atlasLocator)
int flushesSinceLastUsed()
void incFlushesSinceLastUsed()
int AtlasLocator * atlasLocator
skgpu::AtlasToken lastUseToken() const
SkDEBUGCODE(size_t bpp() const { return fBytesPerPixel;}) bool addRect(int width
SkIPoint prepForRender(const AtlasLocator &, SkAutoPixmapStorage *)
const uint32_t fPageIndex
void * dataAt(const AtlasLocator &atlasLocator)
PlotLocator plotLocator() const
std::pair< const void *, SkIRect > prepareForUpload()
skgpu::AtlasToken lastUploadToken() const
void setLastUseToken(skgpu::AtlasToken token)
void setLastUploadToken(skgpu::AtlasToken token)
void resetFlushesSinceLastUsed()
uint32_t pageIndex() const
sk_sp< Plot > clone() const
void copySubImage(const AtlasLocator &atlasLocator, const void *image)
const uint32_t fPlotIndex
uint32_t plotIndex() const
AtlasToken nextFlushToken() const
AtlasToken nextDrawToken() const
uint32_t uint32_t * format
sk_sp< const SkImage > image
sk_sp< SkBlender > blender SkRect rect
skia_private::AutoTArray< sk_sp< SkImageFilter > > filters TypedMatrix matrix TypedMatrix matrix SkScalar dx
constexpr int MaskFormatBytesPerPixel(MaskFormat format)
static constexpr SkColorType MaskFormatToColorType(MaskFormat format)
SkTInternalLList< Plot > PlotList
static const int kMaskFormatCount
@ kA565
2-bytes per pixel, RGB represent 3-channel LCD coverage
@ kARGB
4-bytes per pixel, color format
int32_t fBottom
larger y-axis bounds
int32_t fTop
smaller y-axis bounds
int32_t fLeft
smaller x-axis bounds
int32_t fRight
larger x-axis bounds
static constexpr SkPoint Make(float x, float y)
PlotData(int pageIdx, int plotIdx)
void offset(int16_t dx, int16_t dy)
static IRect16 MakeEmpty()
static IRect16 Make(const SkIRect &ir)
void set(int16_t left, int16_t top, int16_t right, int16_t bottom)
static IRect16 MakeWH(int16_t w, int16_t h)
static IRect16 MakeXYWH(int16_t x, int16_t y, int16_t w, int16_t h)
void set(const SkIRect &r)