SkIntToScalar(25)));
gm->setStarterMatrix(perspective);
- }
+ }
SkAutoTDelete<GM> adgm(gm);
++gmIndex;
if (moduloRemainder >= 0) {
}
{
- // Arc example to test imperfect truncation bug (crbug.com/295626)
+ // Arc example to test imperfect truncation bug (crbug.com/295626)
static const SkScalar kRad = SkIntToScalar(2000);
static const SkScalar kStartAngle = SkFloatToScalar(262.59717f);
static const SkScalar kSweepAngle = SkScalarHalf(SkFloatToScalar(17.188717f));
* it will automatically try to purge entries to meet the new limit.
*/
static int SetFontCacheCountLimit(int count);
-
+
/**
* For debugging purposes, this will attempt to purge the font cache. It
* does not change the limit, but will cause subsequent font measures and
Note: this bounds may be larger than the actual shape, since curves
do not extend as far as their control points.
*/
- const SkRect& getBounds() const {
+ const SkRect& getBounds() const {
if (fBoundsIsDirty) {
this->computeBounds();
}
kA8_GrMaskFormat, //!< 1-byte per pixel
kA565_GrMaskFormat, //!< 2-bytes per pixel
kA888_GrMaskFormat, //!< 4-bytes per pixel
-
+
kLast_GrMaskFormat = kA888_GrMaskFormat
};
static const int kMaskFormatCount = kLast_GrMaskFormat + 1;
if (newLimit < minLimit) {
newLimit = minLimit;
}
-
+
SkAutoMutexAcquire ac(fMutex);
-
+
size_t prevLimit = fCacheSizeLimit;
fCacheSizeLimit = newLimit;
this->internalPurge();
if (newCount < 0) {
newCount = 0;
}
-
+
SkAutoMutexAcquire ac(fMutex);
-
+
int prevCount = fCacheCountLimit;
fCacheCountLimit = newCount;
this->internalPurge();
cache->fNext = fHead;
}
fHead = cache;
-
+
fCacheCount += 1;
fTotalMemoryUsed += cache->fMemoryUsed;
}
void SkGlyphCache_Globals::validate() const {
size_t computedBytes = 0;
int computedCount = 0;
-
+
const SkGlyphCache* head = fHead;
while (head != NULL) {
computedBytes += head->fMemoryUsed;
computedCount += 1;
head = head->fNext;
}
-
+
SkASSERT(fTotalMemoryUsed == computedBytes);
SkASSERT(fCacheCount == computedCount);
}
kNo_UseMutex, // thread-local cache
kYes_UseMutex // shared cache
};
-
+
SkGlyphCache_Globals(UseMutex um) {
fHead = NULL;
fTotalMemoryUsed = 0;
fCacheSizeLimit = SK_DEFAULT_FONT_CACHE_LIMIT;
fCacheCount = 0;
fCacheCountLimit = SK_DEFAULT_FONT_CACHE_COUNT_LIMIT;
-
+
fMutex = (kYes_UseMutex == um) ? SkNEW(SkMutex) : NULL;
}
-
+
~SkGlyphCache_Globals() {
SkGlyphCache* cache = fHead;
while (cache) {
SkDELETE(cache);
cache = next;
}
-
+
SkDELETE(fMutex);
}
-
+
SkMutex* fMutex;
SkGlyphCache* internalGetHead() const { return fHead; }
// call when a glyphcache is available for caching (i.e. not in use)
void attachCacheToHead(SkGlyphCache*);
-
+
// can only be called when the mutex is already held
void internalDetachCache(SkGlyphCache*);
void internalAttachCacheToHead(SkGlyphCache*);
static SkGlyphCache_Globals* FindTLS() {
return (SkGlyphCache_Globals*)SkTLS::Find(CreateTLS);
}
-
+
static SkGlyphCache_Globals& GetTLS() {
return *(SkGlyphCache_Globals*)SkTLS::Get(CreateTLS, DeleteTLS);
}
-
+
static void DeleteTLS() { SkTLS::Delete(CreateTLS); }
-
+
private:
SkGlyphCache* fHead;
size_t fTotalMemoryUsed;
size_t fCacheSizeLimit;
int32_t fCacheCountLimit;
int32_t fCacheCount;
-
+
// Checkout budgets, modulated by the specified min-bytes-needed-to-purge,
// and attempt to purge caches to match.
// Returns number of bytes freed.
static void* CreateTLS() {
return SkNEW_ARGS(SkGlyphCache_Globals, (kNo_UseMutex));
}
-
+
static void DeleteTLS(void* ptr) {
SkDELETE((SkGlyphCache_Globals*)ptr);
}
SkPaint paint;
paint.setXfermodeMode(SkXfermode::kSrc_Mode);
- SkAutoTUnref<SkShader> shader(SkShader::CreateBitmapShader(subset,
+ SkAutoTUnref<SkShader> shader(SkShader::CreateBitmapShader(subset,
SkShader::kRepeat_TileMode, SkShader::kRepeat_TileMode));
paint.setShader(shader);
SkRect dstRect = fDstRect;
buffer.writeRect(fSrcRect);
buffer.writeRect(fDstRect);
}
-