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

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

Issue 682223002: rename GrTextureDesc->GrSurfaceDesc, GrTextureFlags->GrSurfaceFlags (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: const Created 6 years, 1 month 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
« no previous file with comments | « src/gpu/GrClipMaskManager.cpp ('k') | src/gpu/GrDistanceFieldTextContext.cpp » ('j') | 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 /* 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 #include "GrContext.h" 9 #include "GrContext.h"
10 10
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after
254 if (fGpu->caps()->pathRenderingSupport() && renderTarget->getStencilBuffer() && 254 if (fGpu->caps()->pathRenderingSupport() && renderTarget->getStencilBuffer() &&
255 renderTarget->isMultisampled()) { 255 renderTarget->isMultisampled()) {
256 return GrStencilAndCoverTextContext::Create(this, leakyProperties); 256 return GrStencilAndCoverTextContext::Create(this, leakyProperties);
257 } 257 }
258 258
259 return GrDistanceFieldTextContext::Create(this, leakyProperties, enableDista nceFieldFonts); 259 return GrDistanceFieldTextContext::Create(this, leakyProperties, enableDista nceFieldFonts);
260 } 260 }
261 261
262 //////////////////////////////////////////////////////////////////////////////// 262 ////////////////////////////////////////////////////////////////////////////////
263 263
264 GrTexture* GrContext::findAndRefTexture(const GrTextureDesc& desc, 264 GrTexture* GrContext::findAndRefTexture(const GrSurfaceDesc& desc,
265 const GrCacheID& cacheID, 265 const GrCacheID& cacheID,
266 const GrTextureParams* params) { 266 const GrTextureParams* params) {
267 GrResourceKey resourceKey = GrTexturePriv::ComputeKey(fGpu, params, desc, ca cheID); 267 GrResourceKey resourceKey = GrTexturePriv::ComputeKey(fGpu, params, desc, ca cheID);
268 GrGpuResource* resource = fResourceCache->find(resourceKey); 268 GrGpuResource* resource = fResourceCache->find(resourceKey);
269 SkSafeRef(resource); 269 SkSafeRef(resource);
270 return static_cast<GrTexture*>(resource); 270 return static_cast<GrTexture*>(resource);
271 } 271 }
272 272
273 bool GrContext::isTextureInCache(const GrTextureDesc& desc, 273 bool GrContext::isTextureInCache(const GrSurfaceDesc& desc,
274 const GrCacheID& cacheID, 274 const GrCacheID& cacheID,
275 const GrTextureParams* params) const { 275 const GrTextureParams* params) const {
276 GrResourceKey resourceKey = GrTexturePriv::ComputeKey(fGpu, params, desc, ca cheID); 276 GrResourceKey resourceKey = GrTexturePriv::ComputeKey(fGpu, params, desc, ca cheID);
277 return fResourceCache->hasKey(resourceKey); 277 return fResourceCache->hasKey(resourceKey);
278 } 278 }
279 279
280 void GrContext::addStencilBuffer(GrStencilBuffer* sb) { 280 void GrContext::addStencilBuffer(GrStencilBuffer* sb) {
281 ASSERT_OWNED_RESOURCE(sb); 281 ASSERT_OWNED_RESOURCE(sb);
282 282
283 GrResourceKey resourceKey = GrStencilBuffer::ComputeKey(sb->width(), 283 GrResourceKey resourceKey = GrStencilBuffer::ComputeKey(sb->width(),
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
325 // position + local coordinate 325 // position + local coordinate
326 extern const GrVertexAttrib gVertexAttribs[] = { 326 extern const GrVertexAttrib gVertexAttribs[] = {
327 {kVec2f_GrVertexAttribType, 0, kPosition_GrVertexAttribBinding }, 327 {kVec2f_GrVertexAttribType, 0, kPosition_GrVertexAttribBinding },
328 {kVec2f_GrVertexAttribType, sizeof(SkPoint), kLocalCoord_GrVertexAttribBindi ng} 328 {kVec2f_GrVertexAttribType, sizeof(SkPoint), kLocalCoord_GrVertexAttribBindi ng}
329 }; 329 };
330 330
331 }; 331 };
332 332
333 // The desired texture is NPOT and tiled but that isn't supported by 333 // The desired texture is NPOT and tiled but that isn't supported by
334 // the current hardware. Resize the texture to be a POT 334 // the current hardware. Resize the texture to be a POT
335 GrTexture* GrContext::createResizedTexture(const GrTextureDesc& desc, 335 GrTexture* GrContext::createResizedTexture(const GrSurfaceDesc& desc,
336 const GrCacheID& cacheID, 336 const GrCacheID& cacheID,
337 const void* srcData, 337 const void* srcData,
338 size_t rowBytes, 338 size_t rowBytes,
339 bool filter) { 339 bool filter) {
340 SkAutoTUnref<GrTexture> clampedTexture(this->findAndRefTexture(desc, cacheID , NULL)); 340 SkAutoTUnref<GrTexture> clampedTexture(this->findAndRefTexture(desc, cacheID , NULL));
341 if (NULL == clampedTexture) { 341 if (NULL == clampedTexture) {
342 clampedTexture.reset(this->createTexture(NULL, desc, cacheID, srcData, r owBytes)); 342 clampedTexture.reset(this->createTexture(NULL, desc, cacheID, srcData, r owBytes));
343 343
344 if (NULL == clampedTexture) { 344 if (NULL == clampedTexture) {
345 return NULL; 345 return NULL;
346 } 346 }
347 } 347 }
348 348
349 GrTextureDesc rtDesc = desc; 349 GrSurfaceDesc rtDesc = desc;
350 rtDesc.fFlags = rtDesc.fFlags | 350 rtDesc.fFlags = rtDesc.fFlags |
351 kRenderTarget_GrTextureFlagBit | 351 kRenderTarget_GrSurfaceFlag |
352 kNoStencil_GrTextureFlagBit; 352 kNoStencil_GrSurfaceFlag;
353 rtDesc.fWidth = GrNextPow2(desc.fWidth); 353 rtDesc.fWidth = GrNextPow2(desc.fWidth);
354 rtDesc.fHeight = GrNextPow2(desc.fHeight); 354 rtDesc.fHeight = GrNextPow2(desc.fHeight);
355 355
356 GrTexture* texture = fGpu->createTexture(rtDesc, NULL, 0); 356 GrTexture* texture = fGpu->createTexture(rtDesc, NULL, 0);
357 357
358 if (texture) { 358 if (texture) {
359 GrDrawTarget::AutoStateRestore asr(fGpu, GrDrawTarget::kReset_ASRInit); 359 GrDrawTarget::AutoStateRestore asr(fGpu, GrDrawTarget::kReset_ASRInit);
360 GrDrawState* drawState = fGpu->drawState(); 360 GrDrawState* drawState = fGpu->drawState();
361 drawState->setRenderTarget(texture->asRenderTarget()); 361 drawState->setRenderTarget(texture->asRenderTarget());
362 362
(...skipping 14 matching lines...) Expand all
377 verts[0].setIRectFan(0, 0, texture->width(), texture->height(), 2 * sizeof(SkPoint)); 377 verts[0].setIRectFan(0, 0, texture->width(), texture->height(), 2 * sizeof(SkPoint));
378 verts[1].setIRectFan(0, 0, 1, 1, 2 * sizeof(SkPoint)); 378 verts[1].setIRectFan(0, 0, 1, 1, 2 * sizeof(SkPoint));
379 fGpu->drawNonIndexed(kTriangleFan_GrPrimitiveType, 0, 4); 379 fGpu->drawNonIndexed(kTriangleFan_GrPrimitiveType, 0, 4);
380 } 380 }
381 } else { 381 } else {
382 // TODO: Our CPU stretch doesn't filter. But we create separate 382 // TODO: Our CPU stretch doesn't filter. But we create separate
383 // stretched textures when the texture params is either filtered or 383 // stretched textures when the texture params is either filtered or
384 // not. Either implement filtered stretch blit on CPU or just create 384 // not. Either implement filtered stretch blit on CPU or just create
385 // one when FBO case fails. 385 // one when FBO case fails.
386 386
387 rtDesc.fFlags = kNone_GrTextureFlags; 387 rtDesc.fFlags = kNone_GrSurfaceFlags;
388 // no longer need to clamp at min RT size. 388 // no longer need to clamp at min RT size.
389 rtDesc.fWidth = GrNextPow2(desc.fWidth); 389 rtDesc.fWidth = GrNextPow2(desc.fWidth);
390 rtDesc.fHeight = GrNextPow2(desc.fHeight); 390 rtDesc.fHeight = GrNextPow2(desc.fHeight);
391 391
392 // We shouldn't be resizing a compressed texture. 392 // We shouldn't be resizing a compressed texture.
393 SkASSERT(!GrPixelConfigIsCompressed(desc.fConfig)); 393 SkASSERT(!GrPixelConfigIsCompressed(desc.fConfig));
394 394
395 size_t bpp = GrBytesPerPixel(desc.fConfig); 395 size_t bpp = GrBytesPerPixel(desc.fConfig);
396 GrAutoMalloc<128*128*4> stretchedPixels(bpp * rtDesc.fWidth * rtDesc.fHe ight); 396 GrAutoMalloc<128*128*4> stretchedPixels(bpp * rtDesc.fWidth * rtDesc.fHe ight);
397 stretch_image(stretchedPixels.get(), rtDesc.fWidth, rtDesc.fHeight, 397 stretch_image(stretchedPixels.get(), rtDesc.fWidth, rtDesc.fHeight,
398 srcData, desc.fWidth, desc.fHeight, bpp); 398 srcData, desc.fWidth, desc.fHeight, bpp);
399 399
400 size_t stretchedRowBytes = rtDesc.fWidth * bpp; 400 size_t stretchedRowBytes = rtDesc.fWidth * bpp;
401 401
402 texture = fGpu->createTexture(rtDesc, stretchedPixels.get(), stretchedRo wBytes); 402 texture = fGpu->createTexture(rtDesc, stretchedPixels.get(), stretchedRo wBytes);
403 SkASSERT(texture); 403 SkASSERT(texture);
404 } 404 }
405 405
406 return texture; 406 return texture;
407 } 407 }
408 408
409 GrTexture* GrContext::createTexture(const GrTextureParams* params, 409 GrTexture* GrContext::createTexture(const GrTextureParams* params,
410 const GrTextureDesc& desc, 410 const GrSurfaceDesc& desc,
411 const GrCacheID& cacheID, 411 const GrCacheID& cacheID,
412 const void* srcData, 412 const void* srcData,
413 size_t rowBytes, 413 size_t rowBytes,
414 GrResourceKey* cacheKey) { 414 GrResourceKey* cacheKey) {
415 GrResourceKey resourceKey = GrTexturePriv::ComputeKey(fGpu, params, desc, ca cheID); 415 GrResourceKey resourceKey = GrTexturePriv::ComputeKey(fGpu, params, desc, ca cheID);
416 416
417 GrTexture* texture; 417 GrTexture* texture;
418 if (GrTexturePriv::NeedsResizing(resourceKey)) { 418 if (GrTexturePriv::NeedsResizing(resourceKey)) {
419 // We do not know how to resize compressed textures. 419 // We do not know how to resize compressed textures.
420 SkASSERT(!GrPixelConfigIsCompressed(desc.fConfig)); 420 SkASSERT(!GrPixelConfigIsCompressed(desc.fConfig));
421 421
422 texture = this->createResizedTexture(desc, cacheID, 422 texture = this->createResizedTexture(desc, cacheID,
423 srcData, rowBytes, 423 srcData, rowBytes,
424 GrTexturePriv::NeedsBilerp(resource Key)); 424 GrTexturePriv::NeedsBilerp(resource Key));
425 } else { 425 } else {
426 texture = fGpu->createTexture(desc, srcData, rowBytes); 426 texture = fGpu->createTexture(desc, srcData, rowBytes);
427 } 427 }
428 428
429 if (texture) { 429 if (texture) {
430 fResourceCache->addResource(resourceKey, texture); 430 fResourceCache->addResource(resourceKey, texture);
431 431
432 if (cacheKey) { 432 if (cacheKey) {
433 *cacheKey = resourceKey; 433 *cacheKey = resourceKey;
434 } 434 }
435 } 435 }
436 436
437 return texture; 437 return texture;
438 } 438 }
439 439
440 GrTexture* GrContext::createNewScratchTexture(const GrTextureDesc& desc) { 440 GrTexture* GrContext::createNewScratchTexture(const GrSurfaceDesc& desc) {
441 GrTexture* texture = fGpu->createTexture(desc, NULL, 0); 441 GrTexture* texture = fGpu->createTexture(desc, NULL, 0);
442 if (!texture) { 442 if (!texture) {
443 return NULL; 443 return NULL;
444 } 444 }
445 fResourceCache->addResource(texture->getScratchKey(), texture); 445 fResourceCache->addResource(texture->getScratchKey(), texture);
446 return texture; 446 return texture;
447 } 447 }
448 448
449 GrTexture* GrContext::refScratchTexture(const GrTextureDesc& inDesc, ScratchTexM atch match, 449 GrTexture* GrContext::refScratchTexture(const GrSurfaceDesc& inDesc, ScratchTexM atch match,
450 bool calledDuringFlush) { 450 bool calledDuringFlush) {
451 // kNoStencil has no meaning if kRT isn't set. 451 // kNoStencil has no meaning if kRT isn't set.
452 SkASSERT((inDesc.fFlags & kRenderTarget_GrTextureFlagBit) || 452 SkASSERT((inDesc.fFlags & kRenderTarget_GrSurfaceFlag) ||
453 !(inDesc.fFlags & kNoStencil_GrTextureFlagBit)); 453 !(inDesc.fFlags & kNoStencil_GrSurfaceFlag));
454 454
455 // Make sure caller has checked for renderability if kRT is set. 455 // Make sure caller has checked for renderability if kRT is set.
456 SkASSERT(!(inDesc.fFlags & kRenderTarget_GrTextureFlagBit) || 456 SkASSERT(!(inDesc.fFlags & kRenderTarget_GrSurfaceFlag) ||
457 this->isConfigRenderable(inDesc.fConfig, inDesc.fSampleCnt > 0)); 457 this->isConfigRenderable(inDesc.fConfig, inDesc.fSampleCnt > 0));
458 458
459 SkTCopyOnFirstWrite<GrTextureDesc> desc(inDesc); 459 SkTCopyOnFirstWrite<GrSurfaceDesc> desc(inDesc);
460 460
461 if (fGpu->caps()->reuseScratchTextures() || (desc->fFlags & kRenderTarget_Gr TextureFlagBit)) { 461 if (fGpu->caps()->reuseScratchTextures() || (desc->fFlags & kRenderTarget_Gr SurfaceFlag)) {
462 GrTextureFlags origFlags = desc->fFlags; 462 GrSurfaceFlags origFlags = desc->fFlags;
463 if (kApprox_ScratchTexMatch == match) { 463 if (kApprox_ScratchTexMatch == match) {
464 // bin by pow2 with a reasonable min 464 // bin by pow2 with a reasonable min
465 static const int MIN_SIZE = 16; 465 static const int MIN_SIZE = 16;
466 GrTextureDesc* wdesc = desc.writable(); 466 GrSurfaceDesc* wdesc = desc.writable();
467 wdesc->fWidth = SkTMax(MIN_SIZE, GrNextPow2(desc->fWidth)); 467 wdesc->fWidth = SkTMax(MIN_SIZE, GrNextPow2(desc->fWidth));
468 wdesc->fHeight = SkTMax(MIN_SIZE, GrNextPow2(desc->fHeight)); 468 wdesc->fHeight = SkTMax(MIN_SIZE, GrNextPow2(desc->fHeight));
469 } 469 }
470 470
471 do { 471 do {
472 GrResourceKey key = GrTexturePriv::ComputeScratchKey(*desc); 472 GrResourceKey key = GrTexturePriv::ComputeScratchKey(*desc);
473 uint32_t scratchFlags = 0; 473 uint32_t scratchFlags = 0;
474 if (calledDuringFlush) { 474 if (calledDuringFlush) {
475 scratchFlags = GrResourceCache2::kRequireNoPendingIO_ScratchFlag ; 475 scratchFlags = GrResourceCache2::kRequireNoPendingIO_ScratchFlag ;
476 } else if (!(desc->fFlags & kRenderTarget_GrTextureFlagBit)) { 476 } else if (!(desc->fFlags & kRenderTarget_GrSurfaceFlag)) {
477 // If it is not a render target then it will most likely be popu lated by 477 // If it is not a render target then it will most likely be popu lated by
478 // writePixels() which will trigger a flush if the texture has p ending IO. 478 // writePixels() which will trigger a flush if the texture has p ending IO.
479 scratchFlags = GrResourceCache2::kPreferNoPendingIO_ScratchFlag; 479 scratchFlags = GrResourceCache2::kPreferNoPendingIO_ScratchFlag;
480 } 480 }
481 GrGpuResource* resource = fResourceCache2->findAndRefScratchResource (key, scratchFlags); 481 GrGpuResource* resource = fResourceCache2->findAndRefScratchResource (key, scratchFlags);
482 if (resource) { 482 if (resource) {
483 fResourceCache->makeResourceMRU(resource); 483 fResourceCache->makeResourceMRU(resource);
484 return static_cast<GrTexture*>(resource); 484 return static_cast<GrTexture*>(resource);
485 } 485 }
486 486
487 if (kExact_ScratchTexMatch == match) { 487 if (kExact_ScratchTexMatch == match) {
488 break; 488 break;
489 } 489 }
490 // We had a cache miss and we are in approx mode, relax the fit of t he flags. 490 // We had a cache miss and we are in approx mode, relax the fit of t he flags.
491 491
492 // We no longer try to reuse textures that were previously used as r ender targets in 492 // We no longer try to reuse textures that were previously used as r ender targets in
493 // situations where no RT is needed; doing otherwise can confuse the video driver and 493 // situations where no RT is needed; doing otherwise can confuse the video driver and
494 // cause significant performance problems in some cases. 494 // cause significant performance problems in some cases.
495 if (desc->fFlags & kNoStencil_GrTextureFlagBit) { 495 if (desc->fFlags & kNoStencil_GrSurfaceFlag) {
496 desc.writable()->fFlags = desc->fFlags & ~kNoStencil_GrTextureFl agBit; 496 desc.writable()->fFlags = desc->fFlags & ~kNoStencil_GrSurfaceFl ag;
497 } else { 497 } else {
498 break; 498 break;
499 } 499 }
500 500
501 } while (true); 501 } while (true);
502 502
503 desc.writable()->fFlags = origFlags; 503 desc.writable()->fFlags = origFlags;
504 } 504 }
505 505
506 GrTexture* texture = this->createNewScratchTexture(*desc); 506 GrTexture* texture = this->createNewScratchTexture(*desc);
507 SkASSERT(NULL == texture || 507 SkASSERT(NULL == texture ||
508 texture->getScratchKey() == GrTexturePriv::ComputeScratchKey(*desc) ); 508 texture->getScratchKey() == GrTexturePriv::ComputeScratchKey(*desc) );
509 return texture; 509 return texture;
510 } 510 }
511 511
512 bool GrContext::OverbudgetCB(void* data) { 512 bool GrContext::OverbudgetCB(void* data) {
513 SkASSERT(data); 513 SkASSERT(data);
514 514
515 GrContext* context = reinterpret_cast<GrContext*>(data); 515 GrContext* context = reinterpret_cast<GrContext*>(data);
516 516
517 // Flush the InOrderDrawBuffer to possibly free up some textures 517 // Flush the InOrderDrawBuffer to possibly free up some textures
518 context->fFlushToReduceCacheSize = true; 518 context->fFlushToReduceCacheSize = true;
519 519
520 return true; 520 return true;
521 } 521 }
522 522
523 523
524 GrTexture* GrContext::createUncachedTexture(const GrTextureDesc& descIn, 524 GrTexture* GrContext::createUncachedTexture(const GrSurfaceDesc& descIn,
525 void* srcData, 525 void* srcData,
526 size_t rowBytes) { 526 size_t rowBytes) {
527 GrTextureDesc descCopy = descIn; 527 GrSurfaceDesc descCopy = descIn;
528 return fGpu->createTexture(descCopy, srcData, rowBytes); 528 return fGpu->createTexture(descCopy, srcData, rowBytes);
529 } 529 }
530 530
531 void GrContext::getResourceCacheLimits(int* maxTextures, size_t* maxTextureBytes ) const { 531 void GrContext::getResourceCacheLimits(int* maxTextures, size_t* maxTextureBytes ) const {
532 fResourceCache->getLimits(maxTextures, maxTextureBytes); 532 fResourceCache->getLimits(maxTextures, maxTextureBytes);
533 } 533 }
534 534
535 void GrContext::setResourceCacheLimits(int maxTextures, size_t maxTextureBytes) { 535 void GrContext::setResourceCacheLimits(int maxTextures, size_t maxTextureBytes) {
536 fResourceCache->setLimits(maxTextures, maxTextureBytes); 536 fResourceCache->setLimits(maxTextures, maxTextureBytes);
537 } 537 }
(...skipping 770 matching lines...) Expand 10 before | Expand all | Expand 10 after
1308 // config. This scratch will then have R and B swapped. We correct for this by swapping again 1308 // config. This scratch will then have R and B swapped. We correct for this by swapping again
1309 // when drawing the scratch to the dst using a conversion effect. 1309 // when drawing the scratch to the dst using a conversion effect.
1310 bool swapRAndB = false; 1310 bool swapRAndB = false;
1311 GrPixelConfig writeConfig = srcConfig; 1311 GrPixelConfig writeConfig = srcConfig;
1312 if (GrPixelConfigSwapRAndB(srcConfig) == 1312 if (GrPixelConfigSwapRAndB(srcConfig) ==
1313 fGpu->preferredWritePixelsConfig(srcConfig, renderTarget->config())) { 1313 fGpu->preferredWritePixelsConfig(srcConfig, renderTarget->config())) {
1314 writeConfig = GrPixelConfigSwapRAndB(srcConfig); 1314 writeConfig = GrPixelConfigSwapRAndB(srcConfig);
1315 swapRAndB = true; 1315 swapRAndB = true;
1316 } 1316 }
1317 1317
1318 GrTextureDesc desc; 1318 GrSurfaceDesc desc;
1319 desc.fWidth = width; 1319 desc.fWidth = width;
1320 desc.fHeight = height; 1320 desc.fHeight = height;
1321 desc.fConfig = writeConfig; 1321 desc.fConfig = writeConfig;
1322 SkAutoTUnref<GrTexture> texture(this->refScratchTexture(desc, kApprox_Scratc hTexMatch)); 1322 SkAutoTUnref<GrTexture> texture(this->refScratchTexture(desc, kApprox_Scratc hTexMatch));
1323 if (!texture) { 1323 if (!texture) {
1324 return false; 1324 return false;
1325 } 1325 }
1326 1326
1327 SkAutoTUnref<const GrFragmentProcessor> fp; 1327 SkAutoTUnref<const GrFragmentProcessor> fp;
1328 SkMatrix textureMatrix; 1328 SkMatrix textureMatrix;
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
1445 return false; 1445 return false;
1446 } 1446 }
1447 1447
1448 // If the src is a texture and we would have to do conversions after read pi xels, we instead 1448 // If the src is a texture and we would have to do conversions after read pi xels, we instead
1449 // do the conversions by drawing the src to a scratch texture. If we handle any of the 1449 // do the conversions by drawing the src to a scratch texture. If we handle any of the
1450 // conversions in the draw we set the corresponding bool to false so that we don't reapply it 1450 // conversions in the draw we set the corresponding bool to false so that we don't reapply it
1451 // on the read back pixels. 1451 // on the read back pixels.
1452 GrTexture* src = target->asTexture(); 1452 GrTexture* src = target->asTexture();
1453 if (src && (swapRAndB || unpremul || flipY)) { 1453 if (src && (swapRAndB || unpremul || flipY)) {
1454 // Make the scratch a render so we can read its pixels. 1454 // Make the scratch a render so we can read its pixels.
1455 GrTextureDesc desc; 1455 GrSurfaceDesc desc;
1456 desc.fFlags = kRenderTarget_GrTextureFlagBit; 1456 desc.fFlags = kRenderTarget_GrSurfaceFlag;
1457 desc.fWidth = width; 1457 desc.fWidth = width;
1458 desc.fHeight = height; 1458 desc.fHeight = height;
1459 desc.fConfig = readConfig; 1459 desc.fConfig = readConfig;
1460 desc.fOrigin = kTopLeft_GrSurfaceOrigin; 1460 desc.fOrigin = kTopLeft_GrSurfaceOrigin;
1461 1461
1462 // When a full read back is faster than a partial we could always make t he scratch exactly 1462 // When a full read back is faster than a partial we could always make t he scratch exactly
1463 // match the passed rect. However, if we see many different size rectang les we will trash 1463 // match the passed rect. However, if we see many different size rectang les we will trash
1464 // our texture cache and pay the cost of creating and destroying many te xtures. So, we only 1464 // our texture cache and pay the cost of creating and destroying many te xtures. So, we only
1465 // request an exact match when the caller is reading an entire RT. 1465 // request an exact match when the caller is reading an entire RT.
1466 ScratchTexMatch match = kApprox_ScratchTexMatch; 1466 ScratchTexMatch match = kApprox_ScratchTexMatch;
(...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after
1801 fResourceCache->printStats(); 1801 fResourceCache->printStats();
1802 } 1802 }
1803 #endif 1803 #endif
1804 1804
1805 #if GR_GPU_STATS 1805 #if GR_GPU_STATS
1806 const GrContext::GPUStats* GrContext::gpuStats() const { 1806 const GrContext::GPUStats* GrContext::gpuStats() const {
1807 return fGpu->gpuStats(); 1807 return fGpu->gpuStats();
1808 } 1808 }
1809 #endif 1809 #endif
1810 1810
OLDNEW
« no previous file with comments | « src/gpu/GrClipMaskManager.cpp ('k') | src/gpu/GrDistanceFieldTextContext.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698