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 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
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 void SkGpuDevice::drawBitmapAsSprite(const SkDraw& draw, const SkBitmap& bitmap, | |
reed1
2016/03/21 20:41:35
// Want to ensure that we always have a texture-ba
robertphillips
2016/03/21 21:32:40
Done.
| |
224 int x, int y, const SkPaint& paint) { | |
225 if (bitmap.getTexture()) { | |
226 INHERITED::drawBitmapAsSprite(draw, bitmap, x, y, paint); | |
227 return; | |
228 } | |
229 | |
230 SkAutoLockPixels alp(bitmap, !bitmap.getTexture()); | |
231 if (!bitmap.getTexture() && !bitmap.readyToDraw()) { | |
232 return; | |
233 } | |
234 | |
235 GrTexture* texture; | |
236 // draw sprite neither filters nor tiles. | |
237 AutoBitmapTexture abt(fContext, bitmap, GrTextureParams::ClampNoFilter(), &t exture); | |
238 if (!texture) { | |
239 return; | |
240 } | |
241 | |
242 SkBitmap newBitmap; | |
243 | |
244 GrWrapTextureInBitmap(texture, texture->width(), texture->height(), | |
245 bitmap.isOpaque(), &newBitmap); | |
246 | |
247 INHERITED::drawBitmapAsSprite(draw, newBitmap, x, y, paint); | |
248 } | |
249 | |
223 /////////////////////////////////////////////////////////////////////////////// | 250 /////////////////////////////////////////////////////////////////////////////// |
224 | 251 |
225 bool SkGpuDevice::onReadPixels(const SkImageInfo& dstInfo, void* dstPixels, size _t dstRowBytes, | 252 bool SkGpuDevice::onReadPixels(const SkImageInfo& dstInfo, void* dstPixels, size _t dstRowBytes, |
226 int x, int y) { | 253 int x, int y) { |
227 ASSERT_SINGLE_OWNER | 254 ASSERT_SINGLE_OWNER |
228 | 255 |
229 // TODO: teach fRenderTarget to take ImageInfo directly to specify the src p ixels | 256 // TODO: teach fRenderTarget to take ImageInfo directly to specify the src p ixels |
230 GrPixelConfig config = SkImageInfo2GrPixelConfig(dstInfo); | 257 GrPixelConfig config = SkImageInfo2GrPixelConfig(dstInfo); |
231 if (kUnknown_GrPixelConfig == config) { | 258 if (kUnknown_GrPixelConfig == config) { |
232 return false; | 259 return false; |
(...skipping 1649 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1882 } | 1909 } |
1883 | 1910 |
1884 SkImageFilter::Cache* SkGpuDevice::getImageFilterCache() { | 1911 SkImageFilter::Cache* SkGpuDevice::getImageFilterCache() { |
1885 ASSERT_SINGLE_OWNER | 1912 ASSERT_SINGLE_OWNER |
1886 // We always return a transient cache, so it is freed after each | 1913 // We always return a transient cache, so it is freed after each |
1887 // filter traversal. | 1914 // filter traversal. |
1888 return SkGpuDevice::NewImageFilterCache(); | 1915 return SkGpuDevice::NewImageFilterCache(); |
1889 } | 1916 } |
1890 | 1917 |
1891 #endif | 1918 #endif |
OLD | NEW |