本文整理汇总了C++中SkTDArray类的典型用法代码示例。如果您正苦于以下问题:C++ SkTDArray类的具体用法?C++ SkTDArray怎么用?C++ SkTDArray使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了SkTDArray类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: find
int SkPictureRecord::find(SkTDArray<const SkFlatBitmap* >& bitmaps, const SkBitmap& bitmap) {
SkFlatBitmap* flat = SkFlatBitmap::Flatten(&fHeap, bitmap, fBitmapIndex,
&fRCSet);
int index = SkTSearch<SkFlatData>((const SkFlatData**) bitmaps.begin(),
bitmaps.count(), (SkFlatData*) flat, sizeof(flat), &SkFlatData::Compare);
if (index >= 0) {
(void)fHeap.unalloc(flat);
return bitmaps[index]->index();
}
index = ~index;
*bitmaps.insert(index) = flat;
return fBitmapIndex++;
}
示例2: getFamilies
void
SkFontData::loadXml( SkTDArray<FontInitRec> &info )
{
SkTDArray<FontFamily*> families;
getFamilies( families );
info.reset();
for( int i = 0 ; i < families.count() ; ++i )
{
FontFamily * family = families[i];
for( int j = 0 ; j < family->fFontFileArray.count() ; ++j )
{
const char * filename = family->fFontFileArray[j]->fFileName;
#ifndef DEPRECATED_CODE
HyLogif( "DEPRECATED_CODE" );
if( haveSystemFont( filename ) )
continue;
#endif
FontInitRec fontInfoRecord;
fontInfoRecord.fFileName = filename;
if( j == 0 )
{
if( family->fNames.count() == 0 )
fontInfoRecord.fNames = ( char ** )gFBNames; // fallback.
else
{
SkTDArray<const char*> names = family->fNames;
const char ** nameList = ( const char ** )calloc( ( names.count() + 1 ), sizeof( char * ) );
if( nameList == NULL )
{
break;
}
for( int n = 0 ; n < names.count() ; ++n )
{
nameList[n] = names[n];
}
nameList[names.count()] = NULL;
fontInfoRecord.fNames = nameList;
}
}
else
{
fontInfoRecord.fNames = NULL;
}
*info.append() = fontInfoRecord;
}
}
families.deleteAll();
}
示例3: SkPin32
void SkTileGrid::search(const SkIRect& query, SkTDArray<void*>* results) {
SkIRect adjustedQuery = query;
// The inset is to counteract the outset that was applied in 'insert'
// The outset/inset is to optimize for lookups of size
// 'tileInterval + 2 * margin' that are aligned with the tile grid.
adjustedQuery.inset(fInfo.fMargin.width(), fInfo.fMargin.height());
adjustedQuery.offset(fInfo.fOffset);
adjustedQuery.sort(); // in case the inset inverted the rectangle
// Convert the query rectangle from device coordinates to tile coordinates
// by rounding outwards to the nearest tile boundary so that the resulting tile
// region includes the query rectangle. (using truncating division to "floor")
int tileStartX = adjustedQuery.left() / fInfo.fTileInterval.width();
int tileEndX = (adjustedQuery.right() + fInfo.fTileInterval.width() - 1) /
fInfo.fTileInterval.width();
int tileStartY = adjustedQuery.top() / fInfo.fTileInterval.height();
int tileEndY = (adjustedQuery.bottom() + fInfo.fTileInterval.height() - 1) /
fInfo.fTileInterval.height();
tileStartX = SkPin32(tileStartX, 0, fXTileCount - 1);
tileEndX = SkPin32(tileEndX, tileStartX+1, fXTileCount);
tileStartY = SkPin32(tileStartY, 0, fYTileCount - 1);
tileEndY = SkPin32(tileEndY, tileStartY+1, fYTileCount);
int queryTileCount = (tileEndX - tileStartX) * (tileEndY - tileStartY);
SkASSERT(queryTileCount);
if (queryTileCount == 1) {
*results = this->tile(tileStartX, tileStartY);
} else {
results->reset();
SkTDArray<int> curPositions;
curPositions.setCount(queryTileCount);
// Note: Reserving space for 1024 tile pointers on the stack. If the
// malloc becomes a bottleneck, we may consider increasing that number.
// Typical large web page, say 2k x 16k, would require 512 tiles of
// size 256 x 256 pixels.
SkAutoSTArray<1024, SkTDArray<void *>*> storage(queryTileCount);
SkTDArray<void *>** tileRange = storage.get();
int tile = 0;
for (int x = tileStartX; x < tileEndX; ++x) {
for (int y = tileStartY; y < tileEndY; ++y) {
tileRange[tile] = &this->tile(x, y);
curPositions[tile] = tileRange[tile]->count() ? 0 : kTileFinished;
++tile;
}
}
void *nextElement;
while(NULL != (nextElement = fNextDatumFunction(tileRange, curPositions))) {
results->push(nextElement);
}
}
}
示例4: test
static void test(skiatest::Reporter* reporter, const SkDCubic* cubics, const char* name,
int firstTest, size_t testCount) {
for (size_t index = firstTest; index < testCount; ++index) {
const SkDCubic& cubic = cubics[index];
double precision = cubic.calcPrecision();
SkTDArray<SkDQuad> quads;
CubicToQuads(cubic, precision, quads);
if (quads.count() != 1) {
SkDebugf("%s [%d] cubic to quadratics failed count=%d\n", name, static_cast<int>(index),
quads.count());
}
REPORTER_ASSERT(reporter, quads.count() == 1);
}
}
示例5: find
int SkPictureRecord::find(SkTDArray<const SkFlatMatrix* >& matrices, const SkMatrix* matrix) {
if (matrix == NULL)
return 0;
SkFlatMatrix* flat = SkFlatMatrix::Flatten(&fHeap, *matrix, fMatrixIndex);
int index = SkTSearch<SkFlatData>((const SkFlatData**) matrices.begin(),
matrices.count(), (SkFlatData*) flat, sizeof(flat), &SkFlatData::Compare);
if (index >= 0) {
(void)fHeap.unalloc(flat);
return matrices[index]->index();
}
index = ~index;
*matrices.insert(index) = flat;
return fMatrixIndex++;
}
示例6: SkDebugf
// register a configuration variable after its value has been set by the parser.
// we maintain a vector of these things instead of just a single one because the
// user might set the value after initialization time and we need to have
// all the pointers lying around, not just one.
void SkRTConfRegistry::registerConf(SkRTConfBase *conf) {
SkTDArray<SkRTConfBase *> *confArray;
if (fConfs.find(conf->getName(), &confArray)) {
if (!conf->equals(confArray->getAt(0))) {
SkDebugf("WARNING: Skia config \"%s\" was registered more than once in incompatible ways.\n", conf->getName());
} else {
confArray->append(1, &conf);
}
} else {
confArray = new SkTDArray<SkRTConfBase *>;
confArray->append(1, &conf);
fConfs.set(conf->getName(),confArray);
}
}
示例7: Simplify
// FIXME : add this as a member of SkPath
void Simplify(const SkPath& path, SkPath* result) {
#if DEBUG_SORT || DEBUG_SWAP_TOP
gDebugSortCount = gDebugSortCountDefault;
#endif
// returns 1 for evenodd, -1 for winding, regardless of inverse-ness
result->reset();
result->setFillType(SkPath::kEvenOdd_FillType);
SkPathWriter simple(*result);
// turn path into list of segments
SkTArray<SkOpContour> contours;
SkOpEdgeBuilder builder(path, contours);
builder.finish();
SkTDArray<SkOpContour*> contourList;
MakeContourList(contours, contourList, false, false);
SkOpContour** currentPtr = contourList.begin();
if (!currentPtr) {
return;
}
SkOpContour** listEnd = contourList.end();
// find all intersections between segments
do {
SkOpContour** nextPtr = currentPtr;
SkOpContour* current = *currentPtr++;
if (current->containsCubics()) {
AddSelfIntersectTs(current);
}
SkOpContour* next;
do {
next = *nextPtr++;
} while (AddIntersectTs(current, next) && nextPtr != listEnd);
} while (currentPtr != listEnd);
// eat through coincident edges
CoincidenceCheck(&contourList, 0);
FixOtherTIndex(&contourList);
SortSegments(&contourList);
#if DEBUG_ACTIVE_SPANS
DebugShowActiveSpans(contourList);
#endif
// construct closed contours
if (builder.xorMask() == kWinding_PathOpsMask ? bridgeWinding(contourList, &simple)
: !bridgeXor(contourList, &simple))
{ // if some edges could not be resolved, assemble remaining fragments
SkPath temp;
temp.setFillType(SkPath::kEvenOdd_FillType);
SkPathWriter assembled(temp);
Assemble(simple, &assembled);
*result = *assembled.nativePath();
}
}
示例8: IsFinite
bool SkAnimatorScript::IsFinite(const char* function, size_t len, SkTDArray<SkScriptValue>& params,
void* eng, SkScriptValue* value) {
if (SK_LITERAL_STR_EQUAL(function, "isFinite", len) == false)
return false;
if (params.count() != 1)
return false;
SkScriptValue* scriptValue = params.begin();
SkDisplayTypes type = scriptValue->fType;
SkScalar scalar = scriptValue->fOperand.fScalar;
value->fType = SkType_Int;
value->fOperand.fS32 = type == SkType_Float ? SkScalarIsNaN(scalar) == false &&
SkScalarAbs(scalar) != SK_ScalarInfinity : type == SkType_Int;
return true;
}
示例9: add_subdict
static void add_subdict(
const SkTDArray<SkPDFObject*>& resourceList,
SkPDFResourceDict::SkPDFResourceType type,
SkPDFDict* dst) {
if (0 == resourceList.count()) {
return;
}
SkAutoTUnref<SkPDFDict> resources(new SkPDFDict);
for (int i = 0; i < resourceList.count(); i++) {
resources->insertObjRef(SkPDFResourceDict::getResourceName(type, i),
SkRef(resourceList[i]));
}
dst->insertObject(get_resource_type_name(type), resources.detach());
}
示例10: SkConcaveToTriangles
bool SkConcaveToTriangles(size_t numPts,
const SkPoint pts[],
SkTDArray<SkPoint> *triangles) {
DebugPrintf("SkConcaveToTriangles()\n");
SkTDArray<Vertex> vertices;
vertices.setCount(numPts);
if (!ConvertPointsToVertices(numPts, pts, vertices.begin()))
return false;
triangles->setReserve(numPts);
triangles->setCount(0);
return Triangulate(vertices.begin(), vertices.end() - 1, triangles);
}
示例11: add_subdict
static void add_subdict(
const SkTDArray<SkPDFObject*>& resourceList,
SkPDFResourceDict::SkPDFResourceType type,
SkPDFDict* dst) {
if (0 == resourceList.count()) {
return;
}
auto resources = sk_make_sp<SkPDFDict>();
for (int i = 0; i < resourceList.count(); i++) {
resources->insertObjRef(SkPDFResourceDict::getResourceName(type, i),
sk_ref_sp(resourceList[i]));
}
dst->insertObject(get_resource_type_name(type), std::move(resources));
}
示例12: parseConfigFile
void SkFontConfigParser::GetTestFontFamilies(SkTDArray<FontFamily*> &fontFamilies,
const char* testMainConfigFile,
const char* testFallbackConfigFile) {
parseConfigFile(testMainConfigFile, fontFamilies);
SkTDArray<FontFamily*> fallbackFonts;
parseConfigFile(testFallbackConfigFile, fallbackFonts);
// Append all fallback fonts to system fonts
for (int i = 0; i < fallbackFonts.count(); ++i) {
fallbackFonts[i]->fIsFallbackFont = true;
*fontFamilies.append() = fallbackFonts[i];
}
}
示例13: storage
void SkTileGrid::search(const SkIRect& query, SkTDArray<void*>* results) {
SkIRect adjustedQuery = query;
adjustedQuery.inset(fInfo.fMargin.width(), fInfo.fMargin.height());
adjustedQuery.offset(fInfo.fOffset);
// Convert the query rectangle from device coordinates to tile coordinates
// by rounding outwards to the nearest tile boundary so that the resulting tile
// region includes the query rectangle. (using truncating division to "floor")
int tileStartX = adjustedQuery.left() / fInfo.fTileInterval.width();
int tileEndX = (adjustedQuery.right() + fInfo.fTileInterval.width() - 1) /
fInfo.fTileInterval.width();
int tileStartY = adjustedQuery.top() / fInfo.fTileInterval.height();
int tileEndY = (adjustedQuery.bottom() + fInfo.fTileInterval.height() - 1) /
fInfo.fTileInterval.height();
if (tileStartX >= fXTileCount || tileStartY >= fYTileCount || tileEndX <= 0 || tileEndY <= 0) {
return; // query does not intersect the grid
}
// clamp to grid
if (tileStartX < 0) tileStartX = 0;
if (tileStartY < 0) tileStartY = 0;
if (tileEndX > fXTileCount) tileEndX = fXTileCount;
if (tileEndY > fYTileCount) tileEndY = fYTileCount;
int queryTileCount = (tileEndX - tileStartX) * (tileEndY - tileStartY);
if (queryTileCount == 1) {
*results = this->tile(tileStartX, tileStartY);
} else {
results->reset();
SkTDArray<int> curPositions;
curPositions.setCount(queryTileCount);
// Note: Reserving space for 1024 tile pointers on the stack. If the
// malloc becomes a bottleneck, we may consider increasing that number.
// Typical large web page, say 2k x 16k, would require 512 tiles of
// size 256 x 256 pixels.
SkAutoSTArray<1024, SkTDArray<void *>*> storage(queryTileCount);
SkTDArray<void *>** tileRange = storage.get();
int tile = 0;
for (int x = tileStartX; x < tileEndX; ++x) {
for (int y = tileStartY; y < tileEndY; ++y) {
tileRange[tile] = &this->tile(x, y);
curPositions[tile] = tileRange[tile]->count() ? 0 : kTileFinished;
++tile;
}
}
void *nextElement;
while(NULL != (nextElement = fNextDatumFunction(tileRange, curPositions))) {
results->push(nextElement);
}
}
}
示例14: DrawLayersToAtlas
void GrLayerHoister::DrawLayersToAtlas(GrContext* context,
const SkTDArray<GrHoistedLayer>& atlased) {
if (atlased.count() > 0) {
// All the atlased layers are rendered into the same GrTexture
SkSurfaceProps props(0, kUnknown_SkPixelGeometry);
SkAutoTUnref<SkSurface> surface(SkSurface::NewRenderTargetDirect(
atlased[0].fLayer->texture()->asRenderTarget(), &props));
SkCanvas* atlasCanvas = surface->getCanvas();
for (int i = 0; i < atlased.count(); ++i) {
const GrCachedLayer* layer = atlased[i].fLayer;
const SkBigPicture* pict = atlased[i].fPicture->asSkBigPicture();
if (!pict) {
// TODO: can we assume / assert this?
continue;
}
const SkIPoint offset = SkIPoint::Make(layer->srcIR().fLeft, layer->srcIR().fTop);
SkDEBUGCODE(const SkPaint* layerPaint = layer->paint();)
SkASSERT(!layerPaint || !layerPaint->getImageFilter());
SkASSERT(!layer->filter());
atlasCanvas->save();
// Add a rect clip to make sure the rendering doesn't
// extend beyond the boundaries of the atlased sub-rect
const SkRect bound = SkRect::Make(layer->rect());
atlasCanvas->clipRect(bound);
atlasCanvas->clear(0);
// '-offset' maps the layer's top/left to the origin.
// Since this layer is atlased, the top/left corner needs
// to be offset to the correct location in the backing texture.
SkMatrix initialCTM;
initialCTM.setTranslate(SkIntToScalar(-offset.fX), SkIntToScalar(-offset.fY));
initialCTM.preTranslate(bound.fLeft, bound.fTop);
initialCTM.preConcat(atlased[i].fPreMat);
atlasCanvas->setMatrix(initialCTM);
atlasCanvas->concat(atlased[i].fLocalMat);
pict->partialPlayback(atlasCanvas, layer->start() + 1, layer->stop(), initialCTM);
atlasCanvas->restore();
}
atlasCanvas->flush();
}
示例15: loadXml
void
SkFontData::loadFont()
{
SkTDArray<FontInitRec> info;
SkTypeface * firstInFamily = NULL;
loadXml( info );
for( int i = 0 ; i < info.count() ; i++ )
{
const char * const * names = info[i].fNames;
if( names != NULL )
firstInFamily = NULL;
bool isFixedWidth;
SkString name;
SkTypeface::Style style;
bool isExpected = ( names != gFBNames );
SkString fullpath;
getFullPathDownloadFont( &fullpath, info[i].fFileName );
if( !getNameAndStyleDlFont( fullpath.c_str(), &name, &style, &isFixedWidth, isExpected ) )
continue;
SkTypeface * tf = SkNEW_ARGS( FileTypeface, ( style, true, fullpath.c_str(), isFixedWidth ) );
addTypefaceLocked( tf, firstInFamily );
if( names != NULL )
{
firstInFamily = tf;
FamilyRec * family = findFamilyLocked( tf );
if( isDefaultSansFont( names ) )
{
FileTypeface * ftf = ( FileTypeface * )tf;
setFamilyAndTypeface( family, ftf );
setWebFaceName( names[0] );
}
while( *names )
{
addNameLocked( *names, family );
names += 1;
}
}
}
}