| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 Google Inc. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 6 */ | 6 */ |
| 7 | 7 |
| 8 #include "SkGpuDevice.h" | 8 #include "SkGpuDevice.h" |
| 9 | 9 |
| 10 #include "GrBlurUtils.h" | 10 #include "GrBlurUtils.h" |
| (...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 219 } | 219 } |
| 220 SkASSERT(nullptr != texture->asRenderTarget()); | 220 SkASSERT(nullptr != texture->asRenderTarget()); |
| 221 return texture->asRenderTarget(); | 221 return texture->asRenderTarget(); |
| 222 } | 222 } |
| 223 | 223 |
| 224 // This method ensures that we always have a texture-backed "bitmap" when we fin
ally | 224 // This method ensures that we always have a texture-backed "bitmap" when we fin
ally |
| 225 // call through to the base impl so that the image filtering code will take the | 225 // call through to the base impl so that the image filtering code will take the |
| 226 // gpu-specific paths. This mirrors SkCanvas::internalDrawDevice (the other | 226 // gpu-specific paths. This mirrors SkCanvas::internalDrawDevice (the other |
| 227 // use of SkImageFilter::filterImage) in that the source and dest will have | 227 // use of SkImageFilter::filterImage) in that the source and dest will have |
| 228 // homogenous backing (e.g., raster or gpu). | 228 // homogenous backing (e.g., raster or gpu). |
| 229 void SkGpuDevice::drawBitmapAsSpriteWithImageFilter(const SkDraw& draw, const Sk
Bitmap& bitmap, | 229 void SkGpuDevice::drawSpriteWithFilter(const SkDraw& draw, const SkBitmap& bitma
p, |
| 230 int x, int y, const SkPaint&
paint) { | 230 int x, int y, const SkPaint& paint) { |
| 231 if (bitmap.getTexture()) { | 231 if (bitmap.getTexture()) { |
| 232 INHERITED::drawBitmapAsSpriteWithImageFilter(draw, bitmap, x, y, paint); | 232 INHERITED::drawSpriteWithFilter(draw, bitmap, x, y, paint); |
| 233 return; | 233 return; |
| 234 } | 234 } |
| 235 | 235 |
| 236 SkAutoLockPixels alp(bitmap, !bitmap.getTexture()); | 236 SkAutoLockPixels alp(bitmap, !bitmap.getTexture()); |
| 237 if (!bitmap.getTexture() && !bitmap.readyToDraw()) { | 237 if (!bitmap.getTexture() && !bitmap.readyToDraw()) { |
| 238 return; | 238 return; |
| 239 } | 239 } |
| 240 | 240 |
| 241 GrTexture* texture; | 241 GrTexture* texture; |
| 242 // draw sprite neither filters nor tiles. | 242 // draw sprite neither filters nor tiles. |
| 243 AutoBitmapTexture abt(fContext, bitmap, GrTextureParams::ClampNoFilter(), &t
exture); | 243 AutoBitmapTexture abt(fContext, bitmap, GrTextureParams::ClampNoFilter(), &t
exture); |
| 244 if (!texture) { | 244 if (!texture) { |
| 245 return; | 245 return; |
| 246 } | 246 } |
| 247 | 247 |
| 248 SkBitmap newBitmap; | 248 SkBitmap newBitmap; |
| 249 | 249 |
| 250 GrWrapTextureInBitmap(texture, texture->width(), texture->height(), | 250 GrWrapTextureInBitmap(texture, texture->width(), texture->height(), |
| 251 bitmap.isOpaque(), &newBitmap); | 251 bitmap.isOpaque(), &newBitmap); |
| 252 | 252 |
| 253 INHERITED::drawBitmapAsSpriteWithImageFilter(draw, newBitmap, x, y, paint); | 253 INHERITED::drawSpriteWithFilter(draw, newBitmap, x, y, paint); |
| 254 } | 254 } |
| 255 | 255 |
| 256 /////////////////////////////////////////////////////////////////////////////// | 256 /////////////////////////////////////////////////////////////////////////////// |
| 257 | 257 |
| 258 bool SkGpuDevice::onReadPixels(const SkImageInfo& dstInfo, void* dstPixels, size
_t dstRowBytes, | 258 bool SkGpuDevice::onReadPixels(const SkImageInfo& dstInfo, void* dstPixels, size
_t dstRowBytes, |
| 259 int x, int y) { | 259 int x, int y) { |
| 260 ASSERT_SINGLE_OWNER | 260 ASSERT_SINGLE_OWNER |
| 261 | 261 |
| 262 // TODO: teach fRenderTarget to take ImageInfo directly to specify the src p
ixels | 262 // TODO: teach fRenderTarget to take ImageInfo directly to specify the src p
ixels |
| 263 GrPixelConfig config = SkImageInfo2GrPixelConfig(dstInfo, *fContext->caps())
; | 263 GrPixelConfig config = SkImageInfo2GrPixelConfig(dstInfo, *fContext->caps())
; |
| (...skipping 1651 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1915 } | 1915 } |
| 1916 | 1916 |
| 1917 SkImageFilter::Cache* SkGpuDevice::getImageFilterCache() { | 1917 SkImageFilter::Cache* SkGpuDevice::getImageFilterCache() { |
| 1918 ASSERT_SINGLE_OWNER | 1918 ASSERT_SINGLE_OWNER |
| 1919 // We always return a transient cache, so it is freed after each | 1919 // We always return a transient cache, so it is freed after each |
| 1920 // filter traversal. | 1920 // filter traversal. |
| 1921 return SkGpuDevice::NewImageFilterCache(); | 1921 return SkGpuDevice::NewImageFilterCache(); |
| 1922 } | 1922 } |
| 1923 | 1923 |
| 1924 #endif | 1924 #endif |
| OLD | NEW |