15#if defined(SK_GANESH) || defined(SK_GRAPHITE)
31class RectanizerSlide :
public Slide {
36 for (
int i = 0;
i < 3; ++
i) {
37 fRects[
i].reserve(kNumRandRects);
39 fRectLocations.reserve(kNumRandRects);
42 for (
int i = 0;
i < kNumRandRects; ++
i) {
44 random.
nextRangeU(kMinRectSize, kMaxRectSize));
52 fCurRects = &fRects[0];
54 fRectanizers.push_back(
56 fRectanizers.push_back(
67 case kCycleRectanizerKey:
68 this->cycleRectanizer();
81 if (fCurRandRect < kNumRandRects) {
82 if (fRectanizers[fCurRectanizer]->addRect((*fCurRects)[fCurRandRect].fWidth,
83 (*fCurRects)[fCurRandRect].fHeight,
84 &fRectLocations[fCurRandRect])) {
102 for (
int i = 0;
i < fCurRandRect; ++
i) {
109 totArea += (*fCurRects)[
i].fWidth * (*fCurRects)[
i].fHeight;
114 str.
printf(
"%s-%s: tot Area: %ld %%full: %.2f (%.2f) numTextures: %d/%d",
115 this->getRectanizerName(),
116 this->getRectsName(),
118 100.0f * fRectanizers[fCurRectanizer]->percentFull(),
124 str.
printf(
"Press \'j\' to toggle rectanizer");
127 str.
printf(
"Press \'h\' to toggle rects");
132 static const int kWidth = 1024;
133 static const int kHeight = 1024;
134 static const int kNumRandRects = 200;
135 static const char kCycleRectanizerKey =
'j';
136 static const char kCycleRectsKey =
'h';
137 static const int kMinRectSize = 2;
138 static const int kMaxRectSize = 256;
147 const char* getRectanizerName()
const {
148 if (!fCurRectanizer) {
155 void cycleRectanizer() {
156 fCurRectanizer = (fCurRectanizer + 1) % fRectanizers.
size();
158 fRectanizers[fCurRectanizer]->
reset();
162 const char* getRectsName()
const {
163 if (fCurRects == &fRects[0]) {
165 }
else if (fCurRects == &fRects[1]) {
173 if (fCurRects == &fRects[0]) {
174 fCurRects = &fRects[1];
175 }
else if (fCurRects == &fRects[1]) {
176 fCurRects = &fRects[2];
178 fCurRects = &fRects[0];
181 fRectanizers[fCurRectanizer]->
reset();
188DEF_SLIDE(
return new RectanizerSlide(); )
constexpr SkColor SK_ColorRED
constexpr SkColor SK_ColorWHITE
static uint32_t GrNextPow2(uint32_t n)
void drawRect(const SkRect &rect, const SkPaint &paint)
void clear(SkColor color)
void drawString(const char str[], SkScalar x, SkScalar y, const SkFont &font, const SkPaint &paint)
void setSize(SkScalar textSize)
void setStyle(Style style)
void setColor(SkColor color)
@ kStroke_Style
set to stroke geometry
uint32_t nextRangeU(uint32_t min, uint32_t max)
void printf(const char format[],...) SK_PRINTF_LIKE(2
virtual bool onChar(SkUnichar c)
virtual void draw(SkCanvas *canvas)=0
SK_SPI size_t ToUTF8(SkUnichar uni, char utf8[kMaxBytesInUTF8Sequence]=nullptr)
constexpr unsigned kMaxBytesInUTF8Sequence
it will be possible to load the file into Perfetto s trace viewer disable asset Prevents usage of any non test fonts unless they were explicitly Loaded via prefetched default font Indicates whether the embedding started a prefetch of the default font manager before creating the engine run In non interactive keep the shell running after the Dart script has completed enable serial On low power devices with low core running concurrent GC tasks on threads can cause them to contend with the UI thread which could potentially lead to jank This option turns off all concurrent GC activities domain network JSON encoded network policy per domain This overrides the DisallowInsecureConnections switch Embedder can specify whether to allow or disallow insecure connections at a domain level old gen heap size
static constexpr SkIPoint16 Make(int x, int y)
static constexpr SkISize Make(int32_t w, int32_t h)
static constexpr SkRect MakeXYWH(float x, float y, float w, float h)
static constexpr SkRect MakeWH(float w, float h)