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

Side by Side Diff: src/gpu/gl/GrGpuGL.cpp

Issue 459263003: Add a parameter GR_ALWAYS_ALLOCATE_ON_HEAP to allow for only ever creating temporary buffers on the… (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 4 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
« src/gpu/GrTextStrike.cpp ('K') | « src/gpu/GrTextStrike.cpp ('k') | no next file » | 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 * 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 8
9 #include "GrGpuGL.h" 9 #include "GrGpuGL.h"
10 #include "GrGLStencilBuffer.h" 10 #include "GrGLStencilBuffer.h"
(...skipping 560 matching lines...) Expand 10 before | Expand all | Expand 10 after
571 SkASSERT(!GrPixelConfigIsCompressed(dataConfig)); 571 SkASSERT(!GrPixelConfigIsCompressed(dataConfig));
572 572
573 size_t bpp = GrBytesPerPixel(dataConfig); 573 size_t bpp = GrBytesPerPixel(dataConfig);
574 if (!adjust_pixel_ops_params(desc.fWidth, desc.fHeight, bpp, &left, &top, 574 if (!adjust_pixel_ops_params(desc.fWidth, desc.fHeight, bpp, &left, &top,
575 &width, &height, &data, &rowBytes)) { 575 &width, &height, &data, &rowBytes)) {
576 return false; 576 return false;
577 } 577 }
578 size_t trimRowBytes = width * bpp; 578 size_t trimRowBytes = width * bpp;
579 579
580 // in case we need a temporary, trimmed copy of the src pixels 580 // in case we need a temporary, trimmed copy of the src pixels
581 #if GR_ALWAYS_ALLOCATE_ON_HEAP
582 SkAutoMalloc tempStorage;
583 #else
581 SkAutoSMalloc<128 * 128> tempStorage; 584 SkAutoSMalloc<128 * 128> tempStorage;
585 #endif
582 586
583 // We currently lazily create MIPMAPs when the we see a draw with 587 // We currently lazily create MIPMAPs when the we see a draw with
584 // GrTextureParams::kMipMap_FilterMode. Using texture storage requires that the 588 // GrTextureParams::kMipMap_FilterMode. Using texture storage requires that the
585 // MIP levels are all created when the texture is created. So for now we don 't use 589 // MIP levels are all created when the texture is created. So for now we don 't use
586 // texture storage. 590 // texture storage.
587 bool useTexStorage = false && 591 bool useTexStorage = false &&
588 isNewTexture && 592 isNewTexture &&
589 this->glCaps().texStorageSupport(); 593 this->glCaps().texStorageSupport();
590 594
591 if (useTexStorage && kGL_GrGLStandard == this->glStandard()) { 595 if (useTexStorage && kGL_GrGLStandard == this->glStandard()) {
(...skipping 1067 matching lines...) Expand 10 before | Expand all | Expand 10 after
1659 1663
1660 size_t tightRowBytes = bpp * width; 1664 size_t tightRowBytes = bpp * width;
1661 if (0 == rowBytes) { 1665 if (0 == rowBytes) {
1662 rowBytes = tightRowBytes; 1666 rowBytes = tightRowBytes;
1663 } 1667 }
1664 size_t readDstRowBytes = tightRowBytes; 1668 size_t readDstRowBytes = tightRowBytes;
1665 void* readDst = buffer; 1669 void* readDst = buffer;
1666 1670
1667 // determine if GL can read using the passed rowBytes or if we need 1671 // determine if GL can read using the passed rowBytes or if we need
1668 // a scratch buffer. 1672 // a scratch buffer.
1673
1674 #if GR_ALWAYS_ALLOCATE_ON_HEAP
1675 SkAutoMalloc scratch;
1676 #else
1669 SkAutoSMalloc<32 * sizeof(GrColor)> scratch; 1677 SkAutoSMalloc<32 * sizeof(GrColor)> scratch;
1678 #endif
1679
1670 if (rowBytes != tightRowBytes) { 1680 if (rowBytes != tightRowBytes) {
1671 if (this->glCaps().packRowLengthSupport()) { 1681 if (this->glCaps().packRowLengthSupport()) {
1672 SkASSERT(!(rowBytes % sizeof(GrColor))); 1682 SkASSERT(!(rowBytes % sizeof(GrColor)));
1673 GL_CALL(PixelStorei(GR_GL_PACK_ROW_LENGTH, 1683 GL_CALL(PixelStorei(GR_GL_PACK_ROW_LENGTH,
1674 static_cast<GrGLint>(rowBytes / sizeof(GrColor)) )); 1684 static_cast<GrGLint>(rowBytes / sizeof(GrColor)) ));
1675 readDstRowBytes = rowBytes; 1685 readDstRowBytes = rowBytes;
1676 } else { 1686 } else {
1677 scratch.reset(tightRowBytes * height); 1687 scratch.reset(tightRowBytes * height);
1678 readDst = scratch.get(); 1688 readDst = scratch.get();
1679 } 1689 }
(...skipping 1263 matching lines...) Expand 10 before | Expand all | Expand 10 after
2943 this->setVertexArrayID(gpu, 0); 2953 this->setVertexArrayID(gpu, 0);
2944 } 2954 }
2945 int attrCount = gpu->glCaps().maxVertexAttributes(); 2955 int attrCount = gpu->glCaps().maxVertexAttributes();
2946 if (fDefaultVertexArrayAttribState.count() != attrCount) { 2956 if (fDefaultVertexArrayAttribState.count() != attrCount) {
2947 fDefaultVertexArrayAttribState.resize(attrCount); 2957 fDefaultVertexArrayAttribState.resize(attrCount);
2948 } 2958 }
2949 attribState = &fDefaultVertexArrayAttribState; 2959 attribState = &fDefaultVertexArrayAttribState;
2950 } 2960 }
2951 return attribState; 2961 return attribState;
2952 } 2962 }
OLDNEW
« src/gpu/GrTextStrike.cpp ('K') | « src/gpu/GrTextStrike.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698