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 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
279 GrResource* resource = fTextureCache->find(resourceKey); | 279 GrResource* resource = fTextureCache->find(resourceKey); |
280 return static_cast<GrStencilBuffer*>(resource); | 280 return static_cast<GrStencilBuffer*>(resource); |
281 } | 281 } |
282 | 282 |
283 static void stretchImage(void* dst, | 283 static void stretchImage(void* dst, |
284 int dstW, | 284 int dstW, |
285 int dstH, | 285 int dstH, |
286 void* src, | 286 void* src, |
287 int srcW, | 287 int srcW, |
288 int srcH, | 288 int srcH, |
289 int bpp) { | 289 size_t bpp) { |
290 GrFixed dx = (srcW << 16) / dstW; | 290 GrFixed dx = (srcW << 16) / dstW; |
291 GrFixed dy = (srcH << 16) / dstH; | 291 GrFixed dy = (srcH << 16) / dstH; |
292 | 292 |
293 GrFixed y = dy >> 1; | 293 GrFixed y = dy >> 1; |
294 | 294 |
295 int dstXLimit = dstW*bpp; | 295 size_t dstXLimit = dstW*bpp; |
296 for (int j = 0; j < dstH; ++j) { | 296 for (int j = 0; j < dstH; ++j) { |
297 GrFixed x = dx >> 1; | 297 GrFixed x = dx >> 1; |
298 void* srcRow = (uint8_t*)src + (y>>16)*srcW*bpp; | 298 void* srcRow = (uint8_t*)src + (y>>16)*srcW*bpp; |
299 void* dstRow = (uint8_t*)dst + j*dstW*bpp; | 299 void* dstRow = (uint8_t*)dst + j*dstW*bpp; |
300 for (int i = 0; i < dstXLimit; i += bpp) { | 300 for (size_t i = 0; i < dstXLimit; i += bpp) { |
301 memcpy((uint8_t*) dstRow + i, | 301 memcpy((uint8_t*) dstRow + i, |
302 (uint8_t*) srcRow + (x>>16)*bpp, | 302 (uint8_t*) srcRow + (x>>16)*bpp, |
303 bpp); | 303 bpp); |
304 x += dx; | 304 x += dx; |
305 } | 305 } |
306 y += dy; | 306 y += dy; |
307 } | 307 } |
308 } | 308 } |
309 | 309 |
310 namespace { | 310 namespace { |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
367 } else { | 367 } else { |
368 // TODO: Our CPU stretch doesn't filter. But we create separate | 368 // TODO: Our CPU stretch doesn't filter. But we create separate |
369 // stretched textures when the texture params is either filtered or | 369 // stretched textures when the texture params is either filtered or |
370 // not. Either implement filtered stretch blit on CPU or just create | 370 // not. Either implement filtered stretch blit on CPU or just create |
371 // one when FBO case fails. | 371 // one when FBO case fails. |
372 | 372 |
373 rtDesc.fFlags = kNone_GrTextureFlags; | 373 rtDesc.fFlags = kNone_GrTextureFlags; |
374 // no longer need to clamp at min RT size. | 374 // no longer need to clamp at min RT size. |
375 rtDesc.fWidth = GrNextPow2(desc.fWidth); | 375 rtDesc.fWidth = GrNextPow2(desc.fWidth); |
376 rtDesc.fHeight = GrNextPow2(desc.fHeight); | 376 rtDesc.fHeight = GrNextPow2(desc.fHeight); |
377 int bpp = GrBytesPerPixel(desc.fConfig); | 377 size_t bpp = GrBytesPerPixel(desc.fConfig); |
378 SkAutoSMalloc<128*128*4> stretchedPixels(bpp * rtDesc.fWidth * rtDesc.fH
eight); | 378 SkAutoSMalloc<128*128*4> stretchedPixels(bpp * rtDesc.fWidth * rtDesc.fH
eight); |
379 stretchImage(stretchedPixels.get(), rtDesc.fWidth, rtDesc.fHeight, | 379 stretchImage(stretchedPixels.get(), rtDesc.fWidth, rtDesc.fHeight, |
380 srcData, desc.fWidth, desc.fHeight, bpp); | 380 srcData, desc.fWidth, desc.fHeight, bpp); |
381 | 381 |
382 size_t stretchedRowBytes = rtDesc.fWidth * bpp; | 382 size_t stretchedRowBytes = rtDesc.fWidth * bpp; |
383 | 383 |
384 SkDEBUGCODE(GrTexture* texture = )fGpu->createTexture(rtDesc, stretchedP
ixels.get(), | 384 SkDEBUGCODE(GrTexture* texture = )fGpu->createTexture(rtDesc, stretchedP
ixels.get(), |
385 stretchedRowBytes)
; | 385 stretchedRowBytes)
; |
386 SkASSERT(NULL != texture); | 386 SkASSERT(NULL != texture); |
387 } | 387 } |
(...skipping 1383 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1771 return NULL; | 1771 return NULL; |
1772 } | 1772 } |
1773 } | 1773 } |
1774 | 1774 |
1775 /////////////////////////////////////////////////////////////////////////////// | 1775 /////////////////////////////////////////////////////////////////////////////// |
1776 #if GR_CACHE_STATS | 1776 #if GR_CACHE_STATS |
1777 void GrContext::printCacheStats() const { | 1777 void GrContext::printCacheStats() const { |
1778 fTextureCache->printStats(); | 1778 fTextureCache->printStats(); |
1779 } | 1779 } |
1780 #endif | 1780 #endif |
OLD | NEW |