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

Unified Diff: src/core/SkSpecialSurface.cpp

Issue 1925313002: Tighten up SkSpecialSurface factory functions (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 8 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/core/SkSpecialSurface.h ('k') | tests/ImageFilterTest.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkSpecialSurface.cpp
diff --git a/src/core/SkSpecialSurface.cpp b/src/core/SkSpecialSurface.cpp
index 2973aa1f9b98f5eeaf50f1949f552d0267d3ac69..eeefb2afa8897dac48f391c99afc153623d41533 100644
--- a/src/core/SkSpecialSurface.cpp
+++ b/src/core/SkSpecialSurface.cpp
@@ -113,6 +113,7 @@ sk_sp<SkSpecialSurface> SkSpecialSurface::MakeRaster(const SkImageInfo& info,
class SkSpecialSurface_Gpu : public SkSpecialSurface_Base {
public:
SkSpecialSurface_Gpu(sk_sp<GrTexture> texture,
+ int width, int height,
const SkIRect& subset,
const SkSurfaceProps* props)
: INHERITED(subset, props)
@@ -120,13 +121,14 @@ public:
SkASSERT(fTexture->asRenderTarget());
- SkAutoTUnref<SkGpuDevice> device(SkGpuDevice::Create(fTexture->asRenderTarget(), props,
- SkGpuDevice::kUninit_InitContents));
+ sk_sp<SkGpuDevice> device(SkGpuDevice::Create(fTexture->asRenderTarget(), width, height,
+ props,
+ SkGpuDevice::kUninit_InitContents));
if (!device) {
return;
}
- fCanvas.reset(new SkCanvas(device));
+ fCanvas.reset(new SkCanvas(device.get()));
fCanvas->clipRect(SkRect::Make(subset));
}
@@ -146,31 +148,27 @@ private:
typedef SkSpecialSurface_Base INHERITED;
};
-sk_sp<SkSpecialSurface> SkSpecialSurface::MakeFromTexture(const SkIRect& subset,
- sk_sp<GrTexture> texture,
- const SkSurfaceProps* props) {
- if (!texture->asRenderTarget()) {
- return nullptr;
- }
-
- return sk_make_sp<SkSpecialSurface_Gpu>(std::move(texture), subset, props);
-}
-
sk_sp<SkSpecialSurface> SkSpecialSurface::MakeRenderTarget(GrContext* context,
- const GrSurfaceDesc& desc,
- const SkSurfaceProps* props) {
- if (!context || !SkToBool(desc.fFlags & kRenderTarget_GrSurfaceFlag)) {
+ int width, int height,
+ GrPixelConfig config) {
+ if (!context) {
return nullptr;
}
- sk_sp<GrTexture> temp(context->textureProvider()->createApproxTexture(desc));
- if (!temp) {
+ GrSurfaceDesc desc;
+ desc.fFlags = kRenderTarget_GrSurfaceFlag;
+ desc.fWidth = width;
+ desc.fHeight = height;
+ desc.fConfig = config;
+
+ sk_sp<GrTexture> tex(context->textureProvider()->createApproxTexture(desc));
+ if (!tex) {
return nullptr;
}
- const SkIRect subset = SkIRect::MakeWH(desc.fWidth, desc.fHeight);
+ const SkIRect subset = SkIRect::MakeWH(width, height);
- return sk_make_sp<SkSpecialSurface_Gpu>(std::move(temp), subset, props);
+ return sk_make_sp<SkSpecialSurface_Gpu>(std::move(tex), width, height, subset, nullptr);
}
#endif
« no previous file with comments | « src/core/SkSpecialSurface.h ('k') | tests/ImageFilterTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698