void SkCanvasStack::pushCanvas(std::unique_ptr<SkCanvas> canvas, const SkIPoint& origin) { if (canvas) { // compute the bounds of this canvas const SkIRect canvasBounds = SkIRect::MakeSize(canvas->getBaseLayerSize());
// push the canvas onto the stack
this->INHERITED::addCanvas(canvas.get());
// push the canvas data onto the stack
CanvasData* data = &fCanvasData.push_back();
data->origin = origin;
data->requiredClip.setRect(canvasBounds);
data->ownedCanvas = std::move(canvas);
// subtract this region from the canvas objects already on the stack. // This ensures they do not draw into the space occupied by the layers // above them. for (int i = fList.size() - 1; i > 0; --i) {
SkIRect localBounds = canvasBounds;
localBounds.offset(origin - fCanvasData[i-1].origin);
void SkCanvasStack::removeAll() {
this->INHERITED::removeAll(); // call the baseclass *before* we actually delete the canvases
fCanvasData.clear();
}
/** * Traverse all canvases (e.g. layers) the stack and ensure that they are clipped * to their bounds and that the area covered by any canvas higher in the stack is * also clipped out.
*/ void SkCanvasStack::clipToZOrderedBounds() {
SkASSERT(fList.size() == fCanvasData.size()); for (int i = 0; i < fList.size(); ++i) {
fList[i]->clipRegion(fCanvasData[i].requiredClip);
}
}
/** * We need to handle setMatrix specially as it overwrites the matrix in each * canvas unlike all other matrix operations (i.e. translate, scale, etc) which * just pre-concatenate with the existing matrix.
*/ void SkCanvasStack::didSetM44(const SkM44& mx) {
SkASSERT(fList.size() == fCanvasData.size()); for (int i = 0; i < fList.size(); ++i) {
fList[i]->setMatrix(SkM44::Translate(SkIntToScalar(-fCanvasData[i].origin.x()),
SkIntToScalar(-fCanvasData[i].origin.y())) * mx);
}
this->SkCanvas::didSetM44(mx);
}
void SkCanvasStack::onClipShader(sk_sp<SkShader> cs, SkClipOp op) {
this->INHERITED::onClipShader(std::move(cs), op); // we don't change the "bounds" of the clip, so we don't need to update zorder
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.