// Given a bitmap, an optional src rect, and a context with a clip and matrix determine what
// pixels from the bitmap are necessary.
-static void determine_clipped_src_rect(int width, int height,
+static void determine_clipped_src_rect(const GrRenderTarget* rt,
const GrClip& clip,
const SkMatrix& viewMatrix,
const SkISize& imageSize,
const SkRect* srcRectPtr,
SkIRect* clippedSrcIRect) {
- clip.getConservativeBounds(width, height, clippedSrcIRect, nullptr);
+ clip.getConservativeBounds(rt->width(), rt->height(), clippedSrcIRect, nullptr);
SkMatrix inv;
if (!viewMatrix.invert(&inv)) {
clippedSrcIRect->setEmpty();
ASSERT_SINGLE_OWNER
// if it's larger than the max tile size, then we have no choice but tiling.
if (imageRect.width() > maxTileSize || imageRect.height() > maxTileSize) {
- determine_clipped_src_rect(fDrawContext->width(), fDrawContext->height(),
- fClip, viewMatrix, imageRect.size(),
+ determine_clipped_src_rect(fRenderTarget, fClip, viewMatrix, imageRect.size(),
srcRectPtr, clippedSubset);
*tileSize = determine_tile_size(*clippedSubset, maxTileSize);
return true;
// Figure out how much of the src we will need based on the src rect and clipping. Reject if
// tiling memory savings would be < 50%.
- determine_clipped_src_rect(fDrawContext->width(), fDrawContext->height(),
- fClip, viewMatrix, imageRect.size(), srcRectPtr,
+ determine_clipped_src_rect(fRenderTarget, fClip, viewMatrix, imageRect.size(), srcRectPtr,
clippedSubset);
*tileSize = kBmpSmallTileSize; // already know whole bitmap fits in one max sized tile.
size_t usedTileBytes = get_tile_count(*clippedSubset, kBmpSmallTileSize) *
ASSERT_SINGLE_OWNER
// TODO: Change the signature of newSurface to take a budgeted parameter.
static const SkBudgeted kBudgeted = SkBudgeted::kNo;
- return SkSurface::MakeRenderTarget(fContext, kBudgeted, info, fDrawContext->numColorSamples(),
+ return SkSurface::MakeRenderTarget(fContext, kBudgeted, info, fRenderTarget->desc().fSampleCnt,
&props);
}
initialMatrix,
clipBounds,
&atlasedNeedRendering, &atlasedRecycled,
- fDrawContext->numColorSamples());
+ fRenderTarget->numColorSamples());
GrLayerHoister::DrawLayersToAtlas(fContext, atlasedNeedRendering);
initialMatrix,
clipBounds,
&needRendering, &recycled,
- fDrawContext->numColorSamples());
+ fRenderTarget->numColorSamples());
GrLayerHoister::DrawLayers(fContext, needRendering);
}
sk_sp<SkSurface> SkSurface_Gpu::onNewSurface(const SkImageInfo& info) {
- int sampleCount = fDevice->accessDrawContext()->numColorSamples();
+ GrRenderTarget* rt = fDevice->accessRenderTarget();
+ int sampleCount = rt->numColorSamples();
// TODO: Make caller specify this (change virtual signature of onNewSurface).
static const SkBudgeted kBudgeted = SkBudgeted::kNo;
return SkSurface::MakeRenderTarget(fDevice->context(), kBudgeted, info, sampleCount,
// want to ever retarget the SkSurface at another buffer we create. Force a copy now to avoid
// copy-on-write.
if (kYes_ForceCopyMode == forceCopyMode || !tex || rt->resourcePriv().refsWrappedObjects()) {
- GrSurfaceDesc desc = fDevice->accessDrawContext()->desc();
+ GrSurfaceDesc desc = fDevice->accessRenderTarget()->desc();
GrContext* ctx = fDevice->context();
desc.fFlags = desc.fFlags & ~kRenderTarget_GrSurfaceFlag;
copy.reset(ctx->textureProvider()->createTexture(desc, budgeted));