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

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

Issue 1139753002: Refactor GrBufferAllocPools to use resource cache (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Clean up Created 5 years, 7 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
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 1410 matching lines...) Expand 10 before | Expand all | Expand 10 after
1421 fGpu->preferredWritePixelsConfig(srcConfig, renderTarget->config())) { 1421 fGpu->preferredWritePixelsConfig(srcConfig, renderTarget->config())) {
1422 writeConfig = GrPixelConfigSwapRAndB(srcConfig); 1422 writeConfig = GrPixelConfigSwapRAndB(srcConfig);
1423 swapRAndB = true; 1423 swapRAndB = true;
1424 } 1424 }
1425 1425
1426 GrSurfaceDesc desc; 1426 GrSurfaceDesc desc;
1427 desc.fWidth = width; 1427 desc.fWidth = width;
1428 desc.fHeight = height; 1428 desc.fHeight = height;
1429 desc.fConfig = writeConfig; 1429 desc.fConfig = writeConfig;
1430 SkAutoTUnref<GrTexture> texture(this->textureProvider()->refScratchTexture(d esc, 1430 SkAutoTUnref<GrTexture> texture(this->textureProvider()->refScratchTexture(d esc,
1431 GrTextureProvider::kApprox_ScratchTexMatch)); 1431 GrTextureProvider::kApprox_ScratchMatch));
1432 if (!texture) { 1432 if (!texture) {
1433 return false; 1433 return false;
1434 } 1434 }
1435 1435
1436 SkAutoTUnref<const GrFragmentProcessor> fp; 1436 SkAutoTUnref<const GrFragmentProcessor> fp;
1437 SkMatrix textureMatrix; 1437 SkMatrix textureMatrix;
1438 textureMatrix.setIDiv(texture->width(), texture->height()); 1438 textureMatrix.setIDiv(texture->width(), texture->height());
1439 1439
1440 // allocate a tmp buffer and sw convert the pixels to premul 1440 // allocate a tmp buffer and sw convert the pixels to premul
1441 SkAutoSTMalloc<128 * 128, uint32_t> tmpPixels(0); 1441 SkAutoSTMalloc<128 * 128, uint32_t> tmpPixels(0);
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
1566 desc.fFlags = kRenderTarget_GrSurfaceFlag; 1566 desc.fFlags = kRenderTarget_GrSurfaceFlag;
1567 desc.fWidth = width; 1567 desc.fWidth = width;
1568 desc.fHeight = height; 1568 desc.fHeight = height;
1569 desc.fConfig = readConfig; 1569 desc.fConfig = readConfig;
1570 desc.fOrigin = kTopLeft_GrSurfaceOrigin; 1570 desc.fOrigin = kTopLeft_GrSurfaceOrigin;
1571 1571
1572 // When a full read back is faster than a partial we could always make t he scratch exactly 1572 // When a full read back is faster than a partial we could always make t he scratch exactly
1573 // match the passed rect. However, if we see many different size rectang les we will trash 1573 // match the passed rect. However, if we see many different size rectang les we will trash
1574 // our texture cache and pay the cost of creating and destroying many te xtures. So, we only 1574 // our texture cache and pay the cost of creating and destroying many te xtures. So, we only
1575 // request an exact match when the caller is reading an entire RT. 1575 // request an exact match when the caller is reading an entire RT.
1576 GrTextureProvider::ScratchTexMatch match = GrTextureProvider::kApprox_Sc ratchTexMatch; 1576 GrTextureProvider::ScratchMatch match = GrTextureProvider::kApprox_Scrat chMatch;
1577 if (0 == left && 1577 if (0 == left &&
1578 0 == top && 1578 0 == top &&
1579 target->width() == width && 1579 target->width() == width &&
1580 target->height() == height && 1580 target->height() == height &&
1581 fGpu->fullReadPixelsIsFasterThanPartial()) { 1581 fGpu->fullReadPixelsIsFasterThanPartial()) {
1582 match = GrTextureProvider::kExact_ScratchTexMatch; 1582 match = GrTextureProvider::kExact_ScratchMatch;
1583 } 1583 }
1584 tempTexture.reset(this->textureProvider()->refScratchTexture(desc, match )); 1584 tempTexture.reset(this->textureProvider()->refScratchTexture(desc, match ));
1585 if (tempTexture) { 1585 if (tempTexture) {
1586 // compute a matrix to perform the draw 1586 // compute a matrix to perform the draw
1587 SkMatrix textureMatrix; 1587 SkMatrix textureMatrix;
1588 textureMatrix.setTranslate(SK_Scalar1 *left, SK_Scalar1 *top); 1588 textureMatrix.setTranslate(SK_Scalar1 *left, SK_Scalar1 *top);
1589 textureMatrix.postIDiv(src->width(), src->height()); 1589 textureMatrix.postIDiv(src->width(), src->height());
1590 1590
1591 SkAutoTUnref<const GrFragmentProcessor> fp; 1591 SkAutoTUnref<const GrFragmentProcessor> fp;
1592 if (unpremul) { 1592 if (unpremul) {
(...skipping 394 matching lines...) Expand 10 before | Expand all | Expand 10 after
1987 geometry.fColor = GrRandomColor(random); 1987 geometry.fColor = GrRandomColor(random);
1988 return DrawVerticesBatch::Create(geometry, type, viewMatrix, 1988 return DrawVerticesBatch::Create(geometry, type, viewMatrix,
1989 positions.begin(), vertexCount, 1989 positions.begin(), vertexCount,
1990 indices.begin(), hasIndices ? vertexCount : 0, 1990 indices.begin(), hasIndices ? vertexCount : 0,
1991 colors.begin(), 1991 colors.begin(),
1992 texCoords.begin(), 1992 texCoords.begin(),
1993 bounds); 1993 bounds);
1994 } 1994 }
1995 1995
1996 #endif 1996 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698