本文整理汇总了C++中SkRegion::op方法的典型用法代码示例。如果您正苦于以下问题:C++ SkRegion::op方法的具体用法?C++ SkRegion::op怎么用?C++ SkRegion::op使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SkRegion
的用法示例。
在下文中一共展示了SkRegion::op方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: RegionBench
RegionBench(int count, Proc proc, const char name[]) {
fProc = proc;
fName.printf("region_%s_%d", name, count);
SkRandom rand;
for (int i = 0; i < count; i++) {
fA.op(randrect(rand), SkRegion::kXOR_Op);
fB.op(randrect(rand), SkRegion::kXOR_Op);
}
}
示例2: RegionBench
RegionBench(void* param, int count, Proc proc, const char name[], int mul = 1) : INHERITED(param) {
fProc = proc;
fName.printf("region_%s_%d", name, count);
fLoopMul = mul;
SkRandom rand;
for (int i = 0; i < count; i++) {
fA.op(randrect(rand), SkRegion::kXOR_Op);
fB.op(randrect(rand), SkRegion::kXOR_Op);
}
}
示例3: drawFocusRing
void GraphicsContext::drawFocusRing(const Vector<IntRect>& rects, int /* width */, int /* offset */, const Color& color)
{
if (paintingDisabled())
return;
unsigned rectCount = rects.size();
if (!rectCount)
return;
SkRegion focusRingRegion;
const SkScalar focusRingOutset = WebCoreFloatToSkScalar(0.5);
for (unsigned i = 0; i < rectCount; i++) {
SkIRect r = rects[i];
r.inset(-focusRingOutset, -focusRingOutset);
focusRingRegion.op(r, SkRegion::kUnion_Op);
}
SkPath path;
SkPaint paint;
paint.setAntiAlias(true);
paint.setStyle(SkPaint::kStroke_Style);
paint.setColor(color.rgb());
paint.setStrokeWidth(focusRingOutset * 2);
paint.setPathEffect(new SkCornerPathEffect(focusRingOutset * 2))->unref();
focusRingRegion.getBoundaryPath(&path);
platformContext()->canvas()->drawPath(path, paint);
}
示例4: paintContents
void DefaultTapHighlight::paintContents(const GraphicsLayer*, GraphicsContext& c, GraphicsLayerPaintingPhase, const IntRect& /*inClip*/)
{
std::vector<Platform::IntRect> rects = m_region.rects();
Platform::IntRect rect = m_region.extents();
SkRegion overlayRegion;
unsigned rectCount = m_region.numRects();
if (!rectCount)
return;
for (unsigned i = 0; i < rectCount; ++i) {
Platform::IntRect rectToPaint = rects[i];
SkIRect r = SkIRect::MakeXYWH(rectToPaint.x(), rectToPaint.y(), rectToPaint.width(), rectToPaint.height());
overlayRegion.op(r, SkRegion::kUnion_Op);
}
SkPath pathToPaint;
overlayRegion.getBoundaryPath(&pathToPaint);
Path path(pathToPaint);
c.save();
c.translate(-rect.x(), -rect.y());
// Draw tap highlight
c.setFillColor(m_color, ColorSpaceDeviceRGB);
c.fillPath(path);
Color darker = Color(m_color.red(), m_color.green(), m_color.blue()); // Get rid of alpha.
c.setStrokeColor(darker, ColorSpaceDeviceRGB);
c.setStrokeThickness(1);
c.strokePath(path);
c.restore();
}
示例5: boolTojboolean
static jboolean Region_op2(JNIEnv* env, jobject, jlong dstHandle, jlong region1Handle, jlong region2Handle, jint op) {
SkRegion* dst = reinterpret_cast<SkRegion*>(dstHandle);
const SkRegion* region1 = reinterpret_cast<SkRegion*>(region1Handle);
const SkRegion* region2 = reinterpret_cast<SkRegion*>(region2Handle);
bool result = dst->op(*region1, *region2, (SkRegion::Op)op);
return boolTojboolean(result);
}
示例6: inval
void SkPageFlipper::inval(const SkRegion& rgn) {
SkRegion r;
r.setRect(0, 0, fWidth, fHeight);
if (r.op(rgn, SkRegion::kIntersect_Op)) {
fDirty1->op(r, SkRegion::kUnion_Op);
}
}
示例7: addHighlightRegion
void RegionLayerDrawExtra::addHighlightRegion(const LayerAndroid* layer, const Vector<IntRect>& rects,
const IntPoint& additionalOffset,
const IntRect& clipRect)
{
if (rects.isEmpty())
return;
int layerId = layer ? layer->uniqueId() : 0;
SkRegion* region = m_highlightRegions.get(layerId);
if (!region) {
region = new SkRegion();
m_highlightRegions.set(layerId, region);
}
IntPoint offset = additionalOffset;
WebViewCore::layerToAbsoluteOffset(layer, offset);
for (size_t i = 0; i < rects.size(); i++) {
IntRect r = rects.at(i);
if (!clipRect.isEmpty()) {
r.intersect(clipRect);
if (r.isEmpty())
continue; // don't add it to the region
}
r.move(-offset.x(), -offset.y());
region->op(r.x(), r.y(), r.maxX(), r.maxY(), SkRegion::kUnion_Op);
}
}
示例8: drawFocusRing
void GraphicsContext::drawFocusRing(const Vector<IntRect>& rects, int width, int offset, const Color& color)
{
if (paintingDisabled())
return;
unsigned rectCount = rects.size();
if (!rectCount)
return;
SkRegion focusRingRegion;
const int focusRingOutset = getFocusRingOutset(offset);
for (unsigned i = 0; i < rectCount; i++) {
SkIRect r = rects[i];
r.inset(-focusRingOutset, -focusRingOutset);
focusRingRegion.op(r, SkRegion::kUnion_Op);
}
SkPath path;
SkPaint paint;
paint.setAntiAlias(true);
paint.setStyle(SkPaint::kStroke_Style);
paint.setColor(color.rgb());
focusRingRegion.getBoundaryPath(&path);
drawOuterPath(platformContext(), path, paint, width);
drawInnerPath(platformContext(), path, paint, width);
}
示例9: scale_rgn
// Scale the region by given scale and set the reuslt to the dst.
// dest and src can be the same region instance.
static void scale_rgn(SkRegion* dst, const SkRegion& src, float scale) {
SkRegion tmp;
SkRegion::Iterator iter(src);
for (; !iter.done(); iter.next()) {
SkIRect r;
scale_rect(&r, iter.rect(), scale);
tmp.op(r, SkRegion::kUnion_Op);
}
dst->swap(tmp);
}
示例10: RegionContainBench
RegionContainBench(Proc proc, const char name[]) {
fProc = proc;
fName.printf("region_contains_%s", name);
SkRandom rand;
for (int i = 0; i < COUNT; i++) {
fA.op(randrect(rand, i), SkRegion::kXOR_Op);
}
fB.setRect(0, 0, H, W);
}
示例11: drawCursorRings
void GLExtras::drawCursorRings()
{
SkRegion region;
for (size_t i = 0; i < m_ring->rings().size(); i++) {
IntRect rect = m_ring->rings().at(i);
if (i == 0)
region.setRect(rect);
else
region.op(rect, SkRegion::kUnion_Op);
}
drawRegion(region, m_ring->m_isPressed, !m_ring->m_isButton, false);
}
示例12: RegionContainBench
RegionContainBench(void* param, Proc proc, const char name[]) : INHERITED(param) {
fProc = proc;
fName.printf("region_contains_%s", name);
SkRandom rand;
for (int i = 0; i < COUNT; i++) {
fA.op(randrect(rand, i), SkRegion::kXOR_Op);
}
fB.setRect(0, 0, H, W);
fIsRendering = false;
}
示例13: opIRect
void SkConservativeClip::opIRect(const SkIRect& devRect, SkRegion::Op op) {
if (SkRegion::kIntersect_Op == op) {
if (!fBounds.intersect(devRect)) {
fBounds.setEmpty();
}
return;
}
// This may still create a complex region (which we would then take the bounds
// Perhaps we should inline the op-logic directly to never create the rgn...
SkRegion result;
result.op(SkRegion(fBounds), SkRegion(devRect), op);
fBounds = result.getBounds();
this->applyClipRestriction(op, &fBounds);
}
示例14:
extern "C" bool complex_clips_draw_from_canvas_state(SkCanvasState* state,
int32_t left, int32_t top, int32_t right, int32_t bottom, int32_t clipOp,
int32_t regionRects, int32_t* rectCoords) {
std::unique_ptr<SkCanvas> canvas = SkCanvasStateUtils::MakeFromCanvasState(state);
if (!canvas) {
return false;
}
SkRegion localRegion;
for (int32_t i = 0; i < regionRects; ++i) {
localRegion.op(rectCoords[0], rectCoords[1], rectCoords[2], rectCoords[3],
SkRegion::kUnion_Op);
rectCoords += 4;
}
complex_clips_draw(canvas.get(), left, top, right, bottom, clipOp, localRegion);
return true;
}
示例15: draw
void CursorRing::draw(SkCanvas* canvas, LayerAndroid* layer)
{
#if USE(ACCELERATED_COMPOSITING)
int layerId = m_node->isInLayer() ? m_frame->layer(m_node)->uniqueId() : -1;
if (layer->uniqueId() != layerId)
return;
#endif
if (canvas->quickReject(m_bounds, SkCanvas::kAA_EdgeType)) {
DBG_NAV_LOGD("canvas->quickReject cursorNode=%d (nodePointer=%p)"
" bounds=(%d,%d,w=%d,h=%d)", m_node->index(), m_node->nodePointer(),
m_bounds.x(), m_bounds.y(), m_bounds.width(), m_bounds.height());
m_followedLink = false;
return;
}
unsigned rectCount = m_rings.size();
SkRegion rgn;
SkPath path;
for (unsigned i = 0; i < rectCount; i++)
{
SkRect r(m_rings[i]);
SkIRect ir;
r.round(&ir);
ir.inset(-CURSOR_RING_OUTER_OUTSET, -CURSOR_RING_OUTER_OUTSET);
rgn.op(ir, SkRegion::kUnion_Op);
}
rgn.getBoundaryPath(&path);
SkPaint paint;
paint.setAntiAlias(true);
paint.setPathEffect(new SkCornerPathEffect(CURSOR_RING_ROUNDEDNESS))->unref();
if (m_flavor >= NORMAL_ANIMATING) { // pressed
paint.setColor(cursorPressedColors[m_flavor - NORMAL_ANIMATING]);
canvas->drawPath(path, paint);
}
paint.setStyle(SkPaint::kStroke_Style);
paint.setStrokeWidth(CURSOR_RING_OUTER_DIAMETER);
paint.setColor(cursorOuterColors[m_flavor]);
canvas->drawPath(path, paint);
paint.setStrokeWidth(CURSOR_RING_INNER_DIAMETER);
paint.setColor(cursorInnerColors[m_flavor]);
canvas->drawPath(path, paint);
}