Upstream changes from Android.
Review URL: https://codereview.chromium.org/12699002 git-svn-id: http://skia.googlecode.com/svn/trunk@8045 2bbb7eff-a529-9590-31e7-b0007b416f81
This commit is contained in:
parent
184487c808
commit
4bd2bdbf04
@ -542,6 +542,20 @@ public:
|
||||
*/
|
||||
int extractMipLevel(SkBitmap* dst, SkFixed sx, SkFixed sy);
|
||||
|
||||
#ifdef SK_BUILD_FOR_ANDROID
|
||||
bool hasHardwareMipMap() const {
|
||||
return (fFlags & kHasHardwareMipMap_Flag) != 0;
|
||||
}
|
||||
|
||||
void setHasHardwareMipMap(bool hasHardwareMipMap) {
|
||||
if (hasHardwareMipMap) {
|
||||
fFlags |= kHasHardwareMipMap_Flag;
|
||||
} else {
|
||||
fFlags &= ~kHasHardwareMipMap_Flag;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
bool extractAlpha(SkBitmap* dst) const {
|
||||
return this->extractAlpha(dst, NULL, NULL, NULL);
|
||||
}
|
||||
@ -642,7 +656,14 @@ private:
|
||||
enum Flags {
|
||||
kImageIsOpaque_Flag = 0x01,
|
||||
kImageIsVolatile_Flag = 0x02,
|
||||
kImageIsImmutable_Flag = 0x04
|
||||
kImageIsImmutable_Flag = 0x04,
|
||||
#ifdef SK_BUILD_FOR_ANDROID
|
||||
/* A hint for the renderer responsible for drawing this bitmap
|
||||
* indicating that it should attempt to use mipmaps when this bitmap
|
||||
* is drawn scaled down.
|
||||
*/
|
||||
kHasHardwareMipMap_Flag = 0x08,
|
||||
#endif
|
||||
};
|
||||
|
||||
uint32_t fRowBytes;
|
||||
|
@ -850,11 +850,12 @@ public:
|
||||
const SkPoint pos[], SkPath* path) const;
|
||||
|
||||
#ifdef SK_BUILD_FOR_ANDROID
|
||||
const SkGlyph& getUnicharMetrics(SkUnichar);
|
||||
const SkGlyph& getGlyphMetrics(uint16_t);
|
||||
const void* findImage(const SkGlyph&);
|
||||
const SkGlyph& getUnicharMetrics(SkUnichar, const SkMatrix*);
|
||||
const SkGlyph& getGlyphMetrics(uint16_t, const SkMatrix*);
|
||||
const void* findImage(const SkGlyph&, const SkMatrix*);
|
||||
|
||||
uint32_t getGenerationID() const;
|
||||
void setGenerationID(uint32_t generationID);
|
||||
|
||||
/** Returns the base glyph count for the strike associated with this paint
|
||||
*/
|
||||
|
@ -188,12 +188,14 @@ public:
|
||||
|
||||
friend bool operator==(const SkRRect& a, const SkRRect& b) {
|
||||
return a.fRect == b.fRect &&
|
||||
SkScalarsEqual((SkScalar*) a.fRadii, (SkScalar*) b.fRadii, 8);
|
||||
SkScalarsEqual(a.fRadii[0].asScalars(),
|
||||
b.fRadii[0].asScalars(), 8);
|
||||
}
|
||||
|
||||
friend bool operator!=(const SkRRect& a, const SkRRect& b) {
|
||||
return a.fRect != b.fRect ||
|
||||
!SkScalarsEqual((SkScalar*) a.fRadii, (SkScalar*) b.fRadii, 8);
|
||||
!SkScalarsEqual(a.fRadii[0].asScalars(),
|
||||
b.fRadii[0].asScalars(), 8);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -61,13 +61,14 @@ static inline __attribute__((always_inline)) void sk_membar_aquire__after_atomic
|
||||
#define sk_atomic_inc(addr) android_atomic_inc(addr)
|
||||
#define sk_atomic_add(addr, inc) android_atomic_add(inc, addr)
|
||||
#define sk_atomic_dec(addr) android_atomic_dec(addr)
|
||||
void sk_membar_aquire__after_atomic_dec() {
|
||||
|
||||
static inline __attribute__((always_inline)) void sk_membar_aquire__after_atomic_dec() {
|
||||
//HACK: Android is actually using full memory barriers.
|
||||
// Should this change, uncomment below.
|
||||
//int dummy;
|
||||
//android_atomic_aquire_store(0, &dummy);
|
||||
}
|
||||
int32_t sk_atomic_conditional_inc(int32_t* addr) {
|
||||
static inline __attribute__((always_inline)) int32_t sk_atomic_conditional_inc(int32_t* addr) {
|
||||
while (true) {
|
||||
int32_t value = *addr;
|
||||
if (value == 0) {
|
||||
@ -78,7 +79,7 @@ int32_t sk_atomic_conditional_inc(int32_t* addr) {
|
||||
}
|
||||
}
|
||||
}
|
||||
void sk_membar_aquire__after_atomic_conditional_inc() {
|
||||
static inline __attribute__((always_inline)) void sk_membar_aquire__after_atomic_conditional_inc() {
|
||||
//HACK: Android is actually using full memory barriers.
|
||||
// Should this change, uncomment below.
|
||||
//int dummy;
|
||||
|
@ -176,6 +176,10 @@ void SkPaint::reset() {
|
||||
uint32_t SkPaint::getGenerationID() const {
|
||||
return fGenerationID;
|
||||
}
|
||||
|
||||
void SkPaint::setGenerationID(uint32_t generationID) {
|
||||
fGenerationID = generationID;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef SK_BUILD_FOR_ANDROID
|
||||
@ -415,9 +419,10 @@ static void DetachDescProc(const SkDescriptor* desc, void* context) {
|
||||
}
|
||||
|
||||
#ifdef SK_BUILD_FOR_ANDROID
|
||||
const SkGlyph& SkPaint::getUnicharMetrics(SkUnichar text) {
|
||||
const SkGlyph& SkPaint::getUnicharMetrics(SkUnichar text,
|
||||
const SkMatrix* deviceMatrix) {
|
||||
SkGlyphCache* cache;
|
||||
descriptorProc(NULL, NULL, DetachDescProc, &cache, true);
|
||||
descriptorProc(NULL, deviceMatrix, DetachDescProc, &cache, true);
|
||||
|
||||
const SkGlyph& glyph = cache->getUnicharMetrics(text);
|
||||
|
||||
@ -425,9 +430,10 @@ const SkGlyph& SkPaint::getUnicharMetrics(SkUnichar text) {
|
||||
return glyph;
|
||||
}
|
||||
|
||||
const SkGlyph& SkPaint::getGlyphMetrics(uint16_t glyphId) {
|
||||
const SkGlyph& SkPaint::getGlyphMetrics(uint16_t glyphId,
|
||||
const SkMatrix* deviceMatrix) {
|
||||
SkGlyphCache* cache;
|
||||
descriptorProc(NULL, NULL, DetachDescProc, &cache, true);
|
||||
descriptorProc(NULL, deviceMatrix, DetachDescProc, &cache, true);
|
||||
|
||||
const SkGlyph& glyph = cache->getGlyphIDMetrics(glyphId);
|
||||
|
||||
@ -435,10 +441,11 @@ const SkGlyph& SkPaint::getGlyphMetrics(uint16_t glyphId) {
|
||||
return glyph;
|
||||
}
|
||||
|
||||
const void* SkPaint::findImage(const SkGlyph& glyph) {
|
||||
const void* SkPaint::findImage(const SkGlyph& glyph,
|
||||
const SkMatrix* deviceMatrix) {
|
||||
// See ::detachCache()
|
||||
SkGlyphCache* cache;
|
||||
descriptorProc(NULL, NULL, DetachDescProc, &cache, true);
|
||||
descriptorProc(NULL, deviceMatrix, DetachDescProc, &cache, true);
|
||||
|
||||
const void* image = cache->findImage(glyph);
|
||||
|
||||
@ -900,17 +907,26 @@ public:
|
||||
fTextSize = paint->getTextSize();
|
||||
fStyle = paint->getStyle();
|
||||
fPaint->setStyle(SkPaint::kFill_Style);
|
||||
#ifdef SK_BUILD_FOR_ANDROID
|
||||
fGenerationID = fPaint->getGenerationID();
|
||||
#endif
|
||||
}
|
||||
|
||||
~SkAutoRestorePaintTextSizeAndFrame() {
|
||||
fPaint->setStyle(fStyle);
|
||||
fPaint->setTextSize(fTextSize);
|
||||
#ifdef SK_BUILD_FOR_ANDROID
|
||||
fPaint->setGenerationID(fGenerationID);
|
||||
#endif
|
||||
}
|
||||
|
||||
private:
|
||||
SkPaint* fPaint;
|
||||
SkScalar fTextSize;
|
||||
SkPaint::Style fStyle;
|
||||
#ifdef SK_BUILD_FOR_ANDROID
|
||||
uint32_t fGenerationID;
|
||||
#endif
|
||||
};
|
||||
|
||||
static void set_bounds(const SkGlyph& g, SkRect* bounds) {
|
||||
|
@ -1680,6 +1680,12 @@ void SkPath::transform(const SkMatrix& matrix, SkPath* dst) const {
|
||||
dst->fConvexity = fConvexity;
|
||||
}
|
||||
|
||||
#ifdef SK_BUILD_FOR_ANDROID
|
||||
if (!matrix.isIdentity()) {
|
||||
GEN_ID_PTR_INC(dst);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (kUnknown_Direction == fDirection) {
|
||||
dst->fDirection = kUnknown_Direction;
|
||||
} else {
|
||||
|
@ -178,7 +178,35 @@ SkScalerContext* SkScalerContext::getGlyphContext(const SkGlyph& glyph) {
|
||||
return ctx;
|
||||
}
|
||||
|
||||
SkScalerContext* SkScalerContext::getContextFromChar(SkUnichar uni,
|
||||
uint16_t* glyphID) {
|
||||
SkScalerContext* ctx = this;
|
||||
for (;;) {
|
||||
const uint16_t glyph = ctx->generateCharToGlyph(uni);
|
||||
if (glyph) {
|
||||
if (NULL != glyphID) {
|
||||
*glyphID = glyph;
|
||||
}
|
||||
break; // found it
|
||||
}
|
||||
ctx = ctx->getNextContext();
|
||||
if (NULL == ctx) {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
return ctx;
|
||||
}
|
||||
|
||||
#ifdef SK_BUILD_FOR_ANDROID
|
||||
SkFontID SkScalerContext::findTypefaceIdForChar(SkUnichar uni) {
|
||||
SkScalerContext* ctx = this->getContextFromChar(uni, NULL);
|
||||
if (NULL != ctx) {
|
||||
return ctx->fRec.fFontID;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/* This loops through all available fallback contexts (if needed) until it
|
||||
finds some context that can handle the unichar and return it.
|
||||
|
||||
@ -186,42 +214,28 @@ SkScalerContext* SkScalerContext::getGlyphContext(const SkGlyph& glyph) {
|
||||
char of a run.
|
||||
*/
|
||||
unsigned SkScalerContext::getBaseGlyphCount(SkUnichar uni) {
|
||||
SkScalerContext* ctx = this;
|
||||
unsigned glyphID;
|
||||
for (;;) {
|
||||
glyphID = ctx->generateCharToGlyph(uni);
|
||||
if (glyphID) {
|
||||
break; // found it
|
||||
}
|
||||
ctx = ctx->getNextContext();
|
||||
if (NULL == ctx) {
|
||||
SkDebugf("--- no context for char %x\n", uni);
|
||||
// just return the original context (this)
|
||||
SkScalerContext* ctx = this->getContextFromChar(uni, NULL);
|
||||
if (NULL != ctx) {
|
||||
return ctx->fBaseGlyphCount;
|
||||
} else {
|
||||
SkDEBUGF(("--- no context for char %x\n", uni));
|
||||
return this->fBaseGlyphCount;
|
||||
}
|
||||
}
|
||||
return ctx->fBaseGlyphCount;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* This loops through all available fallback contexts (if needed) until it
|
||||
finds some context that can handle the unichar. If all fail, returns 0
|
||||
*/
|
||||
uint16_t SkScalerContext::charToGlyphID(SkUnichar uni) {
|
||||
SkScalerContext* ctx = this;
|
||||
unsigned glyphID;
|
||||
for (;;) {
|
||||
glyphID = ctx->generateCharToGlyph(uni);
|
||||
if (glyphID) {
|
||||
break; // found it
|
||||
}
|
||||
ctx = ctx->getNextContext();
|
||||
|
||||
uint16_t tempID;
|
||||
SkScalerContext* ctx = this->getContextFromChar(uni, &tempID);
|
||||
if (NULL == ctx) {
|
||||
return 0; // no more contexts, return missing glyph
|
||||
}
|
||||
}
|
||||
// add the ctx's base, making glyphID unique for chain of contexts
|
||||
glyphID += ctx->fBaseGlyphCount;
|
||||
unsigned glyphID = tempID + ctx->fBaseGlyphCount;
|
||||
// check for overflow of 16bits, since our glyphID cannot exceed that
|
||||
if (glyphID > 0xFFFF) {
|
||||
glyphID = 0;
|
||||
|
@ -190,16 +190,7 @@ public:
|
||||
|
||||
// This function must be public for SkTypeface_android.h, but should not be
|
||||
// called by other callers
|
||||
SkFontID findTypefaceIdForChar(SkUnichar uni) {
|
||||
SkScalerContext* ctx = this;
|
||||
while (NULL != ctx) {
|
||||
if (ctx->generateCharToGlyph(uni)) {
|
||||
return ctx->fRec.fFontID;
|
||||
}
|
||||
ctx = ctx->getNextContext();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
SkFontID findTypefaceIdForChar(SkUnichar uni);
|
||||
#endif
|
||||
|
||||
static inline void MakeRec(const SkPaint&, const SkDeviceProperties* deviceProperties,
|
||||
@ -245,6 +236,11 @@ private:
|
||||
// is found, just returns the original context (this)
|
||||
SkScalerContext* getGlyphContext(const SkGlyph& glyph);
|
||||
|
||||
// returns the right context from our link-list for this char. If no match
|
||||
// is found it returns NULL. If a match is found then the glyphID param is
|
||||
// set to the glyphID that maps to the provided char.
|
||||
SkScalerContext* getContextFromChar(SkUnichar uni, uint16_t* glyphID);
|
||||
|
||||
// link-list of context, to handle missing chars. null-terminated.
|
||||
SkScalerContext* fNextContext;
|
||||
|
||||
|
@ -10,8 +10,6 @@
|
||||
#include "SkColorPriv.h"
|
||||
#include "SkFlattenableBuffers.h"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
#if SK_SUPPORT_GPU
|
||||
#include "effects/GrSingleTextureEffect.h"
|
||||
|
@ -694,6 +694,13 @@ void SkFontHost::FilterRec(SkScalerContext::Rec* rec, SkTypeface*) {
|
||||
#ifdef SK_BUILD_FOR_ANDROID
|
||||
uint32_t SkFontHost::GetUnitsPerEm(SkFontID fontID) {
|
||||
SkAutoMutexAcquire ac(gFTMutex);
|
||||
FT_Library libInit = NULL;
|
||||
if (gFTCount == 0) {
|
||||
if (!InitFreetype())
|
||||
sk_throw();
|
||||
libInit = gFTLibrary;
|
||||
}
|
||||
SkAutoTCallIProc<struct FT_LibraryRec_, FT_Done_FreeType> ftLib(libInit);
|
||||
SkFaceRec *rec = ref_ft_face(fontID);
|
||||
uint16_t unitsPerEm = 0;
|
||||
|
||||
|
@ -38,7 +38,7 @@ static bool are_equal(skiatest::Reporter* reporter,
|
||||
bool equal = a == b;
|
||||
bool cheapEqual = a.cheapEqualTo(b);
|
||||
if (equal != cheapEqual) {
|
||||
#if SK_SCALAR_IS_FLOAT
|
||||
#ifdef SK_SCALAR_IS_FLOAT
|
||||
if (equal) {
|
||||
bool foundZeroSignDiff = false;
|
||||
for (int i = 0; i < 9; ++i) {
|
||||
@ -287,7 +287,7 @@ static void test_matrix_is_similarity(skiatest::Reporter* reporter) {
|
||||
mat.setPerspY(SkScalarToPersp(SK_Scalar1 / 2));
|
||||
REPORTER_ASSERT(reporter, !mat.isSimilarity());
|
||||
|
||||
#if SK_SCALAR_IS_FLOAT
|
||||
#ifdef SK_SCALAR_IS_FLOAT
|
||||
/* We bypass the following tests for SK_SCALAR_IS_FIXED build.
|
||||
* The long discussion can be found in this issue:
|
||||
* http://codereview.appspot.com/5999050/
|
||||
|
Loading…
Reference in New Issue
Block a user