Index: src/gpu/SkGpuDevice.cpp |
diff --git a/src/gpu/SkGpuDevice.cpp b/src/gpu/SkGpuDevice.cpp |
index a3f26149e8d1eceabd8dc07ca99a9bf6fadce5ee..38a22e69f5ae87a263f31f362999dfcb42becf65 100644 |
--- a/src/gpu/SkGpuDevice.cpp |
+++ b/src/gpu/SkGpuDevice.cpp |
@@ -121,15 +121,10 @@ |
/////////////////////////////////////////////////////////////////////////////// |
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 @@ |
} |
} |
-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 @@ |
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 @@ |
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 @@ |
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; |
} |
@@ -1103,14 +1097,11 @@ |
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() < width || |
- srcRect.height() < height; |
+ needsTextureDomain = srcRect.width() < bitmap.width() || |
+ srcRect.height() < bitmap.height(); |
if (!bicubic && needsTextureDomain && contextMatrix.rectStaysRect()) { |
// sampling is axis-aligned |
SkRect transformedRect; |
@@ -1145,17 +1136,15 @@ |
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; |
- } |
- 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 (srcRect.fLeft <= 0 && srcRect.fTop <= 0 && |
+ srcRect.fRight >= bitmap.width() && srcRect.fBottom >= bitmap.height()) { |
+ flags = (SkCanvas::DrawBitmapRectFlags) (flags | SkCanvas::kBleed_DrawBitmapRectFlag); |
+ } |
} |
// If the render target is not msaa and draw is antialiased, we call |
@@ -1485,7 +1474,6 @@ |
} |
bool SkGpuDevice::filterTexture(GrContext* context, GrTexture* texture, |
- int width, int height, |
const SkImageFilter* filter, |
const SkImageFilter::Context& ctx, |
SkBitmap* result, SkIPoint* offset) { |
@@ -1496,8 +1484,7 @@ |
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; |
} |
@@ -1536,7 +1523,7 @@ |
// 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(); |
@@ -1650,8 +1637,8 @@ |
// 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(); |
@@ -1704,8 +1691,7 @@ |
// 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); |
} |
/////////////////////////////////////////////////////////////////////////////// |
@@ -1915,8 +1901,7 @@ |
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", |