本文整理汇总了C++中clip函数的典型用法代码示例。如果您正苦于以下问题:C++ clip函数的具体用法?C++ clip怎么用?C++ clip使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了clip函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: justify
static void justify(char *fromnum, char *tonum, TELNUM number)
{
register char *p1, *p2;
auto char s[BUFSIZ], sx[BUFSIZ], sy[BUFSIZ];
/* AK:16-Dec-99 */
/* Hier ist noch ein Bug in normalizeNumber(), Leo! */
/* Bei Sonderrufnummern landet die komplette Nummer in number.area, */
/* wobei die letzten 2 Digits abgeschnitten sind (fehlen) */
if (!*number.msn) {
strcpy(number.msn, c.dialout ? tonum : fromnum);
*number.area = 0;
} /* if */
p1 = numtonam(c.dialout ? CALLED : CALLING, 1);
if (*number.msn)
sprintf(sx, "%s%s%s", number.area, (*number.area ? "/" : ""), number.msn);
else
strcpy(sx, number.area);
if (*number.country && strcmp(number.country, mycountry))
sprintf(s, "%s %s", number.country, sx);
else
sprintf(s, "%s%s", (*number.country ? "0" : ""), sx);
p2 = msnsum[SUBTOTAL][c.si1][c.ihome].alias;
printf("%12s %s %-21s",
p2 ? p2 : fromnum,
(c.dialout ? "->" : "<-"),
p1 ? clip(p1, 20) : s);
*s = 0;
if (*tonum && getSpecial(tonum))
sprintf(s, "%s", getSpecialName(tonum));
else {
if (*number.country && strcmp(number.country, mycountry))
sprintf(s, "%s", number.scountry);
else if (*number.scountry && strcmp(number.country, mycountry))
sprintf(s, "%s", number.scountry);
if (*number.sarea) {
if (*s)
strcat(s, ", ");
strcat(s, number.sarea);
if (c.dialout) {
sprintf(sy, ",%d", c.zone);
strcat(s, sy);
} /* if */
} /* if */
if (!*s && *tonum)
sprintf(s, "???");
} /* else */
s[COUNTRYLEN] = 0; /* clipping */
sprintf(c.country, "%-*s", COUNTRYLEN, s);
} /* justify */
开发者ID:marschap,项目名称:isdn4k-utils,代码行数:65,代码来源:isdnbill.c
示例2: clip
BOOL TapeLab::paintlabel(PMPresSpace& ps)
{
ps.setColor(CLR_BLACK);
// righe orizzontali
int i;
for (i=0; i<=labelformat.flaps; i++) {
if (i>0 && i<labelformat.flaps) ps.setLineType(LINETYPE_DOT);
else ps.setLineType(LINETYPE_DEFAULT);
ps.move(&fixpoints[labelformat.size][i*2]);
ps.line(&fixpoints[labelformat.size][i*2+1]);
}
// righe verticali
ps.move(&fixpoints[labelformat.size][0]);
ps.line(&fixpoints[labelformat.size][ labelformat.flaps * 2 ]);
ps.move(&fixpoints[labelformat.size][1]);
ps.line(&fixpoints[labelformat.size][ ( labelformat.flaps * 2 ) + 1 ]);
// esegue clip dentro a rettangolo dell'etichetta!
PMRect clip(fixpoints[labelformat.size][labelformat.flaps*2],fixpoints[labelformat.size][1]);
ps.intersectClipRectangle(&clip);
// titolo
PMPoint a;
if (labelformat.title2[0] != '\0') { // ci sono 2 titoli
a.y=(fixpoints[labelformat.size][2].y+fixpoints[labelformat.size][4].y)/2;
a.x=fixpoints[labelformat.size][2].x+labelformat.form.titlelm;
a.y=a.y+ (((fixpoints[labelformat.size][2].y-fixpoints[labelformat.size][4].y)/2)-pts2dmm(labelformat.title1font.height))/2 ;
paintString(labelformat.title1,&labelformat.title1font,1000L,a,ps);
a.y=fixpoints[labelformat.size][4].y;
a.x=fixpoints[labelformat.size][2].x+labelformat.form.titlelm;
a.y=a.y+ (((fixpoints[labelformat.size][2].y-fixpoints[labelformat.size][4].y)/2)-pts2dmm(labelformat.title2font.height))/2 ;
paintString(labelformat.title2,&labelformat.title2font,1000L,a,ps);
} else { // c'e' un solo titolo
a.x=fixpoints[labelformat.size][2].x+labelformat.form.titlelm;
a.y=(fixpoints[labelformat.size][2].y+fixpoints[labelformat.size][4].y-pts2dmm(labelformat.title1font.height)) / 2 ;
paintString(labelformat.title1,&labelformat.title1font,1000L,a,ps);
}
// testo
a.y=fixpoints[labelformat.size][4].y-pts2dmm(labelformat.text1font.height)-labelformat.form.texttm;
a.x=fixpoints[labelformat.size][4].x+labelformat.form.textlm;
paintString(labelformat.text1,&labelformat.text1font,labelformat.form.textvert1,a,ps);
a.y=fixpoints[labelformat.size][4].y-pts2dmm(labelformat.text1font.height)-labelformat.form.texttm;
a.x=(fixpoints[labelformat.size][4].x+fixpoints[labelformat.size][5].x)/2+labelformat.form.textlm;
paintString(labelformat.text2,&labelformat.text2font,labelformat.form.textvert2,a,ps);
if (labelformat.size != 2 && labelformat.flaps > 2) {
a.y=fixpoints[labelformat.size][0].y-pts2dmm(labelformat.datefont.height)-15;
// data A
if (labelformat.whatinfo[0]) {
a.x=fixpoints[labelformat.size][0].x+20;
paintString(labelformat.date1,&labelformat.datefont,1000L,a,ps);
}
// data B
if (labelformat.whatinfo[1]) {
a.x=fixpoints[labelformat.size][1].x-queryStrWidth(labelformat.date2,&labelformat.datefont,ps)-20;
paintString(labelformat.date2,&labelformat.datefont,1000L,a,ps);
}
// "DATE"
if (labelformat.whatinfo[1] || labelformat.whatinfo[0]) {
a.x=(fixpoints[labelformat.size][0].x+fixpoints[labelformat.size][1].x-queryStrWidth("DATE",&labelformat.datefont,ps))/2;
paintString("DATE",&labelformat.datefont,1000L,a,ps);
a.y-=pts2dmm(labelformat.sourcefont.height); // se c'era uno dei due abbassati...
}
// source A
if (labelformat.whatinfo[4]) {
a.x=fixpoints[labelformat.size][0].x+20;
paintString(apchSources[labelformat.source1],&labelformat.sourcefont,1000L,a,ps);
}
// source B
if (labelformat.whatinfo[5]) {
a.x=fixpoints[labelformat.size][1].x-queryStrWidth(apchSources[labelformat.source2],&labelformat.sourcefont,ps)-20;
paintString(apchSources[labelformat.source2],&labelformat.sourcefont,1000L,a,ps);
}
// "SOURCE"
if (labelformat.whatinfo[4] || labelformat.whatinfo[5]) {
a.x=(fixpoints[labelformat.size][0].x+fixpoints[labelformat.size][1].x-queryStrWidth("SOURCE",&labelformat.sourcefont,ps))/2;
paintString("SOURCE",&labelformat.sourcefont,1000L,a,ps);
a.y-=pts2dmm(labelformat.nrfont.height);
}
// NR A
if (labelformat.whatinfo[2]) {
a.x=fixpoints[labelformat.size][0].x+20;
paintString(apchNR[labelformat.nr1],&labelformat.nrfont,1000L,a,ps);
}
// NR B
if (labelformat.whatinfo[3]) {
a.x=fixpoints[labelformat.size][1].x-queryStrWidth(apchNR[labelformat.nr2],&labelformat.nrfont,ps)-20;
paintString(apchNR[labelformat.nr2],&labelformat.nrfont,1000L,a,ps);
}
// "NR"
if (labelformat.whatinfo[2] || labelformat.whatinfo[3]) {
a.x=(fixpoints[labelformat.size][0].x+fixpoints[labelformat.size][1].x-queryStrWidth("NR",&labelformat.nrfont,ps))/2;
paintString("NR",&labelformat.sourcefont,1000L,a,ps);
//.........这里部分代码省略.........
开发者ID:OS2World,项目名称:APP-MISC-Tape_lab,代码行数:101,代码来源:tl_paint.cpp
示例3: MOZ_ASSERT
DrawResult
ClippedImage::DrawSingleTile(gfxContext* aContext,
const nsIntSize& aSize,
const ImageRegion& aRegion,
uint32_t aWhichFrame,
SamplingFilter aSamplingFilter,
const Maybe<SVGImageContext>& aSVGContext,
uint32_t aFlags)
{
MOZ_ASSERT(!MustCreateSurface(aContext, aSize, aRegion, aFlags),
"Shouldn't need to create a surface");
gfxRect clip(mClip.x, mClip.y, mClip.width, mClip.height);
nsIntSize size(aSize), innerSize(aSize);
bool needScale = false;
if (mSVGViewportSize && !mSVGViewportSize->IsEmpty()) {
innerSize = *mSVGViewportSize;
needScale = true;
} else if (NS_SUCCEEDED(InnerImage()->GetWidth(&innerSize.width)) &&
NS_SUCCEEDED(InnerImage()->GetHeight(&innerSize.height))) {
needScale = true;
} else {
MOZ_ASSERT_UNREACHABLE(
"If ShouldClip() led us to draw then we should never get here");
}
if (needScale) {
double scaleX = aSize.width / clip.width;
double scaleY = aSize.height / clip.height;
// Map the clip and size to the scale requested by the caller.
clip.Scale(scaleX, scaleY);
size = innerSize;
size.Scale(scaleX, scaleY);
}
// We restrict our drawing to only the clipping region, and translate so that
// the clipping region is placed at the position the caller expects.
ImageRegion region(aRegion);
region.MoveBy(clip.x, clip.y);
region = region.Intersect(clip);
gfxContextMatrixAutoSaveRestore saveMatrix(aContext);
aContext->Multiply(gfxMatrix::Translation(-clip.x, -clip.y));
auto unclipViewport = [&](const SVGImageContext& aOldContext) {
// Map the viewport to the inner image. Note that we don't take the aSize
// parameter of imgIContainer::Draw into account, just the clipping region.
// The size in pixels at which the output will ultimately be drawn is
// irrelevant here since the purpose of the SVG viewport size is to
// determine what *region* of the SVG document will be drawn.
CSSIntSize vSize(aOldContext.GetViewportSize());
vSize.width = ceil(vSize.width * double(innerSize.width) / mClip.width);
vSize.height =
ceil(vSize.height * double(innerSize.height) / mClip.height);
return SVGImageContext(vSize,
aOldContext.GetPreserveAspectRatio());
};
return InnerImage()->Draw(aContext, size, region,
aWhichFrame, aSamplingFilter,
aSVGContext.map(unclipViewport),
aFlags);
}
开发者ID:carriercomm,项目名称:gecko-dev,代码行数:65,代码来源:ClippedImage.cpp
示例4: createObjectImage
void LLNetMap::draw()
{
static LLFrameTimer map_timer;
if (mObjectImagep.isNull())
{
createObjectImage();
}
if (gSavedSettings.getS32( "MiniMapCenter") != MAP_CENTER_NONE)
{
mCurPanX = lerp(mCurPanX, mTargetPanX, LLCriticalDamp::getInterpolant(0.1f));
mCurPanY = lerp(mCurPanY, mTargetPanY, LLCriticalDamp::getInterpolant(0.1f));
}
F32 rotation = 0;
// Prepare a scissor region
{
LLGLEnable scissor(GL_SCISSOR_TEST);
{
gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE);
LLLocalClipRect clip(getLocalRect());
glMatrixMode(GL_MODELVIEW);
// Draw background rectangle
if(isBackgroundVisible())
{
gGL.color4fv(isBackgroundOpaque() ? getBackgroundColor().mV : getTransparentColor().mV);
gl_rect_2d(0, getRect().getHeight(), getRect().getWidth(), 0);
}
}
// region 0,0 is in the middle
S32 center_sw_left = getRect().getWidth() / 2 + llfloor(mCurPanX);
S32 center_sw_bottom = getRect().getHeight() / 2 + llfloor(mCurPanY);
gGL.pushMatrix();
gGL.translatef( (F32) center_sw_left, (F32) center_sw_bottom, 0.f);
BOOL rotate_map = gSavedSettings.getBOOL( "MiniMapRotate" );
if (rotate_map)
{
// rotate subsequent draws to agent rotation
rotation = atan2( LLViewerCamera::getInstance()->getAtAxis().mV[VX], LLViewerCamera::getInstance()->getAtAxis().mV[VY] );
glRotatef( rotation * RAD_TO_DEG, 0.f, 0.f, 1.f);
}
// figure out where agent is
LLColor4 this_region_color = gColors.getColor( "NetMapThisRegion" );
LLColor4 live_region_color = gColors.getColor( "NetMapLiveRegion" );
LLColor4 dead_region_color = gColors.getColor( "NetMapDeadRegion" );
for (LLWorld::region_list_t::const_iterator iter = LLWorld::getInstance()->getRegionList().begin();
iter != LLWorld::getInstance()->getRegionList().end(); ++iter)
{
LLViewerRegion* regionp = *iter;
S32 region_width = llround(regionp->getWidth());
// Find x and y position relative to camera's center.
LLVector3 origin_agent = regionp->getOriginAgent();
LLVector3 rel_region_pos = origin_agent - gAgentCamera.getCameraPositionAgent();
F32 relative_x = (rel_region_pos.mV[0] / region_width) * mScale;
F32 relative_y = (rel_region_pos.mV[1] / region_width) * mScale;
// background region rectangle
F32 bottom = relative_y;
F32 left = relative_x;
F32 top = bottom + mScale ;
F32 right = left + mScale ;
gGL.color4fv(regionp == gAgent.getRegion() ? this_region_color.mV : live_region_color.mV);
if (!regionp->isAlive())
{
gGL.color4fv(dead_region_color.mV);
}
// Draw using texture.
gGL.getTexUnit(0)->bind(regionp->getLand().getSTexture());
gGL.begin(LLRender::QUADS);
gGL.texCoord2f(0.f, 1.f);
gGL.vertex2f(left, top);
gGL.texCoord2f(0.f, 0.f);
gGL.vertex2f(left, bottom);
gGL.texCoord2f(1.f, 0.f);
gGL.vertex2f(right, bottom);
gGL.texCoord2f(1.f, 1.f);
gGL.vertex2f(right, top);
gGL.end();
// Draw water
gGL.setAlphaRejectSettings(LLRender::CF_GREATER, ABOVE_WATERLINE_ALPHA / 255.f);
{
if (regionp->getLand().getWaterTexture())
{
gGL.getTexUnit(0)->bind(regionp->getLand().getWaterTexture());
gGL.begin(LLRender::QUADS);
//.........这里部分代码省略.........
开发者ID:Barosonix,项目名称:AstraViewer,代码行数:101,代码来源:llnetmap.cpp
示例5: clip
void Shape::drawClipped(ShadowBuffer& sb, Point min, Point max, float scale) {
clip(min, max, scale);
scanLineFill(sb, clippedPoints);
//drawBorder(sb, borderColor);
}
开发者ID:natanelia,项目名称:grafika,代码行数:5,代码来源:Shape.cpp
示例6: clip
Decimal & Decimal::multiply(const Decimal & other)
{
int low1, high1, low2, high2, lowt, hight;
clip(low1, high1);
other.clip(low2, high2);
lowt = low1+low2-zeroDigit;
if (lowt < 0) lowt = 0;
hight = high1 + high2 - zeroDigit;
if (hight >= maxDigits) hight = maxDigits-1;
else if (hight < 0)
{
if (hight < -1)
{
setZero();
return *this;
}
hight = 0;
}
unsigned temp[maxDigits*2];
_clear(temp);
// memset(temp+low1+low2, 0, (high1+high2-low1-low2+2)*sizeof(unsigned)); // only need to clear part of the target we're adding to.
//More: could copy across 1st time round - might be worth it.
const byte * digits1 = digits;
const byte * digits2 = other.digits;
for (int i = low1; i <= high1; i++)
{
byte next = digits1[i];
if (next)
{
for (int j=low2; j <= high2; j++)
temp[i+j] += next * digits2[j];
}
}
//Now copy the results, taking care of the carries
unsigned carry = 0;
int j;
for (j = low1+low2 - zeroDigit; j < lowt; j++)
{
unsigned next = temp[j+zeroDigit]+carry;
//Round the least significant digit
if (j+1 == lowt)
next += 5;
carry = next / 10;
}
for (j = lowt; j <= hight; j++)
{
div_t next = div(temp[j+zeroDigit]+carry, 10);
digits[j] = next.rem;
carry = next.quot;
}
while ((hight < maxDigits-1) && (carry != 0))
{
digits[++hight] = carry % 10;
carry = carry / 10;
}
lsb = lowt;
msb = hight;
negative ^= other.negative;
return *this;
}
开发者ID:Josh-Googler,项目名称:HPCC-Platform,代码行数:67,代码来源:nbcd.cpp
示例7: segment1
// out_map was initialized to 0 already
int segment1(image *in_image, image *out_map, int min_dist_th)
{
int n_bands = in_image->num_of_bands;
int n_lines = in_image->num_of_lines;
int n_cols = in_image->num_of_samples;
int n_seg = 0; // number of segments, first segment is named 1, second 2, and so on
float pel_dist, min_dist; // measurement of the distance between two pixels
imgpel **map = (imgpel **) dim2 (n_lines, n_cols, sizeof(imgpel));
for(int y=0; y<n_lines; y++)
{
for(int x=0; x<n_cols; x++)
{
if(map[y][x] == 0) // non-segmented pixel, check its eight neighbors for a potential merge; if no merge, start a new segment
{
min_dist = (float) LARGE_FLOAT;
for(int j=y-1; j<=y+1; j++)
{
for(int i=x-1; i<=x+1; i++)
{
if(j>=0 && j<n_lines && i>=0 && i<n_cols && (j!=y || i!=x) && (map[j][i]>0))
{
pel_dist = 0;
for(int k=0; k<n_bands; k++)
pel_dist += ((in_image->IMG[k][y][x] - in_image->IMG[k][j][i]) * (in_image->IMG[k][y][x] - in_image->IMG[k][j][i]));
if(pel_dist < min_dist)
{
min_dist = pel_dist;
map[y][x] = map[j][i];
}
}
}
}
if (min_dist > min_dist_th * n_bands)
{
n_seg += 1;
map[y][x] = (imgpel) n_seg;
}
}
}
}
for(int y=0; y<n_lines; y++)
{
for(int x=0; x<n_cols; x++)
{
int boundary_flag = 0;
for(int j=y-1; j<=y+1; j++)
{
for(int i=x-1; i<=x+1; i++)
{
int jj = clip(0, n_lines-1, j);
int ii = clip(0, n_cols-1, i);
if(map[jj][ii] != map[y][x]) boundary_flag = 1;
}
}
for(int k=0; k<n_bands; k++)
out_map->IMG[k][y][x] = ((boundary_flag==1) ? 0xFFFF : in_image->IMG[k][y][x]);
}
}
free2((char **)map);
return n_seg;
}
开发者ID:geomanyxf,项目名称:nikki,代码行数:67,代码来源:segment1.cpp
示例8: clip
/*
* sprite_get_image()
* Receives an animation and the desired frame number.
* Returns an image.
*/
image_t *sprite_get_image(const animation_t *anim, int frame_id)
{
frame_id = clip(frame_id, 0, anim->frame_count-1);
return anim->frame_data[ anim->data[frame_id] ];
}
开发者ID:myeongjinkim,项目名称:sample,代码行数:10,代码来源:sprite.c
示例9: headerRect
void TextPrinter::paintPage(QPainter *painter,
QTextDocument *document,
int pagenum)
{
QRectF rect;
double onepoint = painter->device()->logicalDpiY() / 72.0;
// header
if (headersize_ > 0) {
rect = headerRect(painter->device());
if (headerrule_ > 0.0) {
painter->save();
// allow space between rule and header
painter->translate(0, onepoint + (headerrule_ * onepoint / 2.0));
painter->setPen(QPen(Qt::black, headerrule_ * onepoint));
painter->drawLine(rect.bottomLeft(), rect.bottomRight());
painter->restore();
}
// replace page variables
QString header = headertext_;
header.replace("&page;", QString::number(pagenum));
if (dateformat_.isEmpty()) {
header.replace("&date;", QDate::currentDate().toString());
} else {
header.replace("&date;", QDate::currentDate().toString(dateformat_));
}
painter->save();
painter->translate(rect.left(), rect.top());
QRectF clip(0, 0, rect.width(), rect.height());
QTextDocument doc;
doc.setUseDesignMetrics(true);
doc.setHtml(header);
doc.documentLayout()->setPaintDevice(painter->device());
doc.setPageSize(rect.size());
// align text to bottom
double newtop = clip.bottom() - doc.size().height();
clip.setHeight(doc.size().height());
painter->translate(0, newtop);
doc.drawContents(painter, clip);
painter->restore();
}
// footer
if (footersize_ > 0) {
rect = footerRect(painter->device());
if (footerrule_ > 0.0) {
painter->save();
// allow space between rule and footer
painter->translate(0, -onepoint + (-footerrule_ * onepoint / 2.0));
painter->setPen(QPen(Qt::black, footerrule_ * onepoint));
painter->drawLine(rect.topLeft(), rect.topRight());
painter->restore();
}
// replace page variables
QString footer = footertext_;
footer.replace("&page;", QString::number(pagenum));
if (dateformat_.isEmpty()) {
footer.replace("&date;", QDate::currentDate().toString());
} else {
footer.replace("&date;", QDate::currentDate().toString(dateformat_));
}
painter->save();
painter->translate(rect.left(), rect.top());
QRectF clip(0, 0, rect.width(), rect.height());
QTextDocument doc;
doc.setUseDesignMetrics(true);
doc.setHtml(footer);
doc.documentLayout()->setPaintDevice(painter->device());
doc.setPageSize(rect.size());
doc.drawContents(painter, clip);
painter->restore();
}
// content
painter->save();
rect = contentRect(painter->device());
painter->translate(rect.left(), rect.top() - (pagenum-1) * rect.height());
QRectF clip(0, (pagenum-1) * rect.height(), rect.width(), rect.height());
document->drawContents(painter, clip);
painter->restore();
}
开发者ID:Sangil-Lee,项目名称:RefCode,代码行数:90,代码来源:textprinter.cpp
示例10: trimRight
inline StringBuffer & trimRight() { return clip(); }
开发者ID:atodor,项目名称:HPCC-Platform,代码行数:1,代码来源:jstring.hpp
示例11: FinalAlphaValue
static int FinalAlphaValue(int alpha) {
alpha = MAX_ALPHA - alpha;
return clip(alpha, 0, MAX_ALPHA);
}
开发者ID:haroldma,项目名称:Universal.WebP,代码行数:4,代码来源:analysis.c
示例12: SkASSERT
////////////////////////////////////////////////////////////////////////////////
// Create a 1-bit clip mask in the stencil buffer. 'devClipBounds' are in device
// (as opposed to canvas) coordinates
bool GrClipMaskManager::createStencilClipMask(GrRenderTarget* rt,
int32_t elementsGenID,
GrReducedClip::InitialState initialState,
const GrReducedClip::ElementList& elements,
const SkIRect& clipSpaceIBounds,
const SkIPoint& clipSpaceToStencilOffset) {
SkASSERT(rt);
GrStencilAttachment* stencilAttachment =
fDrawTarget->cmmAccess().resourceProvider()->attachStencilAttachment(rt);
if (nullptr == stencilAttachment) {
return false;
}
if (stencilAttachment->mustRenderClip(elementsGenID, clipSpaceIBounds, clipSpaceToStencilOffset)) {
stencilAttachment->setLastClip(elementsGenID, clipSpaceIBounds, clipSpaceToStencilOffset);
// Set the matrix so that rendered clip elements are transformed from clip to stencil space.
SkVector translate = {
SkIntToScalar(clipSpaceToStencilOffset.fX),
SkIntToScalar(clipSpaceToStencilOffset.fY)
};
SkMatrix viewMatrix;
viewMatrix.setTranslate(translate);
// We set the current clip to the bounds so that our recursive draws are scissored to them.
SkIRect stencilSpaceIBounds(clipSpaceIBounds);
stencilSpaceIBounds.offset(clipSpaceToStencilOffset);
GrClip clip(stencilSpaceIBounds);
int clipBit = stencilAttachment->bits();
SkASSERT((clipBit <= 16) && "Ganesh only handles 16b or smaller stencil buffers");
clipBit = (1 << (clipBit-1));
fDrawTarget->cmmAccess().clearStencilClip(stencilSpaceIBounds,
GrReducedClip::kAllIn_InitialState == initialState, rt);
// walk through each clip element and perform its set op
// with the existing clip.
for (GrReducedClip::ElementList::Iter iter(elements.headIter()); iter.get(); iter.next()) {
const Element* element = iter.get();
GrPipelineBuilder pipelineBuilder;
pipelineBuilder.setClip(clip);
pipelineBuilder.setRenderTarget(rt);
pipelineBuilder.setDisableColorXPFactory();
// if the target is MSAA then we want MSAA enabled when the clip is soft
if (rt->isStencilBufferMultisampled()) {
pipelineBuilder.setState(GrPipelineBuilder::kHWAntialias_Flag, element->isAA());
}
bool fillInverted = false;
// enabled at bottom of loop
fClipMode = kIgnoreClip_StencilClipMode;
// This will be used to determine whether the clip shape can be rendered into the
// stencil with arbitrary stencil settings.
GrPathRenderer::StencilSupport stencilSupport;
GrStrokeInfo stroke(SkStrokeRec::kFill_InitStyle);
SkRegion::Op op = element->getOp();
GrPathRenderer* pr = nullptr;
SkPath clipPath;
if (Element::kRect_Type == element->getType()) {
stencilSupport = GrPathRenderer::kNoRestriction_StencilSupport;
fillInverted = false;
} else {
element->asPath(&clipPath);
fillInverted = clipPath.isInverseFillType();
if (fillInverted) {
clipPath.toggleInverseFillType();
}
pr = this->getContext()->getPathRenderer(fDrawTarget,
&pipelineBuilder,
viewMatrix,
clipPath,
stroke,
false,
GrPathRendererChain::kStencilOnly_DrawType,
&stencilSupport);
if (nullptr == pr) {
return false;
}
}
int passes;
GrStencilSettings stencilSettings[GrStencilSettings::kMaxStencilClipPasses];
bool canRenderDirectToStencil =
GrPathRenderer::kNoRestriction_StencilSupport == stencilSupport;
bool canDrawDirectToClip; // Given the renderer, the element,
// fill rule, and set operation can
// we render the element directly to
// stencil bit used for clipping.
canDrawDirectToClip = GrStencilSettings::GetClipPasses(op,
//.........这里部分代码省略.........
开发者ID:Just-D,项目名称:skia,代码行数:101,代码来源:GrClipMaskManager.cpp
示例13: GetClipMaskKey
GrTexture* GrClipMaskManager::createAlphaClipMask(int32_t elementsGenID,
GrReducedClip::InitialState initialState,
const GrReducedClip::ElementList& elements,
const SkVector& clipToMaskOffset,
const SkIRect& clipSpaceIBounds) {
GrResourceProvider* resourceProvider = fDrawTarget->cmmAccess().resourceProvider();
GrUniqueKey key;
GetClipMaskKey(elementsGenID, clipSpaceIBounds, &key);
if (GrTexture* texture = resourceProvider->findAndRefTextureByUniqueKey(key)) {
return texture;
}
SkAutoTUnref<GrTexture> texture(this->createCachedMask(
clipSpaceIBounds.width(), clipSpaceIBounds.height(), key, true));
// There's no texture in the cache. Let's try to allocate it then.
if (!texture) {
return nullptr;
}
// Set the matrix so that rendered clip elements are transformed to mask space from clip
// space.
SkMatrix translate;
translate.setTranslate(clipToMaskOffset);
// The texture may be larger than necessary, this rect represents the part of the texture
// we populate with a rasterization of the clip.
SkIRect maskSpaceIBounds = SkIRect::MakeWH(clipSpaceIBounds.width(), clipSpaceIBounds.height());
// The scratch texture that we are drawing into can be substantially larger than the mask. Only
// clear the part that we care about.
fDrawTarget->clear(&maskSpaceIBounds,
GrReducedClip::kAllIn_InitialState == initialState ? 0xffffffff : 0x00000000,
true,
texture->asRenderTarget());
// When we use the stencil in the below loop it is important to have this clip installed.
// The second pass that zeros the stencil buffer renders the rect maskSpaceIBounds so the first
// pass must not set values outside of this bounds or stencil values outside the rect won't be
// cleared.
GrClip clip(maskSpaceIBounds);
SkAutoTUnref<GrTexture> temp;
// walk through each clip element and perform its set op
for (GrReducedClip::ElementList::Iter iter = elements.headIter(); iter.get(); iter.next()) {
const Element* element = iter.get();
SkRegion::Op op = element->getOp();
bool invert = element->isInverseFilled();
if (invert || SkRegion::kIntersect_Op == op || SkRegion::kReverseDifference_Op == op) {
GrPipelineBuilder pipelineBuilder;
pipelineBuilder.setClip(clip);
GrPathRenderer* pr = nullptr;
bool useTemp = !this->canStencilAndDrawElement(&pipelineBuilder, texture, &pr, element);
GrTexture* dst;
// This is the bounds of the clip element in the space of the alpha-mask. The temporary
// mask buffer can be substantially larger than the actually clip stack element. We
// touch the minimum number of pixels necessary and use decal mode to combine it with
// the accumulator.
SkIRect maskSpaceElementIBounds;
if (useTemp) {
if (invert) {
maskSpaceElementIBounds = maskSpaceIBounds;
} else {
SkRect elementBounds = element->getBounds();
elementBounds.offset(clipToMaskOffset);
elementBounds.roundOut(&maskSpaceElementIBounds);
}
if (!temp) {
temp.reset(this->createTempMask(maskSpaceIBounds.fRight,
maskSpaceIBounds.fBottom));
if (!temp) {
texture->resourcePriv().removeUniqueKey();
return nullptr;
}
}
dst = temp;
// clear the temp target and set blend to replace
fDrawTarget->clear(&maskSpaceElementIBounds,
invert ? 0xffffffff : 0x00000000,
true,
dst->asRenderTarget());
set_coverage_drawing_xpf(SkRegion::kReplace_Op, invert, &pipelineBuilder);
} else {
// draw directly into the result with the stencil set to make the pixels affected
// by the clip shape be non-zero.
dst = texture;
GR_STATIC_CONST_SAME_STENCIL(kStencilInElement,
kReplace_StencilOp,
kReplace_StencilOp,
kAlways_StencilFunc,
0xffff,
0xffff,
0xffff);
pipelineBuilder.setStencil(kStencilInElement);
set_coverage_drawing_xpf(op, invert, &pipelineBuilder);
}
//.........这里部分代码省略.........
开发者ID:Just-D,项目名称:skia,代码行数:101,代码来源:GrClipMaskManager.cpp
示例14: FPDF_FFLDraw
DLLEXPORT void STDCALL FPDF_FFLDraw(FPDF_FORMHANDLE hHandle,
FPDF_BITMAP bitmap,
FPDF_PAGE page,
int start_x,
int start_y,
int size_x,
int size_y,
int rotate,
int flags) {
if (!hHandle)
return;
UnderlyingPageType* pPage = UnderlyingFromFPDFPage(page);
if (!pPage)
return;
#ifndef PDF_ENABLE_XFA
CPDF_RenderOptions options;
if (flags & FPDF_LCD_TEXT)
options.m_Flags |= RENDER_CLEARTYPE;
else
options.m_Flags &= ~RENDER_CLEARTYPE;
// Grayscale output
if (flags & FPDF_GRAYSCALE) {
options.m_ColorMode = RENDER_COLOR_GRAY;
options.m_ForeColor = 0;
options.m_BackColor = 0xffffff;
}
options.m_AddFlags = flags >> 8;
options.m_pOCContext = new CPDF_OCContext(pPage->m_pDocument);
#else // PDF_ENABLE_XFA
CPDFXFA_Document* pDocument = pPage->GetDocument();
if (!pDocument)
return;
CPDF_Document* pPDFDoc = pDocument->GetPDFDoc();
if (!pPDFDoc)
return;
CPDFDoc_Environment* pEnv = (CPDFDoc_Environment*)hHandle;
CPDFSDK_Document* pFXDoc = pEnv->GetSDKDocument();
if (!pFXDoc)
return;
#endif // PDF_ENABLE_XFA
CFX_Matrix matrix;
pPage->GetDisplayMatrix(matrix, start_x, start_y, size_x, size_y, rotate);
FX_RECT clip(start_x, start_y, start_x + size_x, start_y + size_y);
#ifdef _SKIA_SUPPORT_
std::unique_ptr<CFX_SkiaDevice> pDevice(new CFX_SkiaDevice);
#else
std::unique_ptr<CFX_FxgeDevice> pDevice(new CFX_FxgeDevice);
#endif
pDevice->Attach((CFX_DIBitmap*)bitmap);
pDevice->SaveState();
pDevice->SetClip_Rect(clip);
#ifndef PDF_ENABLE_XFA
if (CPDFSDK_PageView* pPageView = FormHandleToPageView(hHandle, pPage))
pPageView->PageView_OnDraw(pDevice.get(), &matrix, &options);
#else // PDF_ENABLE_XFA
CPDF_RenderOptions options;
if (flags & FPDF_LCD_TEXT)
options.m_Flags |= RENDER_CLEARTYPE;
else
options.m_Flags &= ~RENDER_CLEARTYPE;
// Grayscale output
if (flags & FPDF_GRAYSCALE) {
options.m_ColorMode = RENDER_COLOR_GRAY;
options.m_ForeColor = 0;
options.m_BackColor = 0xffffff;
}
options.m_AddFlags = flags >> 8;
options.m_pOCContext = new CPDF_OCContext(pPDFDoc);
if (CPDFSDK_PageView* pPageView = pFXDoc->GetPageView(pPage))
pPageView->PageView_OnDraw(pDevice.get(), &matrix, &options, clip);
#endif // PDF_ENABLE_XFA
pDevice->RestoreState();
delete options.m_pOCContext;
#ifdef PDF_ENABLE_XFA
options.m_pOCContext = NULL;
#endif // PDF_ENABLE_XFA
}
开发者ID:JinAirsOs,项目名称:pdfium,代码行数:86,代码来源:fpdfformfill.cpp
示例15: clip
void TextArea::Draw(unsigned short x, unsigned short y)
{
/** Don't come back recursively */
if (InternalFlags&TA_BITEMYTAIL) {
return;
}
int tx=x+XPos;
int ty=y+YPos;
Region clip( tx, ty, Width, Height );
Video *video = core->GetVideoDriver();
if (Flags&IE_GUI_TEXTAREA_SPEAKER) {
if (AnimPicture) {
video->BlitSprite(AnimPicture, tx,ty, true, &clip);
clip.x+=AnimPicture->Width;
clip.w-=AnimPicture->Width;
}
}
//this might look better in GlobalTimer
//or you might want to change the animated button to work like this
if (Flags &IE_GUI_TEXTAREA_SMOOTHSCROLL)
{
unsigned long thisTime;
GetTime( thisTime);
if (thisTime>starttime) {
starttime = thisTime+ticks;
smooth--;
while (smooth<=0) {
smooth+=ftext->maxHeight;
if (startrow<rows) {
startrow++;
}
}
/** Forcing redraw of whole screen before drawing text*/
Owner->Invalidate();
InternalFlags |= TA_BITEMYTAIL;
Owner->DrawWindow();
InternalFlags &= ~TA_BITEMYTAIL;
}
}
if (!Changed && !(Owner->Flags&WF_FLOAT) ) {
return;
}
Changed = false;
if (XPos == 65535) {
return;
}
size_t linesize = lines.size();
if (linesize == 0) {
return;
}
//smooth vertical scrolling up
if (Flags & IE_GUI_TEXTAREA_SMOOTHSCROLL) {
clip.y+=smooth;
clip.h-=smooth;
}
//if textarea is 'selectable' it actually means, it is a listbox
//in this case the selected value equals the line number
//if it is 'not selectable' it can still have selectable lines
//but then it is like the dialog window in the main game screen:
//the selected value is encoded into the line
if (!(Flags & IE_GUI_TEXTAREA_SELECTABLE) ) {
char* Buffer = (char *) malloc( 1 );
Buffer[0] = 0;
int len = 0;
int lastlen = 0;
for (size_t i = 0; i < linesize; i++) {
if (strnicmp( "[s=", lines[i], 3 ) == 0) {
int tlen;
unsigned long idx, acolor, bcolor;
char* rest;
idx = strtoul( lines[i] + 3, &rest, 0 );
if (*rest != ',')
goto notmatched;
acolor = strtoul( rest + 1, &rest, 16 );
if (*rest != ',')
goto notmatched;
bcolor = strtoul( rest + 1, &rest, 16 );
if (*rest != ']')
goto notmatched;
tlen = (int)(strstr( rest + 1, "[/s]" ) - rest - 1);
if (tlen < 0)
goto notmatched;
len += tlen + 23;
Buffer = (char *) realloc( Buffer, len + 2 );
if (seltext == (int) i) {
sprintf( Buffer + lastlen, "[color=%6.6lX]%.*s[/color]",
acolor, tlen, rest + 1 );
} else {
sprintf( Buffer + lastlen, "[color=%6.6lX]%.*s[/color]",
bcolor, tlen, rest + 1 );
}
} else {
//.........这里部分代码省略.........
开发者ID:NickDaly,项目名称:GemRB-MultipleConfigs,代码行数:101,代码来源:TextArea.cpp
示例16: tipDisplay
/* Update and possibly display the tip */
void tipDisplay()
{
SDWORD newMX, newMY;
SDWORD currTime;
SDWORD fw, topGap;
switch (tipState)
{
case TIP_WAIT:
/* See if the tip has to be shown */
newMX = mouseX();
newMY = mouseY();
currTime = wzGetTicks();
if (newMX == mx &&
newMY == my &&
(currTime - startTime > TIP_PAUSE))
{
/* Activate the tip */
tipState = TIP_ACTIVE;
/* Calculate the size of the tip box */
topGap = TIP_VGAP;
iV_SetFont(FontID);
lineHeight = iV_GetTextLineSize();
fw = 0;
for (int n = 0; n < pTip.size(); ++n)
{
fw = std::max<int>(fw, iV_GetTextWidth(pTip[n].toUtf8().constData()));
}
tw = fw + TIP_HGAP * 2;
th = topGap * 2 + lineHeight * pTip.size() + iV_GetTextBelowBase();
/* Position the tip box */
tx = clip(wx + ww / 2, 0, screenWidth - tw - 1);
ty = std::max(wy + wh + TIP_VGAP, 0);
if (ty + th >= (int)screenHeight)
{
/* Position the tip above the button */
ty = wy - th - TIP_VGAP;
}
/* Position the text */
fx = tx + TIP_HGAP;
fy = ty + (th - lineHeight * pTip.size()) / 2 - iV_GetTextAboveBase();
/* Note the time */
startTime = wzGetTicks();
}
else if (newMX != mx ||
newMY != my ||
mousePressed(MOUSE_LMB))
{
mx = newMX;
my = newMY;
startTime = currTime;
}
break;
case TIP_ACTIVE:
/* Draw the tool tip */
pie_BoxFill(tx, ty, tx + tw, ty + th, WZCOL_FORM_TIP_BACKGROUND);
iV_Line(tx + 1, ty + th - 2, tx + 1, ty + 1, WZCOL_FORM_DARK);
iV_Line(tx + 2, ty + 1, tx + tw - 2, ty + 1, WZCOL_FORM_DARK);
iV_Line(tx, ty + th, tx + tw, ty + th, WZCOL_FORM_DARK);
iV_Line(tx + tw, ty + th - 1, tx + tw, ty, WZCOL_FORM_DARK);
iV_Box(tx, ty, tx + tw - 1, ty + th - 1, WZCOL_FORM_LIGHT);
iV_SetFont(FontID);
iV_SetTextColour(TipColour);
for (int n = 0; n < pTip.size(); ++n)
{
iV_DrawText(pTip[n].toUtf8().constData(), fx, fy + lineHeight * n);
}
break;
default:
break;
}
}
开发者ID:C1annad,项目名称:warzone2100,代码行数:81,代码来源:tip.cpp
示例17: game_redraw
static void game_redraw(drawing *dr, game_drawstate *ds, game_state *oldstate,
game_state *state, int dir, game_ui *ui,
float animtime, float flashtime)
{
int i, x, y, ts = TILE_SIZE, isflash = 0, force = 0;
if (flashtime > 0) {
int frame = (int)(flashtime / FLASH_FRAME);
isflash = (frame % 2) == 0;
debug(("game_redraw: flashtime = %f", flashtime));
}
if (!ds->started) {
int x0 = TODRAW(0)-1, y0 = TODRAW(0)-1;
int x1 = TODRAW(state->w+2), y1 = TODRAW(state->h+2);
draw_rect(dr, 0, 0,
TILE_SIZE * (state->w+3), TILE_SIZE * (state->h+3),
COL_BACKGROUND);
/* clockwise around the outline starting at pt behind (1,1). */
draw_line(dr, x0+ts, y0+ts, x0+ts, y0, COL_HIGHLIGHT);
draw_line(dr, x0+ts, y0, x1-ts, y0, COL_HIGHLIGHT);
draw_line(dr, x1-ts, y0, x1-ts, y0+ts, COL_LOWLIGHT);
draw_line(dr, x1-ts, y0+ts, x1, y0+ts, COL_HIGHLIGHT);
draw_line(dr, x1, y0+ts, x1, y1-ts, COL_LOWLIGHT);
draw_line(dr, x1, y1-ts, x1-ts, y1-ts, COL_LOWLIGHT);
draw_line(dr, x1-ts, y1-ts, x1-ts, y1, COL_LOWLIGHT);
draw_line(dr, x1-ts, y1, x0+ts, y1, COL_LOWLIGHT);
draw_line(dr, x0+ts, y1, x0+ts, y1-ts, COL_HIGHLIGHT);
draw_line(dr, x0+ts, y1-ts, x0, y1-ts, COL_LOWLIGHT);
draw_line(dr, x0, y1-ts, x0, y0+ts, COL_HIGHLIGHT);
draw_line(dr, x0, y0+ts, x0+ts, y0+ts, COL_HIGHLIGHT);
/* phew... */
draw_update(dr, 0, 0,
TILE_SIZE * (state->w+3), TILE_SIZE * (state->h+3));
force = 1;
ds->started = 1;
}
if (isflash != ds->isflash) force = 1;
/* draw the arena */
for (x = 0; x < state->w; x++) {
for (y = 0; y < state->h; y++) {
draw_arena_tile(dr, state, ds, ui, x, y, force, isflash);
}
}
/* draw the lasers */
ds->flash_laserno = LASER_EMPTY;
if (ui->flash_laser == 1)
ds->flash_laserno = ui->flash_laserno;
else if (ui->flash_laser == 2 && animtime > 0)
ds->flash_laserno = ui->flash_laserno;
for (i = 0; i < 2*(state->w+state->h); i++) {
draw_laser_tile(dr, state, ds, ui, i, force);
}
/* draw the 'finish' button */
if (CAN_REVEAL(state)) {
int outline = (ui->cur_visible && ui->cur_x ==
|
请发表评论