本文整理汇总了C++中GrRect::top方法的典型用法代码示例。如果您正苦于以下问题:C++ GrRect::top方法的具体用法?C++ GrRect::top怎么用?C++ GrRect::top使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GrRect
的用法示例。
在下文中一共展示了GrRect::top方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: drawRect
void GrInOrderDrawBuffer::drawRect(const GrRect& rect,
const GrMatrix* matrix,
StageBitfield stageEnableBitfield,
const GrRect* srcRects[],
const GrMatrix* srcMatrices[]) {
GrAssert(!(NULL == fQuadIndexBuffer && fCurrQuad));
GrAssert(!(fDraws.empty() && fCurrQuad));
GrAssert(!(0 != fMaxQuads && NULL == fQuadIndexBuffer));
// if we have a quad IB then either append to the previous run of
// rects or start a new run
if (fMaxQuads) {
bool appendToPreviousDraw = false;
GrVertexLayout layout = GetRectVertexLayout(stageEnableBitfield, srcRects);
AutoReleaseGeometry geo(this, layout, 4, 0);
AutoViewMatrixRestore avmr(this);
GrMatrix combinedMatrix = this->getViewMatrix();
this->setViewMatrix(GrMatrix::I());
if (NULL != matrix) {
combinedMatrix.preConcat(*matrix);
}
SetRectVertices(rect, &combinedMatrix, srcRects, srcMatrices, layout, geo.vertices());
// we don't want to miss an opportunity to batch rects together
// simply because the clip has changed if the clip doesn't affect
// the rect.
bool disabledClip = false;
if (this->isClipState() && fClip.isRect()) {
GrRect clipRect = fClip.getRect(0);
// If the clip rect touches the edge of the viewport, extended it
// out (close) to infinity to avoid bogus intersections.
// We might consider a more exact clip to viewport if this
// conservative test fails.
const GrRenderTarget* target = this->getRenderTarget();
if (0 >= clipRect.fLeft) {
clipRect.fLeft = GR_ScalarMin;
}
if (target->width() <= clipRect.fRight) {
clipRect.fRight = GR_ScalarMax;
}
if (0 >= clipRect.top()) {
clipRect.fTop = GR_ScalarMin;
}
if (target->height() <= clipRect.fBottom) {
clipRect.fBottom = GR_ScalarMax;
}
int stride = VertexSize(layout);
bool insideClip = true;
for (int v = 0; v < 4; ++v) {
const GrPoint& p = *GetVertexPoint(geo.vertices(), v, stride);
if (!clipRect.contains(p)) {
insideClip = false;
break;
}
}
if (insideClip) {
this->disableState(kClip_StateBit);
disabledClip = true;
}
}
if (!needsNewClip() && !needsNewState() && fCurrQuad > 0 &&
fCurrQuad < fMaxQuads && layout == fLastRectVertexLayout) {
int vsize = VertexSize(layout);
Draw& lastDraw = fDraws.back();
GrAssert(lastDraw.fIndexBuffer == fQuadIndexBuffer);
GrAssert(kTriangles_PrimitiveType == lastDraw.fPrimitiveType);
GrAssert(0 == lastDraw.fVertexCount % 4);
GrAssert(0 == lastDraw.fIndexCount % 6);
GrAssert(0 == lastDraw.fStartIndex);
GeometryPoolState& poolState = fGeoPoolStateStack.back();
bool clearSinceLastDraw =
fClears.count() &&
fClears.back().fBeforeDrawIdx == fDraws.count();
appendToPreviousDraw =
!clearSinceLastDraw &&
lastDraw.fVertexBuffer == poolState.fPoolVertexBuffer &&
(fCurrQuad * 4 + lastDraw.fStartVertex) == poolState.fPoolStartVertex;
if (appendToPreviousDraw) {
lastDraw.fVertexCount += 4;
lastDraw.fIndexCount += 6;
fCurrQuad += 1;
// we reserved above, so we should be the first
// use of this vertex reserveation.
GrAssert(0 == poolState.fUsedPoolVertexBytes);
poolState.fUsedPoolVertexBytes = 4 * vsize;
}
}
if (!appendToPreviousDraw) {
this->setIndexSourceToBuffer(fQuadIndexBuffer);
drawIndexed(kTriangles_PrimitiveType, 0, 0, 4, 6);
//.........这里部分代码省略.........
示例2: drawRect
//.........这里部分代码省略.........
GrDrawState::AutoColorRestore acr(this->drawState(),
batchAcrossColors ? SK_ColorWHITE
: this->getDrawState().getColor());
// we don't want to miss an opportunity to batch rects together
// simply because the clip has changed if the clip doesn't affect
// the rect.
bool disabledClip = false;
if (drawState->isClipState()) {
GrRect devClipRect;
bool isIntersectionOfRects = false;
const GrClipData* clip = this->getClip();
clip->fClipStack->getConservativeBounds(-clip->fOrigin.fX,
-clip->fOrigin.fY,
drawState->getRenderTarget()->width(),
drawState->getRenderTarget()->height(),
&devClipRect,
&isIntersectionOfRects);
if (isIntersectionOfRects) {
// If the clip rect touches the edge of the viewport, extended it
// out (close) to infinity to avoid bogus intersections.
// We might consider a more exact clip to viewport if this
// conservative test fails.
const GrRenderTarget* target = drawState->getRenderTarget();
if (0 >= devClipRect.fLeft) {
devClipRect.fLeft = SK_ScalarMin;
}
if (target->width() <= devClipRect.fRight) {
devClipRect.fRight = SK_ScalarMax;
}
if (0 >= devClipRect.top()) {
devClipRect.fTop = SK_ScalarMin;
}
if (target->height() <= devClipRect.fBottom) {
devClipRect.fBottom = SK_ScalarMax;
}
int stride = GrDrawState::VertexSize(layout);
bool insideClip = true;
for (int v = 0; v < 4; ++v) {
const GrPoint& p = *GrDrawState::GetVertexPoint(geo.vertices(), v, stride);
if (!devClipRect.contains(p)) {
insideClip = false;
break;
}
}
if (insideClip) {
drawState->disableState(GrDrawState::kClip_StateBit);
disabledClip = true;
}
}
}
if (!this->needsNewClip() &&
!this->needsNewState() &&
fCurrQuad > 0 &&
fCurrQuad < fMaxQuads &&
layout == fLastRectVertexLayout) {
int vsize = GrDrawState::VertexSize(layout);
Draw& lastDraw = fDraws.back();
GrAssert(lastDraw.fIndexBuffer == fQuadIndexBuffer);