Revert of Retract GrRenderTarget a bit within SkGpuDevice (patchset #2 id:20001 of...
authorrobertphillips <robertphillips@google.com>
Fri, 6 May 2016 14:55:19 +0000 (07:55 -0700)
committerCommit bot <commit-bot@chromium.org>
Fri, 6 May 2016 14:55:20 +0000 (07:55 -0700)
Reason for revert:
Experimental revert to track down perf regression

Original issue's description:
> Retract GrRenderTarget a bit within SkGpuDevice
>
> Split off of: https://codereview.chromium.org/1930013002/ ((Mostly) Retract GrRenderTarget from SkGpuDevice)
>
> GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1956473002
>
> Committed: https://skia.googlesource.com/skia/+/d215a95882485026d176a81bf58871276b21c89c

TBR=bsalomon@google.com
# Skipping CQ checks because original CL landed less than 1 days ago.
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true

Review-Url: https://codereview.chromium.org/1954103002

include/gpu/GrDrawContext.h
src/gpu/SkGpuDevice.cpp
src/image/SkSurface_Gpu.cpp

index 699bf49a2a5cd90ae2a820d9638e8171a23cc834..7bb9aafc78127252680ee0c88ead0ac79617ae5a 100644 (file)
@@ -273,7 +273,6 @@ public:
      */
     void drawPathBatch(const GrPipelineBuilder&, GrDrawPathBatchBase*);
 
-    const GrSurfaceDesc& desc() const { return fRenderTarget->desc(); }
     int width() const { return fRenderTarget->width(); }
     int height() const { return fRenderTarget->height(); }
     int numColorSamples() const { return fRenderTarget->numColorSamples(); }
index 54ed413549d8ec83cf5c091fb28d4c7f87fa0206..98da472581bbba469d47668b346e1a47038bac07 100644 (file)
@@ -744,13 +744,13 @@ static int determine_tile_size(const SkIRect& src, int maxTileSize) {
 
 // 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();
@@ -783,8 +783,7 @@ bool SkGpuDevice::shouldTileImageID(uint32_t imageID, const SkIRect& imageRect,
     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;
@@ -812,8 +811,7 @@ bool SkGpuDevice::shouldTileImageID(uint32_t imageID, const SkIRect& imageRect,
 
     // 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) *
@@ -1775,7 +1773,7 @@ sk_sp<SkSurface> SkGpuDevice::makeSurface(const SkImageInfo& info, const SkSurfa
     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);
 }
 
@@ -1818,7 +1816,7 @@ bool SkGpuDevice::EXPERIMENTAL_drawPicture(SkCanvas* mainCanvas, const SkPicture
                                       initialMatrix,
                                       clipBounds,
                                       &atlasedNeedRendering, &atlasedRecycled,
-                                      fDrawContext->numColorSamples());
+                                      fRenderTarget->numColorSamples());
 
     GrLayerHoister::DrawLayersToAtlas(fContext, atlasedNeedRendering);
 
@@ -1830,7 +1828,7 @@ bool SkGpuDevice::EXPERIMENTAL_drawPicture(SkCanvas* mainCanvas, const SkPicture
                                       initialMatrix,
                                       clipBounds,
                                       &needRendering, &recycled,
-                                      fDrawContext->numColorSamples());
+                                      fRenderTarget->numColorSamples());
 
     GrLayerHoister::DrawLayers(fContext, needRendering);
 
index 1e4bd87661a1a0ec10562ec8f86e6fc216b51dfd..110d614d9b311dbee70ffc179ade7719f94eac97 100644 (file)
@@ -68,7 +68,8 @@ SkCanvas* SkSurface_Gpu::onNewCanvas() {
 }
 
 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,
@@ -84,7 +85,7 @@ sk_sp<SkImage> SkSurface_Gpu::onNewImageSnapshot(SkBudgeted budgeted, ForceCopyM
     // 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));