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

Side by Side Diff: src/gpu/SkGpuDevice.cpp

Issue 1785643003: Switch SkBlurImageFilter over to new onFilterImage interface (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Clean up Created 4 years, 9 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 unified diff | Download patch
« src/effects/SkBlurImageFilter.cpp ('K') | « src/gpu/SkGpuDevice.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
213 desc.fTextureStorageAllocator = textureStorageAllocator; 213 desc.fTextureStorageAllocator = textureStorageAllocator;
214 desc.fIsMipMapped = false; 214 desc.fIsMipMapped = false;
215 GrTexture* texture = context->textureProvider()->createTexture(desc, budgete d, nullptr, 0); 215 GrTexture* texture = context->textureProvider()->createTexture(desc, budgete d, nullptr, 0);
216 if (nullptr == texture) { 216 if (nullptr == texture) {
217 return nullptr; 217 return nullptr;
218 } 218 }
219 SkASSERT(nullptr != texture->asRenderTarget()); 219 SkASSERT(nullptr != texture->asRenderTarget());
220 return texture->asRenderTarget(); 220 return texture->asRenderTarget();
221 } 221 }
222 222
223 // This method ensures that we always have a texture-backed "bitmap" when we fin ally
224 // call through to the base impl so that the image filtering code will take the
225 // gpu-specific paths. This mirrors SkCanvas::internalDrawDevice (the other
226 // use of SkImageFilter::filterImage) in that the source and dest will have
227 // homogenous backing (e.g., raster or gpu).
228 void SkGpuDevice::drawBitmapAsSprite(const SkDraw& draw, const SkBitmap& bitmap,
229 int x, int y, const SkPaint& paint) {
230 if (bitmap.getTexture()) {
231 INHERITED::drawBitmapAsSprite(draw, bitmap, x, y, paint);
232 return;
233 }
234
235 SkAutoLockPixels alp(bitmap, !bitmap.getTexture());
236 if (!bitmap.getTexture() && !bitmap.readyToDraw()) {
237 return;
238 }
239
240 GrTexture* texture;
241 // draw sprite neither filters nor tiles.
242 AutoBitmapTexture abt(fContext, bitmap, GrTextureParams::ClampNoFilter(), &t exture);
243 if (!texture) {
244 return;
245 }
246
247 SkBitmap newBitmap;
248
249 GrWrapTextureInBitmap(texture, texture->width(), texture->height(),
250 bitmap.isOpaque(), &newBitmap);
251
252 INHERITED::drawBitmapAsSprite(draw, newBitmap, x, y, paint);
253 }
254
223 /////////////////////////////////////////////////////////////////////////////// 255 ///////////////////////////////////////////////////////////////////////////////
224 256
225 bool SkGpuDevice::onReadPixels(const SkImageInfo& dstInfo, void* dstPixels, size _t dstRowBytes, 257 bool SkGpuDevice::onReadPixels(const SkImageInfo& dstInfo, void* dstPixels, size _t dstRowBytes,
226 int x, int y) { 258 int x, int y) {
227 ASSERT_SINGLE_OWNER 259 ASSERT_SINGLE_OWNER
228 260
229 // TODO: teach fRenderTarget to take ImageInfo directly to specify the src p ixels 261 // TODO: teach fRenderTarget to take ImageInfo directly to specify the src p ixels
230 GrPixelConfig config = SkImageInfo2GrPixelConfig(dstInfo); 262 GrPixelConfig config = SkImageInfo2GrPixelConfig(dstInfo);
231 if (kUnknown_GrPixelConfig == config) { 263 if (kUnknown_GrPixelConfig == config) {
232 return false; 264 return false;
(...skipping 1649 matching lines...) Expand 10 before | Expand all | Expand 10 after
1882 } 1914 }
1883 1915
1884 SkImageFilter::Cache* SkGpuDevice::getImageFilterCache() { 1916 SkImageFilter::Cache* SkGpuDevice::getImageFilterCache() {
1885 ASSERT_SINGLE_OWNER 1917 ASSERT_SINGLE_OWNER
1886 // We always return a transient cache, so it is freed after each 1918 // We always return a transient cache, so it is freed after each
1887 // filter traversal. 1919 // filter traversal.
1888 return SkGpuDevice::NewImageFilterCache(); 1920 return SkGpuDevice::NewImageFilterCache();
1889 } 1921 }
1890 1922
1891 #endif 1923 #endif
OLDNEW
« src/effects/SkBlurImageFilter.cpp ('K') | « src/gpu/SkGpuDevice.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698