*/
static SkDataTable* NewCopyArray(const void* array, size_t elemSize,
int count);
-
+
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkDataTable)
protected:
SkDataTable(SkFlattenableReadBuffer&);
virtual void flatten(SkFlattenableWriteBuffer&) const SK_OVERRIDE;
-
+
private:
SkDataTable(int count, SkData* dataWeTakeOverOwnership);
virtual ~SkDataTable();
if (count < 0) {
count = 0;
}
-
+
size_t headerSize = count * sizeof(ElemHead);
size_t dataSize = count * elemSize;
-
+
size_t bufferSize = headerSize + dataSize;
void* buffer = sk_malloc_throw(bufferSize);
-
+
ElemHead* headerCurr = (ElemHead*)buffer;
char* dataCurr = (char*)buffer + headerSize;
for (int i = 0; i < count; ++i) {
dataCurr += elemSize;
}
memcpy((char*)buffer + headerSize, array, dataSize);
-
+
return SkNEW_ARGS(SkDataTable, (count,
SkData::NewFromMalloc(buffer, bufferSize)));
}
return SkDataTable::NewCopyArrays(fPtrs.begin(), fSizes.begin(),
fSizes.count());
}
-
break;
case SkXfermode::kDifference_Mode:
builder->fsCodeAppendf("\t\t%s.rgb = %s.rgb + %s.rgb -"
- "2.0 * min(%s.rgb * %s.a, %s.rgb * %s.a);\n",
+ "2.0 * min(%s.rgb * %s.a, %s.rgb * %s.a);\n",
outputColor, inputColor, dstColor, inputColor, dstColor,
dstColor, inputColor);
break;
private:
XferEffect(SkXfermode::Mode mode) : fMode(mode) { this->setWillReadDst(); }
virtual bool onIsEqual(const GrEffect& other) const SK_OVERRIDE { return true; }
-
+
SkXfermode::Mode fMode;
typedef GrEffect INHERITED;
vm.mapPoints(¢er, 1);
SkScalar ellipseXRadius = SkScalarHalf(ellipse.width());
SkScalar ellipseYRadius = SkScalarHalf(ellipse.height());
- SkScalar xRadius = SkScalarAbs(vm[SkMatrix::kMScaleX]*ellipseXRadius +
+ SkScalar xRadius = SkScalarAbs(vm[SkMatrix::kMScaleX]*ellipseXRadius +
vm[SkMatrix::kMSkewY]*ellipseYRadius);
- SkScalar yRadius = SkScalarAbs(vm[SkMatrix::kMSkewX]*ellipseXRadius +
+ SkScalar yRadius = SkScalarAbs(vm[SkMatrix::kMSkewX]*ellipseXRadius +
vm[SkMatrix::kMScaleY]*ellipseYRadius);
if (SkScalarDiv(xRadius, yRadius) > 2 || SkScalarDiv(yRadius, xRadius) > 2) {
return false;
SkTArray<FontIdentity>* ids) {
return false;
}
-
int* count) {
// Older versions of fontconfig have a bug where they cannot select
// only scalable fonts so we have to manually filter the results.
-
+
FcPattern** iter = font_set->fonts;
FcPattern** stop = iter + font_set->nfont;
// find the first good match
break;
}
}
-
+
*count = iter - firstIter;
return firstIter;
}
virtual void getStyle(int index, SkFontStyle*, SkString* style) SK_OVERRIDE;
virtual SkTypeface* createTypeface(int index) SK_OVERRIDE;
virtual SkTypeface* matchStyle(const SkFontStyle& pattern) SK_OVERRIDE;
-
+
private:
struct Rec {
SkString fStyleName;
static int map_range(int value,
int old_min, int old_max, int new_min, int new_max) {
SkASSERT(old_min < old_max);
- SkASSERT(new_min < new_max);
+ SkASSERT(new_min < new_max);
return new_min + SkMulDiv(value - old_min,
new_max - new_min, old_max - old_min);
}
int width = get_int(match, FC_WIDTH);
int slant = get_int(match, FC_SLANT);
// SkDebugf("old weight %d new weight %d\n", weight, map_range(weight, 0, 80, 0, 400));
-
+
// fontconfig weight seems to be 0..200 or so, so we remap it here
weight = map_range(weight, 0, 80, 0, 400);
width = map_range(width, 0, 200, 0, 9);
SkFontMgr_fontconfig(SkFontConfigInterface* fci)
: fFCI(fci)
, fFamilyNames(NULL) {}
-
+
virtual ~SkFontMgr_fontconfig() {
SkSafeUnref(fFamilyNames);
}
SkFontConfigInterface* fci = RefFCI();
return fci ? SkNEW_ARGS(SkFontMgr_fontconfig, (fci)) : NULL;
}
-
-
for (int i = 0; i < count; ++i) {
sizes[i] = strlen(str[i]) + 1;
}
-
+
SkAutoTUnref<SkDataTable> table(SkDataTable::NewCopyArrays(
(const void*const*)str, sizes, count));
-
+
REPORTER_ASSERT(reporter, table->count() == count);
for (int i = 0; i < count; ++i) {
size_t size;
REPORTER_ASSERT(reporter, !strcmp(table->atDataT<const char>(i, &size),
str[i]));
REPORTER_ASSERT(reporter, size == sizes[i]);
-
+
const char* s = table->atStr(i);
REPORTER_ASSERT(reporter, strlen(s) == strlen(str[i]));
}
int count = SK_ARRAY_COUNT(str);
SkDataTableBuilder builder(16);
-
+
for (int i = 0; i < count; ++i) {
builder.append(str[i], strlen(str[i]) + 1);
}
SkAutoTUnref<SkDataTable> table(builder.createDataTable());
-
+
REPORTER_ASSERT(reporter, table->count() == count);
for (int i = 0; i < count; ++i) {
size_t size;
REPORTER_ASSERT(reporter, !strcmp(table->atDataT<const char>(i, &size),
str[i]));
REPORTER_ASSERT(reporter, size == strlen(str[i]) + 1);
-
+
const char* s = table->atStr(i);
REPORTER_ASSERT(reporter, strlen(s) == strlen(str[i]));
}