本文整理汇总了C++中GrCachedLayer::stop方法的典型用法代码示例。如果您正苦于以下问题:C++ GrCachedLayer::stop方法的具体用法?C++ GrCachedLayer::stop怎么用?C++ GrCachedLayer::stop使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GrCachedLayer
的用法示例。
在下文中一共展示了GrCachedLayer::stop方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: create_layers
// Add several layers to the cache
static void create_layers(skiatest::Reporter* reporter,
GrLayerCache* cache,
const SkPicture& picture,
int numToAdd,
int idOffset) {
for (int i = 0; i < numToAdd; ++i) {
GrCachedLayer* layer = cache->findLayerOrCreate(&picture,
idOffset+i+1, idOffset+i+2,
SkMatrix::I());
REPORTER_ASSERT(reporter, NULL != layer);
GrCachedLayer* temp = cache->findLayer(&picture, idOffset+i+1, idOffset+i+2, SkMatrix::I());
REPORTER_ASSERT(reporter, temp == layer);
REPORTER_ASSERT(reporter, TestingAccess::NumLayers(cache) == idOffset + i + 1);
REPORTER_ASSERT(reporter, picture.uniqueID() == layer->pictureID());
REPORTER_ASSERT(reporter, layer->start() == idOffset + i + 1);
REPORTER_ASSERT(reporter, layer->stop() == idOffset + i + 2);
REPORTER_ASSERT(reporter, layer->ctm() == SkMatrix::I());
REPORTER_ASSERT(reporter, NULL == layer->texture());
REPORTER_ASSERT(reporter, !layer->isAtlased());
}
cache->trackPicture(&picture);
}
示例2: create_layers
// Add several layers to the cache
static void create_layers(skiatest::Reporter* reporter,
GrLayerCache* cache,
const SkPicture& picture,
unsigned numToAdd,
unsigned idOffset) {
for (unsigned i = 0; i < numToAdd; ++i) {
unsigned indices[1] = { idOffset+i+1 };
GrCachedLayer* layer = cache->findLayerOrCreate(picture.uniqueID(),
idOffset+i+1, idOffset+i+2,
SkIRect::MakeEmpty(),
SkIRect::MakeEmpty(),
SkMatrix::I(),
indices, 1,
NULL);
REPORTER_ASSERT(reporter, layer);
GrCachedLayer* temp = TestingAccess::Find(cache, picture.uniqueID(), SkMatrix::I(),
indices, 1);
REPORTER_ASSERT(reporter, temp == layer);
REPORTER_ASSERT(reporter, TestingAccess::NumLayers(cache) == idOffset + i + 1);
REPORTER_ASSERT(reporter, picture.uniqueID() == layer->pictureID());
REPORTER_ASSERT(reporter, layer->start() == idOffset + i + 1);
REPORTER_ASSERT(reporter, layer->stop() == idOffset + i + 2);
REPORTER_ASSERT(reporter, NULL == layer->texture());
REPORTER_ASSERT(reporter, NULL == layer->paint());
REPORTER_ASSERT(reporter, !layer->isAtlased());
}
}
示例3: convert_layers_to_replacements
static void convert_layers_to_replacements(const SkTDArray<GrHoistedLayer>& layers,
GrReplacements* replacements) {
// TODO: just replace GrReplacements::ReplacementInfo with GrCachedLayer?
for (int i = 0; i < layers.count(); ++i) {
GrCachedLayer* layer = layers[i].fLayer;
const SkPicture* picture = layers[i].fPicture;
GrReplacements::ReplacementInfo* layerInfo =
replacements->newReplacement(picture->uniqueID(),
layer->start(),
layers[i].fCTM);
layerInfo->fStop = layer->stop();
layerInfo->fPos = layers[i].fOffset;
SkBitmap bm;
wrap_texture(layers[i].fLayer->texture(),
!layers[i].fLayer->isAtlased() ? layers[i].fLayer->rect().width()
: layers[i].fLayer->texture()->width(),
!layers[i].fLayer->isAtlased() ? layers[i].fLayer->rect().height()
: layers[i].fLayer->texture()->height(),
&bm);
layerInfo->fImage = SkImage::NewTexture(bm);
layerInfo->fPaint = layers[i].fLayer->paint()
? SkNEW_ARGS(SkPaint, (*layers[i].fLayer->paint()))
: NULL;
layerInfo->fSrcRect = SkIRect::MakeXYWH(layers[i].fLayer->rect().fLeft,
layers[i].fLayer->rect().fTop,
layers[i].fLayer->rect().width(),
layers[i].fLayer->rect().height());
}
}
示例4: operator
void operator()(const SkRecords::SaveLayer& sl) {
// For a saveLayer command, check if it can be replaced by a drawBitmap
// call and, if so, draw it and then update the current op index accordingly.
int startOffset;
if (fOps.count()) {
startOffset = fOps[fIndex];
} else {
startOffset = fIndex;
}
fOpIndexStack.push(startOffset);
GrCachedLayer* layer = fLayerCache->findLayer(fTopLevelPicture->uniqueID(),
fInitialMatrix,
fOpIndexStack.begin(),
fOpIndexStack.count());
if (layer) {
fNumReplaced++;
draw_replacement_bitmap(layer, fCanvas);
if (fPicture->bbh()) {
while (fOps[fIndex] < layer->stop()) {
++fIndex;
}
SkASSERT(fOps[fIndex] == layer->stop());
} else {
fIndex = layer->stop();
}
fOpIndexStack.pop();
return;
}
// This is a fail for layer hoisting
this->INHERITED::operator()(sl);
fOpIndexStack.pop();
}
示例5: DrawLayers
void GrLayerHoister::DrawLayers(const SkTDArray<GrHoistedLayer>& atlased,
const SkTDArray<GrHoistedLayer>& nonAtlased,
const SkTDArray<GrHoistedLayer>& recycled,
GrReplacements* replacements) {
// Render the atlased layers that require it
if (atlased.count() > 0) {
// All the atlased layers are rendered into the same GrTexture
SkAutoTUnref<SkSurface> surface(SkSurface::NewRenderTargetDirect(
atlased[0].fLayer->texture()->asRenderTarget(), NULL));
SkCanvas* atlasCanvas = surface->getCanvas();
SkPaint paint;
paint.setColor(SK_ColorTRANSPARENT);
paint.setXfermode(SkXfermode::Create(SkXfermode::kSrc_Mode))->unref();
for (int i = 0; i < atlased.count(); ++i) {
GrCachedLayer* layer = atlased[i].fLayer;
const SkPicture* pict = atlased[i].fPicture;
const SkIPoint offset = atlased[i].fOffset;
atlasCanvas->save();
// Add a rect clip to make sure the rendering doesn't
// extend beyond the boundaries of the atlased sub-rect
SkRect bound = SkRect::MakeXYWH(SkIntToScalar(layer->rect().fLeft),
SkIntToScalar(layer->rect().fTop),
SkIntToScalar(layer->rect().width()),
SkIntToScalar(layer->rect().height()));
atlasCanvas->clipRect(bound);
// Since 'clear' doesn't respect the clip we need to draw a rect
// TODO: ensure none of the atlased layers contain a clear call!
atlasCanvas->drawRect(bound, paint);
// info.fCTM 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.postTranslate(bound.fLeft, bound.fTop);
atlasCanvas->translate(SkIntToScalar(-offset.fX),
SkIntToScalar(-offset.fY));
atlasCanvas->translate(bound.fLeft, bound.fTop);
atlasCanvas->concat(atlased[i].fCTM);
SkRecordPartialDraw(*pict->fRecord.get(), atlasCanvas, bound,
layer->start()+1, layer->stop(), initialCTM);
atlasCanvas->restore();
}
atlasCanvas->flush();
}
// Render the non-atlased layers that require it
for (int i = 0; i < nonAtlased.count(); ++i) {
GrCachedLayer* layer = nonAtlased[i].fLayer;
const SkPicture* pict = nonAtlased[i].fPicture;
const SkIPoint offset = nonAtlased[i].fOffset;
// Each non-atlased layer has its own GrTexture
SkAutoTUnref<SkSurface> surface(SkSurface::NewRenderTargetDirect(
layer->texture()->asRenderTarget(), NULL));
SkCanvas* layerCanvas = surface->getCanvas();
// Add a rect clip to make sure the rendering doesn't
// extend beyond the boundaries of the atlased sub-rect
SkRect bound = SkRect::MakeXYWH(SkIntToScalar(layer->rect().fLeft),
SkIntToScalar(layer->rect().fTop),
SkIntToScalar(layer->rect().width()),
SkIntToScalar(layer->rect().height()));
layerCanvas->clipRect(bound); // TODO: still useful?
layerCanvas->clear(SK_ColorTRANSPARENT);
SkMatrix initialCTM;
initialCTM.setTranslate(SkIntToScalar(-offset.fX),
SkIntToScalar(-offset.fY));
layerCanvas->translate(SkIntToScalar(-offset.fX),
SkIntToScalar(-offset.fY));
layerCanvas->concat(nonAtlased[i].fCTM);
SkRecordPartialDraw(*pict->fRecord.get(), layerCanvas, bound,
layer->start()+1, layer->stop(), initialCTM);
layerCanvas->flush();
}
convert_layers_to_replacements(atlased, replacements);
convert_layers_to_replacements(nonAtlased, replacements);
convert_layers_to_replacements(recycled, replacements);
}