| Index: src/gpu/SkGpuDevice.cpp
|
| diff --git a/src/gpu/SkGpuDevice.cpp b/src/gpu/SkGpuDevice.cpp
|
| index 38a22e69f5ae87a263f31f362999dfcb42becf65..a3f26149e8d1eceabd8dc07ca99a9bf6fadce5ee 100644
|
| --- a/src/gpu/SkGpuDevice.cpp
|
| +++ b/src/gpu/SkGpuDevice.cpp
|
| @@ -121,10 +121,15 @@ 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, props, flags));
|
| + return SkNEW_ARGS(SkGpuDevice, (rt, width, height, props, flags));
|
| }
|
|
|
| static SkDeviceProperties surfaceprops_to_deviceprops(const SkSurfaceProps* props) {
|
| @@ -143,7 +148,8 @@ static SkSurfaceProps copy_or_default_props(const SkSurfaceProps* props) {
|
| }
|
| }
|
|
|
| -SkGpuDevice::SkGpuDevice(GrRenderTarget* rt, const SkSurfaceProps* props, unsigned flags)
|
| +SkGpuDevice::SkGpuDevice(GrRenderTarget* rt, int width, int height,
|
| + const SkSurfaceProps* props, unsigned flags)
|
| : INHERITED(surfaceprops_to_deviceprops(props))
|
| , fSurfaceProps(copy_or_default_props(props))
|
| {
|
| @@ -154,7 +160,7 @@ SkGpuDevice::SkGpuDevice(GrRenderTarget* rt, const SkSurfaceProps* props, unsign
|
|
|
| fRenderTarget = SkRef(rt);
|
|
|
| - SkImageInfo info = rt->surfacePriv().info();
|
| + SkImageInfo info = rt->surfacePriv().info().makeWH(width, height);
|
| SkPixelRef* pr = SkNEW_ARGS(SkGrPixelRef, (info, rt));
|
| fLegacyBitmap.setInfo(info);
|
| fLegacyBitmap.setPixelRef(pr)->unref();
|
| @@ -211,7 +217,7 @@ SkGpuDevice* SkGpuDevice::Create(GrContext* context, SkSurface::Budgeted budgete
|
| return NULL;
|
| }
|
|
|
| - return SkNEW_ARGS(SkGpuDevice, (rt, props, flags));
|
| + return SkNEW_ARGS(SkGpuDevice, (rt, info.width(), info.height(), props, flags));
|
| }
|
|
|
| SkGpuDevice::~SkGpuDevice() {
|
| @@ -736,9 +742,9 @@ GrTexture* create_mask_GPU(GrContext* context,
|
| return mask;
|
| }
|
|
|
| -SkBitmap wrap_texture(GrTexture* texture) {
|
| +SkBitmap wrap_texture(GrTexture* texture, int width, int height) {
|
| SkBitmap result;
|
| - result.setInfo(texture->surfacePriv().info());
|
| + result.setInfo(SkImageInfo::MakeN32Premul(width, height));
|
| result.setPixelRef(SkNEW_ARGS(SkGrPixelRef, (result.info(), texture)))->unref();
|
| return result;
|
| }
|
| @@ -1097,11 +1103,14 @@ static bool needs_texture_domain(const SkBitmap& bitmap,
|
| const SkMatrix& contextMatrix,
|
| bool bicubic) {
|
| bool needsTextureDomain = false;
|
| + GrTexture* tex = bitmap.getTexture();
|
| + int width = tex ? tex->width() : bitmap.width();
|
| + int height = tex ? tex->height() : bitmap.height();
|
|
|
| if (bicubic || params.filterMode() != GrTextureParams::kNone_FilterMode) {
|
| // Need texture domain if drawing a sub rect
|
| - needsTextureDomain = srcRect.width() < bitmap.width() ||
|
| - srcRect.height() < bitmap.height();
|
| + needsTextureDomain = srcRect.width() < width ||
|
| + srcRect.height() < height;
|
| if (!bicubic && needsTextureDomain && contextMatrix.rectStaysRect()) {
|
| // sampling is axis-aligned
|
| SkRect transformedRect;
|
| @@ -1136,15 +1145,17 @@ void SkGpuDevice::drawBitmapCommon(const SkDraw& draw,
|
| dstSize.fWidth = w;
|
| dstSize.fHeight = h;
|
| srcRect.set(0, 0, w, h);
|
| - flags = (SkCanvas::DrawBitmapRectFlags) (flags | SkCanvas::kBleed_DrawBitmapRectFlag);
|
| } else {
|
| SkASSERT(dstSizePtr);
|
| srcRect = *srcRectPtr;
|
| dstSize = *dstSizePtr;
|
| - if (srcRect.fLeft <= 0 && srcRect.fTop <= 0 &&
|
| - srcRect.fRight >= bitmap.width() && srcRect.fBottom >= bitmap.height()) {
|
| - flags = (SkCanvas::DrawBitmapRectFlags) (flags | SkCanvas::kBleed_DrawBitmapRectFlag);
|
| - }
|
| + }
|
| + GrTexture* tex = bitmap.getTexture();
|
| + int width = tex ? tex->width() : bitmap.width();
|
| + int height = tex ? tex->height() : bitmap.height();
|
| + if (srcRect.fLeft <= 0 && srcRect.fTop <= 0 &&
|
| + srcRect.fRight >= width && srcRect.fBottom >= height) {
|
| + flags = (SkCanvas::DrawBitmapRectFlags) (flags | SkCanvas::kBleed_DrawBitmapRectFlag);
|
| }
|
|
|
| // If the render target is not msaa and draw is antialiased, we call
|
| @@ -1474,6 +1485,7 @@ 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) {
|
| @@ -1484,7 +1496,8 @@ bool SkGpuDevice::filterTexture(GrContext* context, GrTexture* texture,
|
| SkDeviceImageFilterProxy proxy(this, SkSurfaceProps(0, getLeakyProperties().pixelGeometry()));
|
|
|
| if (filter->canFilterImageGPU()) {
|
| - return filter->filterImageGPU(&proxy, wrap_texture(texture), ctx, result, offset);
|
| + return filter->filterImageGPU(&proxy, wrap_texture(texture, width, height),
|
| + ctx, result, offset);
|
| } else {
|
| return false;
|
| }
|
| @@ -1523,7 +1536,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, filter, ctx, &filteredBitmap,
|
| + if (this->filterTexture(fContext, texture, w, h, filter, ctx, &filteredBitmap,
|
| &offset)) {
|
| texture = (GrTexture*) filteredBitmap.getTexture();
|
| w = filteredBitmap.width();
|
| @@ -1637,8 +1650,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, filter, ctx, &filteredBitmap,
|
| - &offset)) {
|
| + if (this->filterTexture(fContext, devTex, device->width(), device->height(),
|
| + filter, ctx, &filteredBitmap, &offset)) {
|
| devTex = filteredBitmap.getTexture();
|
| w = filteredBitmap.width();
|
| h = filteredBitmap.height();
|
| @@ -1691,7 +1704,8 @@ bool SkGpuDevice::filterImage(const SkImageFilter* filter, const SkBitmap& src,
|
| // must be pushed upstack.
|
| AutoBitmapTexture abt(fContext, src, NULL, &texture);
|
|
|
| - return this->filterTexture(fContext, texture, filter, ctx, result, offset);
|
| + return this->filterTexture(fContext, texture, src.width(), src.height(),
|
| + filter, ctx, result, offset);
|
| }
|
|
|
| ///////////////////////////////////////////////////////////////////////////////
|
| @@ -1901,7 +1915,8 @@ SkBaseDevice* SkGpuDevice::onCreateDevice(const CreateInfo& cinfo, const SkPaint
|
|
|
| if (texture) {
|
| SkSurfaceProps props(fSurfaceProps.flags(), cinfo.fPixelGeometry);
|
| - return SkGpuDevice::Create(texture->asRenderTarget(), &props, flags);
|
| + return SkGpuDevice::Create(
|
| + texture->asRenderTarget(), cinfo.fInfo.width(), cinfo.fInfo.height(), &props, flags);
|
| } else {
|
| SkErrorInternals::SetError( kInternalError_SkError,
|
| "---- failed to create compatible device texture [%d %d]\n",
|
|
|