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); }
bool Sk2DPathEffect::filterPath(SkPath* dst, const SkPath& src, SkStrokeRec*) { if (!fMatrixIsInvertible) { return false; } SkPath tmp; SkIRect ir; src.transform(fInverse, &tmp); tmp.getBounds().round(&ir); if (!ir.isEmpty()) { this->begin(ir, dst); SkRegion rgn; rgn.setPath(tmp, SkRegion(ir)); SkRegion::Iterator iter(rgn); for (; !iter.done(); iter.next()) { const SkIRect& rect = iter.rect(); for (int y = rect.fTop; y < rect.fBottom; ++y) { this->nextSpan(rect.fLeft, y, rect.width(), dst); } } this->end(dst); } return true; }
static SkRegion make_region() { SkIRect iRegion = SkIRect::MakeXYWH(R(static_cast<float>(kBitmapSize)), R(static_cast<float>(kBitmapSize)), R(static_cast<float>(kBitmapSize)), R(static_cast<float>(kBitmapSize))); return SkRegion(iRegion); }
static SkRegion make_region() { int32_t x, y, w, h; fuzz->nextRange(&x, 0, kBitmapSize-1); fuzz->nextRange(&y, 0, kBitmapSize-1); fuzz->nextRange(&w, 0, kBitmapSize-1); fuzz->nextRange(&h, 0, kBitmapSize-1); SkIRect iRegion = SkIRect::MakeXYWH(x,y,w,h); return SkRegion(iRegion); }
void forceLinking() { SkLightingImageFilter::CreateDistantLitDiffuse(SkPoint3(0,0,0), 0, 0, 0); SkMagnifierImageFilter mag(SkRect::MakeWH(SK_Scalar1, SK_Scalar1), SK_Scalar1); GrConfigConversionEffect::Create(NULL, false, GrConfigConversionEffect::kNone_PMConversion, SkMatrix::I()); SkScalar matrix[20]; SkColorMatrixFilter cmf(matrix); SkBitmapAlphaThresholdShader::Create(SkBitmap(), SkRegion(), 0x80); }
AAClipRegionBench(void* param) : INHERITED(param) { SkPath path; // test conversion of a complex clip to a aaclip path.addCircle(0, 0, SkIntToScalar(200)); path.addCircle(0, 0, SkIntToScalar(180)); // evenodd means we've constructed basically a stroked circle path.setFillType(SkPath::kEvenOdd_FillType); SkIRect bounds; path.getBounds().roundOut(&bounds); fRegion.setPath(path, SkRegion(bounds)); }
void forceLinking() { SkLightingImageFilter::CreateDistantLitDiffuse(SkPoint3(0,0,0), 0, 0, 0); SkAlphaThresholdFilter::Create(SkRegion(), .5f, .5f); SkAutoTUnref<SkImageFilter> mag(SkMagnifierImageFilter::Create( SkRect::MakeWH(SK_Scalar1, SK_Scalar1), SK_Scalar1)); GrConfigConversionEffect::Create(NULL, false, GrConfigConversionEffect::kNone_PMConversion, SkMatrix::I()); SkScalar matrix[20]; SkAutoTUnref<SkColorMatrixFilter> cmf(SkColorMatrixFilter::Create(matrix)); }
static void setRgnToPath(SkRegion* rgn, const SkPath& path) { SkIRect ir; path.getBounds().round(&ir); rgn->setPath(path, SkRegion(ir)); }
void TileGrid::drawGL(const IntRect& visibleContentArea, float opacity, const TransformationMatrix* transform, const Color* background) { m_area = computeTilesArea(visibleContentArea, m_scale); if (m_area.width() == 0 || m_area.height() == 0) return; float invScale = 1.0 / m_scale; const float tileWidth = TilesManager::tileWidth() * invScale; const float tileHeight = TilesManager::tileHeight() * invScale; int drawn = 0; SkRegion missingRegion; bool semiOpaqueBaseSurface = background ? (background->hasAlpha() && background->alpha() > 0) : false; if (semiOpaqueBaseSurface) { SkIRect totalArea = SkIRect::MakeXYWH(m_area.x(), m_area.y(), m_area.width(), m_area.height()); missingRegion = SkRegion(totalArea); } bool usePointSampling = TilesManager::instance()->shader()->usePointSampling(m_scale, transform); float minTileX = visibleContentArea.x() / tileWidth; float minTileY = visibleContentArea.y() / tileWidth; float maxTileWidth = visibleContentArea.maxX() / tileWidth; float maxTileHeight = visibleContentArea.maxY() / tileWidth; ALOGV("minTileX, minTileY, maxTileWidth, maxTileHeight %f, %f, %f %f", minTileX, minTileY, maxTileWidth, maxTileHeight); for (unsigned int i = 0; i < m_tiles.size(); i++) { Tile* tile = m_tiles[i]; bool tileInView = tile->isTileVisible(m_area); if (tileInView) { SkRect rect; rect.fLeft = tile->x() * tileWidth; rect.fTop = tile->y() * tileHeight; rect.fRight = rect.fLeft + tileWidth; rect.fBottom = rect.fTop + tileHeight; ALOGV("tile %p (layer tile: %d) %d,%d at scale %.2f vs %.2f [ready: %d] dirty: %d", tile, tile->isLayerTile(), tile->x(), tile->y(), tile->scale(), m_scale, tile->isTileReady(), tile->isDirty()); bool forceBaseBlending = background ? background->hasAlpha() : false; float left = std::max(minTileX - tile->x(), 0.0f); float top = std::max(minTileY - tile->y(), 0.0f); float right = std::min(maxTileWidth - tile->x(), 1.0f); float bottom = std::min(maxTileHeight - tile->y(), 1.0f); if (left > 1.0f || top > 1.0f || right < 0.0f || bottom < 0.0f) { ALOGE("Unexpected portion:left, top, right, bottom %f %f %f %f", left, top, right, bottom); left = 0.0f; top = 0.0f; right = 1.0f; bottom = 1.0f; } FloatRect fillPortion(left, top, right - left, bottom - top); bool success = tile->drawGL(opacity, rect, m_scale, transform, forceBaseBlending, usePointSampling, fillPortion); if (semiOpaqueBaseSurface && success) { // Cut the successful drawn tile area from the missing region. missingRegion.op(SkIRect::MakeXYWH(tile->x(), tile->y(), 1, 1), SkRegion::kDifference_Op); } if (tile->frontTexture()) drawn++; } // log tile information for base, high res tiles if (m_isBaseSurface && background) TilesManager::instance()->getProfiler()->nextTile(tile, invScale, tileInView); } // Draw missing Regions with blend turned on if (semiOpaqueBaseSurface) drawMissingRegion(missingRegion, opacity, background); ALOGV("TG %p drew %d tiles, scale %f", this, drawn, m_scale); }