OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2011 Google Inc. | 3 * Copyright 2011 Google Inc. |
4 * | 4 * |
5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
7 */ | 7 */ |
8 | 8 |
9 | 9 |
10 #include "GrContext.h" | 10 #include "GrContext.h" |
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
261 | 261 |
262 GrStencilBuffer* GrContext::findStencilBuffer(int width, int height, | 262 GrStencilBuffer* GrContext::findStencilBuffer(int width, int height, |
263 int sampleCnt) { | 263 int sampleCnt) { |
264 GrResourceKey resourceKey = GrStencilBuffer::ComputeKey(width, | 264 GrResourceKey resourceKey = GrStencilBuffer::ComputeKey(width, |
265 height, | 265 height, |
266 sampleCnt); | 266 sampleCnt); |
267 GrCacheable* resource = fResourceCache->find(resourceKey); | 267 GrCacheable* resource = fResourceCache->find(resourceKey); |
268 return static_cast<GrStencilBuffer*>(resource); | 268 return static_cast<GrStencilBuffer*>(resource); |
269 } | 269 } |
270 | 270 |
271 static void stretchImage(void* dst, | 271 static void stretch_image(void* dst, |
272 int dstW, | 272 int dstW, |
273 int dstH, | 273 int dstH, |
274 void* src, | 274 void* src, |
275 int srcW, | 275 int srcW, |
276 int srcH, | 276 int srcH, |
277 size_t bpp) { | 277 size_t bpp) { |
278 SkFixed dx = (srcW << 16) / dstW; | 278 SkFixed dx = (srcW << 16) / dstW; |
279 SkFixed dy = (srcH << 16) / dstH; | 279 SkFixed dy = (srcH << 16) / dstH; |
280 | 280 |
281 SkFixed y = dy >> 1; | 281 SkFixed y = dy >> 1; |
282 | 282 |
283 size_t dstXLimit = dstW*bpp; | 283 size_t dstXLimit = dstW*bpp; |
284 for (int j = 0; j < dstH; ++j) { | 284 for (int j = 0; j < dstH; ++j) { |
285 SkFixed x = dx >> 1; | 285 SkFixed x = dx >> 1; |
286 void* srcRow = (uint8_t*)src + (y>>16)*srcW*bpp; | 286 void* srcRow = (uint8_t*)src + (y>>16)*srcW*bpp; |
287 void* dstRow = (uint8_t*)dst + j*dstW*bpp; | 287 void* dstRow = (uint8_t*)dst + j*dstW*bpp; |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
357 // stretched textures when the texture params is either filtered or | 357 // stretched textures when the texture params is either filtered or |
358 // not. Either implement filtered stretch blit on CPU or just create | 358 // not. Either implement filtered stretch blit on CPU or just create |
359 // one when FBO case fails. | 359 // one when FBO case fails. |
360 | 360 |
361 rtDesc.fFlags = kNone_GrTextureFlags; | 361 rtDesc.fFlags = kNone_GrTextureFlags; |
362 // no longer need to clamp at min RT size. | 362 // no longer need to clamp at min RT size. |
363 rtDesc.fWidth = GrNextPow2(desc.fWidth); | 363 rtDesc.fWidth = GrNextPow2(desc.fWidth); |
364 rtDesc.fHeight = GrNextPow2(desc.fHeight); | 364 rtDesc.fHeight = GrNextPow2(desc.fHeight); |
365 size_t bpp = GrBytesPerPixel(desc.fConfig); | 365 size_t bpp = GrBytesPerPixel(desc.fConfig); |
366 SkAutoSMalloc<128*128*4> stretchedPixels(bpp * rtDesc.fWidth * rtDesc.fH
eight); | 366 SkAutoSMalloc<128*128*4> stretchedPixels(bpp * rtDesc.fWidth * rtDesc.fH
eight); |
367 stretchImage(stretchedPixels.get(), rtDesc.fWidth, rtDesc.fHeight, | 367 stretch_image(stretchedPixels.get(), rtDesc.fWidth, rtDesc.fHeight, |
368 srcData, desc.fWidth, desc.fHeight, bpp); | 368 srcData, desc.fWidth, desc.fHeight, bpp); |
369 | 369 |
370 size_t stretchedRowBytes = rtDesc.fWidth * bpp; | 370 size_t stretchedRowBytes = rtDesc.fWidth * bpp; |
371 | 371 |
372 SkDEBUGCODE(GrTexture* texture = )fGpu->createTexture(rtDesc, stretchedP
ixels.get(), | 372 texture = fGpu->createTexture(rtDesc, stretchedPixels.get(), stretchedRo
wBytes); |
373 stretchedRowBytes)
; | |
374 SkASSERT(NULL != texture); | 373 SkASSERT(NULL != texture); |
375 } | 374 } |
376 | 375 |
377 return texture; | 376 return texture; |
378 } | 377 } |
379 | 378 |
380 GrTexture* GrContext::createTexture(const GrTextureParams* params, | 379 GrTexture* GrContext::createTexture(const GrTextureParams* params, |
381 const GrTextureDesc& desc, | 380 const GrTextureDesc& desc, |
382 const GrCacheID& cacheID, | 381 const GrCacheID& cacheID, |
383 void* srcData, | 382 void* srcData, |
(...skipping 1450 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1834 SkSafeRef(resource); | 1833 SkSafeRef(resource); |
1835 return resource; | 1834 return resource; |
1836 } | 1835 } |
1837 | 1836 |
1838 /////////////////////////////////////////////////////////////////////////////// | 1837 /////////////////////////////////////////////////////////////////////////////// |
1839 #if GR_CACHE_STATS | 1838 #if GR_CACHE_STATS |
1840 void GrContext::printCacheStats() const { | 1839 void GrContext::printCacheStats() const { |
1841 fResourceCache->printStats(); | 1840 fResourceCache->printStats(); |
1842 } | 1841 } |
1843 #endif | 1842 #endif |
OLD | NEW |