diff options
Diffstat (limited to 'src/gpu')
-rw-r--r-- | src/gpu/SkGpuDevice.cpp | 34 | ||||
-rw-r--r-- | src/gpu/SkGpuDevice.h | 13 |
2 files changed, 15 insertions, 32 deletions
diff --git a/src/gpu/SkGpuDevice.cpp b/src/gpu/SkGpuDevice.cpp index 021cfba106..38a22e69f5 100644 --- a/src/gpu/SkGpuDevice.cpp +++ b/src/gpu/SkGpuDevice.cpp @@ -121,15 +121,10 @@ public: /////////////////////////////////////////////////////////////////////////////// SkGpuDevice* SkGpuDevice::Create(GrRenderTarget* rt, const SkSurfaceProps* props, unsigned flags) { - return SkGpuDevice::Create(rt, rt->width(), rt->height(), props, flags); -} - -SkGpuDevice* SkGpuDevice::Create(GrRenderTarget* rt, int width, int height, - const SkSurfaceProps* props, unsigned flags) { if (!rt || rt->wasDestroyed()) { return NULL; } - return SkNEW_ARGS(SkGpuDevice, (rt, width, height, props, flags)); + return SkNEW_ARGS(SkGpuDevice, (rt, props, flags)); } static SkDeviceProperties surfaceprops_to_deviceprops(const SkSurfaceProps* props) { @@ -148,8 +143,7 @@ static SkSurfaceProps copy_or_default_props(const SkSurfaceProps* props) { } } -SkGpuDevice::SkGpuDevice(GrRenderTarget* rt, int width, int height, - const SkSurfaceProps* props, unsigned flags) +SkGpuDevice::SkGpuDevice(GrRenderTarget* rt, const SkSurfaceProps* props, unsigned flags) : INHERITED(surfaceprops_to_deviceprops(props)) , fSurfaceProps(copy_or_default_props(props)) { @@ -160,7 +154,7 @@ SkGpuDevice::SkGpuDevice(GrRenderTarget* rt, int width, int height, fRenderTarget = SkRef(rt); - SkImageInfo info = rt->surfacePriv().info().makeWH(width, height); + SkImageInfo info = rt->surfacePriv().info(); SkPixelRef* pr = SkNEW_ARGS(SkGrPixelRef, (info, rt)); fLegacyBitmap.setInfo(info); fLegacyBitmap.setPixelRef(pr)->unref(); @@ -217,7 +211,7 @@ SkGpuDevice* SkGpuDevice::Create(GrContext* context, SkSurface::Budgeted budgete return NULL; } - return SkNEW_ARGS(SkGpuDevice, (rt, info.width(), info.height(), props, flags)); + return SkNEW_ARGS(SkGpuDevice, (rt, props, flags)); } SkGpuDevice::~SkGpuDevice() { @@ -742,9 +736,9 @@ GrTexture* create_mask_GPU(GrContext* context, return mask; } -SkBitmap wrap_texture(GrTexture* texture, int width, int height) { +SkBitmap wrap_texture(GrTexture* texture) { SkBitmap result; - result.setInfo(SkImageInfo::MakeN32Premul(width, height)); + result.setInfo(texture->surfacePriv().info()); result.setPixelRef(SkNEW_ARGS(SkGrPixelRef, (result.info(), texture)))->unref(); return result; } @@ -1480,7 +1474,6 @@ void SkGpuDevice::internalDrawBitmap(const SkBitmap& bitmap, } bool SkGpuDevice::filterTexture(GrContext* context, GrTexture* texture, - int width, int height, const SkImageFilter* filter, const SkImageFilter::Context& ctx, SkBitmap* result, SkIPoint* offset) { @@ -1491,8 +1484,7 @@ bool SkGpuDevice::filterTexture(GrContext* context, GrTexture* texture, SkDeviceImageFilterProxy proxy(this, SkSurfaceProps(0, getLeakyProperties().pixelGeometry())); if (filter->canFilterImageGPU()) { - return filter->filterImageGPU(&proxy, wrap_texture(texture, width, height), - ctx, result, offset); + return filter->filterImageGPU(&proxy, wrap_texture(texture), ctx, result, offset); } else { return false; } @@ -1531,7 +1523,7 @@ void SkGpuDevice::drawSprite(const SkDraw& draw, const SkBitmap& bitmap, // This cache is transient, and is freed (along with all its contained // textures) when it goes out of scope. SkImageFilter::Context ctx(matrix, clipBounds, cache); - if (this->filterTexture(fContext, texture, w, h, filter, ctx, &filteredBitmap, + if (this->filterTexture(fContext, texture, filter, ctx, &filteredBitmap, &offset)) { texture = (GrTexture*) filteredBitmap.getTexture(); w = filteredBitmap.width(); @@ -1645,8 +1637,8 @@ void SkGpuDevice::drawDevice(const SkDraw& draw, SkBaseDevice* device, // textures) when it goes out of scope. SkAutoTUnref<SkImageFilter::Cache> cache(getImageFilterCache()); SkImageFilter::Context ctx(matrix, clipBounds, cache); - if (this->filterTexture(fContext, devTex, device->width(), device->height(), - filter, ctx, &filteredBitmap, &offset)) { + if (this->filterTexture(fContext, devTex, filter, ctx, &filteredBitmap, + &offset)) { devTex = filteredBitmap.getTexture(); w = filteredBitmap.width(); h = filteredBitmap.height(); @@ -1699,8 +1691,7 @@ bool SkGpuDevice::filterImage(const SkImageFilter* filter, const SkBitmap& src, // must be pushed upstack. AutoBitmapTexture abt(fContext, src, NULL, &texture); - return this->filterTexture(fContext, texture, src.width(), src.height(), - filter, ctx, result, offset); + return this->filterTexture(fContext, texture, filter, ctx, result, offset); } /////////////////////////////////////////////////////////////////////////////// @@ -1910,8 +1901,7 @@ SkBaseDevice* SkGpuDevice::onCreateDevice(const CreateInfo& cinfo, const SkPaint if (texture) { SkSurfaceProps props(fSurfaceProps.flags(), cinfo.fPixelGeometry); - return SkGpuDevice::Create( - texture->asRenderTarget(), cinfo.fInfo.width(), cinfo.fInfo.height(), &props, flags); + return SkGpuDevice::Create(texture->asRenderTarget(), &props, flags); } else { SkErrorInternals::SetError( kInternalError_SkError, "---- failed to create compatible device texture [%d %d]\n", diff --git a/src/gpu/SkGpuDevice.h b/src/gpu/SkGpuDevice.h index 999a698ded..ad0c2d63f0 100644 --- a/src/gpu/SkGpuDevice.h +++ b/src/gpu/SkGpuDevice.h @@ -41,13 +41,6 @@ public: static SkGpuDevice* Create(GrRenderTarget* target, const SkSurfaceProps*, unsigned flags = 0); /** - * Creates an SkGpuDevice from a GrRenderTarget whose texture width/height is - * different than its actual width/height (e.g., approx-match scratch texture). - */ - static SkGpuDevice* Create(GrRenderTarget* target, int width, int height, - const SkSurfaceProps*, unsigned flags = 0); - - /** * New device that will create an offscreen renderTarget based on the ImageInfo and * sampleCount. The Budgeted param controls whether the device's backing store counts against * the resource cache budget. On failure, returns NULL. @@ -74,7 +67,7 @@ public: GrRenderTarget* accessRenderTarget() override; SkImageInfo imageInfo() const override { - return fLegacyBitmap.info(); + return fRenderTarget ? fRenderTarget->surfacePriv().info() : SkImageInfo::MakeUnknown(); } const SkSurfaceProps& surfaceProps() const { return fSurfaceProps; } @@ -128,7 +121,7 @@ public: const SkImageFilter::Context&, SkBitmap*, SkIPoint*) override; - bool filterTexture(GrContext*, GrTexture*, int width, int height, const SkImageFilter*, + bool filterTexture(GrContext*, GrTexture*, const SkImageFilter*, const SkImageFilter::Context&, SkBitmap* result, SkIPoint* offset); @@ -154,7 +147,7 @@ private: SkBitmap fLegacyBitmap; bool fNeedClear; - SkGpuDevice(GrRenderTarget*, int width, int height, const SkSurfaceProps*, unsigned flags); + SkGpuDevice(GrRenderTarget*, const SkSurfaceProps*, unsigned flags); SkBaseDevice* onCreateDevice(const CreateInfo&, const SkPaint*) override; |