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

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

Issue 1225923010: Refugee from Dead Machine 4: MDB Monster Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Last update from dead machine Created 4 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
« no previous file with comments | « src/gpu/GrTextureParamsAdjuster.cpp ('k') | src/gpu/GrVertices.h » ('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 2015 Google Inc. 3 * Copyright 2015 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 "GrTextureProvider.h" 9 #include "GrTextureProvider.h"
10 #include "GrTexturePriv.h" 10 #include "GrTexturePriv.h"
(...skipping 12 matching lines...) Expand all
23 return nullptr; 23 return nullptr;
24 } 24 }
25 if ((desc.fFlags & kRenderTarget_GrSurfaceFlag) && 25 if ((desc.fFlags & kRenderTarget_GrSurfaceFlag) &&
26 !fGpu->caps()->isConfigRenderable(desc.fConfig, desc.fSampleCnt > 0)) { 26 !fGpu->caps()->isConfigRenderable(desc.fConfig, desc.fSampleCnt > 0)) {
27 return nullptr; 27 return nullptr;
28 } 28 }
29 if (!GrPixelConfigIsCompressed(desc.fConfig)) { 29 if (!GrPixelConfigIsCompressed(desc.fConfig)) {
30 static const uint32_t kFlags = kExact_ScratchTextureFlag | 30 static const uint32_t kFlags = kExact_ScratchTextureFlag |
31 kNoCreate_ScratchTextureFlag; 31 kNoCreate_ScratchTextureFlag;
32 if (GrTexture* texture = this->refScratchTexture(desc, kFlags)) { 32 if (GrTexture* texture = this->refScratchTexture(desc, kFlags)) {
33 if (!srcData || texture->writePixels(0, 0, desc.fWidth, desc.fHeight , desc.fConfig, 33 if (!srcData || texture->writePixels(NULL, 0, 0, desc.fWidth, desc.f Height, desc.fConfig,
34 srcData, rowBytes)) { 34 srcData, rowBytes)) {
35 if (!budgeted) { 35 if (!budgeted) {
36 texture->resourcePriv().makeUnbudgeted(); 36 texture->resourcePriv().makeUnbudgeted();
37 } 37 }
38 if (srcData) {
39 texture->setFromRawPixels(true);
40 }
38 return texture; 41 return texture;
39 } 42 }
40 texture->unref(); 43 texture->unref();
41 } 44 }
42 } 45 }
43 return fGpu->createTexture(desc, budgeted, srcData, rowBytes); 46 GrTexture* tmp = fGpu->createTexture(desc, budgeted, srcData, rowBytes);
47 if (tmp && srcData) {
48 tmp->setFromRawPixels(true);
49 }
50 return tmp;
44 } 51 }
45 52
46 GrTexture* GrTextureProvider::createApproxTexture(const GrSurfaceDesc& desc) { 53 GrTexture* GrTextureProvider::createApproxTexture(const GrSurfaceDesc& desc) {
47 return this->internalCreateApproxTexture(desc, 0); 54 GrTexture* texture = this->internalCreateApproxTexture(desc, 0);
55 if (texture) {
56 SkASSERT(!texture->fromRawPixels2());
57 }
58 return texture;
48 } 59 }
49 60
50 GrTexture* GrTextureProvider::internalCreateApproxTexture(const GrSurfaceDesc& d esc, 61 GrTexture* GrTextureProvider::internalCreateApproxTexture(const GrSurfaceDesc& d esc,
51 uint32_t scratchFlags) { 62 uint32_t scratchFlags) {
52 if (this->isAbandoned()) { 63 if (this->isAbandoned()) {
53 return nullptr; 64 return nullptr;
54 } 65 }
55 // Currently we don't recycle compressed textures as scratch. 66 // Currently we don't recycle compressed textures as scratch.
56 if (GrPixelConfigIsCompressed(desc.fConfig)) { 67 if (GrPixelConfigIsCompressed(desc.fConfig)) {
57 return nullptr; 68 return nullptr;
(...skipping 28 matching lines...) Expand all
86 // writePixels() which will trigger a flush if the texture has pendi ng IO. 97 // writePixels() which will trigger a flush if the texture has pendi ng IO.
87 scratchFlags = GrResourceCache::kPreferNoPendingIO_ScratchFlag; 98 scratchFlags = GrResourceCache::kPreferNoPendingIO_ScratchFlag;
88 } 99 }
89 GrGpuResource* resource = fCache->findAndRefScratchResource(key, 100 GrGpuResource* resource = fCache->findAndRefScratchResource(key,
90 GrSurface::Wo rseCaseSize(*desc), 101 GrSurface::Wo rseCaseSize(*desc),
91 scratchFlags) ; 102 scratchFlags) ;
92 if (resource) { 103 if (resource) {
93 GrSurface* surface = static_cast<GrSurface*>(resource); 104 GrSurface* surface = static_cast<GrSurface*>(resource);
94 GrRenderTarget* rt = surface->asRenderTarget(); 105 GrRenderTarget* rt = surface->asRenderTarget();
95 if (rt && fGpu->caps()->discardRenderTargetSupport()) { 106 if (rt && fGpu->caps()->discardRenderTargetSupport()) {
107 // trash the existing DC in this case
96 rt->discard(); 108 rt->discard();
97 } 109 }
98 return surface->asTexture(); 110 return surface->asTexture();
99 } 111 }
100 } 112 }
101 113
102 if (!(kNoCreate_ScratchTextureFlag & flags)) { 114 if (!(kNoCreate_ScratchTextureFlag & flags)) {
103 return fGpu->createTexture(*desc, true, nullptr, 0); 115 return fGpu->createTexture(*desc, true, nullptr, 0);
104 } 116 }
105 117
(...skipping 20 matching lines...) Expand all
126 resource->resourcePriv().setUniqueKey(key); 138 resource->resourcePriv().setUniqueKey(key);
127 } 139 }
128 140
129 bool GrTextureProvider::existsResourceWithUniqueKey(const GrUniqueKey& key) cons t { 141 bool GrTextureProvider::existsResourceWithUniqueKey(const GrUniqueKey& key) cons t {
130 return this->isAbandoned() ? false : fCache->hasUniqueKey(key); 142 return this->isAbandoned() ? false : fCache->hasUniqueKey(key);
131 } 143 }
132 144
133 GrGpuResource* GrTextureProvider::findAndRefResourceByUniqueKey(const GrUniqueKe y& key) { 145 GrGpuResource* GrTextureProvider::findAndRefResourceByUniqueKey(const GrUniqueKe y& key) {
134 return this->isAbandoned() ? nullptr : fCache->findAndRefUniqueResource(key) ; 146 return this->isAbandoned() ? nullptr : fCache->findAndRefUniqueResource(key) ;
135 } 147 }
OLDNEW
« no previous file with comments | « src/gpu/GrTextureParamsAdjuster.cpp ('k') | src/gpu/GrVertices.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698