Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(361)

Unified Diff: src/image/SkImage_Gpu.cpp

Issue 1364443002: remove unused (by the outside) SkImage::newSurface, and simplify newImage -> newSubset (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/image/SkImage_Gpu.h ('k') | src/image/SkImage_Raster.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/image/SkImage_Gpu.cpp
diff --git a/src/image/SkImage_Gpu.cpp b/src/image/SkImage_Gpu.cpp
index 163e62e02df540362952e9b55be47d3284d886a7..1a63a0d6ba3cf51af625d616d77cb27de4c459fb 100644
--- a/src/image/SkImage_Gpu.cpp
+++ b/src/image/SkImage_Gpu.cpp
@@ -15,10 +15,9 @@
#include "SkPixelRef.h"
SkImage_Gpu::SkImage_Gpu(int w, int h, uint32_t uniqueID, SkAlphaType at, GrTexture* tex,
- int sampleCountForNewSurfaces, SkSurface::Budgeted budgeted)
+ SkSurface::Budgeted budgeted)
: INHERITED(w, h, uniqueID, nullptr)
, fTexture(SkRef(tex))
- , fSampleCountForNewSurfaces(sampleCountForNewSurfaces)
, fAlphaType(at)
, fBudgeted(budgeted)
, fAddedRasterVersionToCache(false)
@@ -30,19 +29,6 @@ SkImage_Gpu::~SkImage_Gpu() {
}
}
-SkSurface* SkImage_Gpu::onNewSurface(const SkImageInfo& info, const SkSurfaceProps& props) const {
- GrTexture* tex = this->getTexture();
- SkASSERT(tex);
- GrContext* ctx = tex->getContext();
- if (!ctx) {
- // the texture may have been abandoned, so we have to check
- return nullptr;
- }
- // TODO: Change signature of onNewSurface to take a budgeted param.
- const SkSurface::Budgeted budgeted = SkSurface::kNo_Budgeted;
- return SkSurface::NewRenderTarget(ctx, budgeted, info, fSampleCountForNewSurfaces, &props);
-}
-
extern void SkTextureImageApplyBudgetedDecision(SkImage* image) {
if (as_IB(image)->getTexture()) {
((SkImage_Gpu*)image)->applyBudgetDecision();
@@ -136,6 +122,22 @@ bool SkImage_Gpu::onReadPixels(const SkImageInfo& info, void* pixels, size_t row
return true;
}
+SkImage* SkImage_Gpu::onNewSubset(const SkIRect& subset) const {
+ GrContext* ctx = fTexture->getContext();
+ GrSurfaceDesc desc = fTexture->desc();
+ desc.fWidth = subset.width();
+ desc.fHeight = subset.height();
+
+ GrTexture* subTx = ctx->textureProvider()->createTexture(desc,
+ SkSurface::kYes_Budgeted == fBudgeted);
+ if (!subTx) {
+ return nullptr;
+ }
+ ctx->copySurface(subTx, fTexture, subset, SkIPoint::Make(0, 0));
+ return new SkImage_Gpu(desc.fWidth, desc.fHeight, kNeedNewImageUniqueID, fAlphaType, subTx,
+ fBudgeted);
+}
+
///////////////////////////////////////////////////////////////////////////////////////////////////
static SkImage* new_wrapped_texture_common(GrContext* ctx, const GrBackendTextureDesc& desc,
@@ -154,7 +156,7 @@ static SkImage* new_wrapped_texture_common(GrContext* ctx, const GrBackendTextur
}
const SkSurface::Budgeted budgeted = SkSurface::kNo_Budgeted;
- return new SkImage_Gpu(desc.fWidth, desc.fHeight, kNeedNewImageUniqueID, at, tex, 0, budgeted);
+ return new SkImage_Gpu(desc.fWidth, desc.fHeight, kNeedNewImageUniqueID, at, tex, budgeted);
}
SkImage* SkImage::NewFromTexture(GrContext* ctx, const GrBackendTextureDesc& desc, SkAlphaType at,
@@ -186,8 +188,7 @@ SkImage* SkImage::NewFromTextureCopy(GrContext* ctx, const GrBackendTextureDesc&
}
const SkSurface::Budgeted budgeted = SkSurface::kYes_Budgeted;
- const int sampleCount = 0; // todo: make this an explicit parameter to newSurface()?
- return new SkImage_Gpu(desc.fWidth, desc.fHeight, kNeedNewImageUniqueID, at, dst, sampleCount,
+ return new SkImage_Gpu(desc.fWidth, desc.fHeight, kNeedNewImageUniqueID, at, dst,
budgeted);
}
@@ -267,7 +268,7 @@ SkImage* SkImage::NewFromYUVTexturesCopy(GrContext* ctx , SkYUVColorSpace colorS
drawContext->drawRect(dst->asRenderTarget(), GrClip::WideOpen(), paint, SkMatrix::I(), rect);
ctx->flushSurfaceWrites(dst);
return new SkImage_Gpu(dstDesc.fWidth, dstDesc.fHeight, kNeedNewImageUniqueID,
- kOpaque_SkAlphaType, dst, 0, budgeted);
+ kOpaque_SkAlphaType, dst, budgeted);
}
///////////////////////////////////////////////////////////////////////////////////////////////////
« no previous file with comments | « src/image/SkImage_Gpu.h ('k') | src/image/SkImage_Raster.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698