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

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

Issue 1316233002: Style Change: NULL->nullptr (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: 2015-08-27 (Thursday) 10:25:06 EDT Created 5 years, 3 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/GrTextContext.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"
11 #include "GrResourceCache.h" 11 #include "GrResourceCache.h"
12 #include "GrGpu.h" 12 #include "GrGpu.h"
13 13
14 enum ScratchTextureFlags { 14 enum ScratchTextureFlags {
15 kExact_ScratchTextureFlag = 0x1, 15 kExact_ScratchTextureFlag = 0x1,
16 kNoPendingIO_ScratchTextureFlag = 0x2, 16 kNoPendingIO_ScratchTextureFlag = 0x2,
17 kNoCreate_ScratchTextureFlag = 0x4, 17 kNoCreate_ScratchTextureFlag = 0x4,
18 }; 18 };
19 19
20 GrTexture* GrTextureProvider::createTexture(const GrSurfaceDesc& desc, bool budg eted, 20 GrTexture* GrTextureProvider::createTexture(const GrSurfaceDesc& desc, bool budg eted,
21 const void* srcData, size_t rowBytes ) { 21 const void* srcData, size_t rowBytes ) {
22 if (this->isAbandoned()) { 22 if (this->isAbandoned()) {
23 return NULL; 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 NULL; 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(0, 0, desc.fWidth, desc.fHeight , 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 return texture; 38 return texture;
39 } 39 }
40 texture->unref(); 40 texture->unref();
41 } 41 }
42 } 42 }
43 return fGpu->createTexture(desc, budgeted, srcData, rowBytes); 43 return fGpu->createTexture(desc, budgeted, srcData, rowBytes);
44 } 44 }
45 45
46 GrTexture* GrTextureProvider::createApproxTexture(const GrSurfaceDesc& desc) { 46 GrTexture* GrTextureProvider::createApproxTexture(const GrSurfaceDesc& desc) {
47 return this->internalCreateApproxTexture(desc, 0); 47 return this->internalCreateApproxTexture(desc, 0);
48 } 48 }
49 49
50 GrTexture* GrTextureProvider::internalCreateApproxTexture(const GrSurfaceDesc& d esc, 50 GrTexture* GrTextureProvider::internalCreateApproxTexture(const GrSurfaceDesc& d esc,
51 uint32_t scratchFlags) { 51 uint32_t scratchFlags) {
52 if (this->isAbandoned()) { 52 if (this->isAbandoned()) {
53 return NULL; 53 return nullptr;
54 } 54 }
55 // Currently we don't recycle compressed textures as scratch. 55 // Currently we don't recycle compressed textures as scratch.
56 if (GrPixelConfigIsCompressed(desc.fConfig)) { 56 if (GrPixelConfigIsCompressed(desc.fConfig)) {
57 return NULL; 57 return nullptr;
58 } else { 58 } else {
59 return this->refScratchTexture(desc, scratchFlags); 59 return this->refScratchTexture(desc, scratchFlags);
60 } 60 }
61 } 61 }
62 62
63 GrTexture* GrTextureProvider::refScratchTexture(const GrSurfaceDesc& inDesc, 63 GrTexture* GrTextureProvider::refScratchTexture(const GrSurfaceDesc& inDesc,
64 uint32_t flags) { 64 uint32_t flags) {
65 SkASSERT(!this->isAbandoned()); 65 SkASSERT(!this->isAbandoned());
66 SkASSERT(!GrPixelConfigIsCompressed(inDesc.fConfig)); 66 SkASSERT(!GrPixelConfigIsCompressed(inDesc.fConfig));
67 67
(...skipping 25 matching lines...) Expand all
93 GrSurface* surface = static_cast<GrSurface*>(resource); 93 GrSurface* surface = static_cast<GrSurface*>(resource);
94 GrRenderTarget* rt = surface->asRenderTarget(); 94 GrRenderTarget* rt = surface->asRenderTarget();
95 if (rt && fGpu->caps()->discardRenderTargetSupport()) { 95 if (rt && fGpu->caps()->discardRenderTargetSupport()) {
96 rt->discard(); 96 rt->discard();
97 } 97 }
98 return surface->asTexture(); 98 return surface->asTexture();
99 } 99 }
100 } 100 }
101 101
102 if (!(kNoCreate_ScratchTextureFlag & flags)) { 102 if (!(kNoCreate_ScratchTextureFlag & flags)) {
103 return fGpu->createTexture(*desc, true, NULL, 0); 103 return fGpu->createTexture(*desc, true, nullptr, 0);
104 } 104 }
105 105
106 return NULL; 106 return nullptr;
107 } 107 }
108 108
109 GrTexture* GrTextureProvider::wrapBackendTexture(const GrBackendTextureDesc& des c, 109 GrTexture* GrTextureProvider::wrapBackendTexture(const GrBackendTextureDesc& des c,
110 GrWrapOwnership ownership) { 110 GrWrapOwnership ownership) {
111 if (this->isAbandoned()) { 111 if (this->isAbandoned()) {
112 return NULL; 112 return nullptr;
113 } 113 }
114 return fGpu->wrapBackendTexture(desc, ownership); 114 return fGpu->wrapBackendTexture(desc, ownership);
115 } 115 }
116 116
117 GrRenderTarget* GrTextureProvider::wrapBackendRenderTarget(const GrBackendRender TargetDesc& desc) { 117 GrRenderTarget* GrTextureProvider::wrapBackendRenderTarget(const GrBackendRender TargetDesc& desc) {
118 return this->isAbandoned() ? NULL : fGpu->wrapBackendRenderTarget(desc, 118 return this->isAbandoned() ? nullptr : fGpu->wrapBackendRenderTarget(desc,
119 kBorrow_Gr WrapOwnership); 119 kBorrow_Gr WrapOwnership);
120 } 120 }
121 121
122 void GrTextureProvider::assignUniqueKeyToResource(const GrUniqueKey& key, GrGpuR esource* resource) { 122 void GrTextureProvider::assignUniqueKeyToResource(const GrUniqueKey& key, GrGpuR esource* resource) {
123 if (this->isAbandoned() || !resource) { 123 if (this->isAbandoned() || !resource) {
124 return; 124 return;
125 } 125 }
126 resource->resourcePriv().setUniqueKey(key); 126 resource->resourcePriv().setUniqueKey(key);
127 } 127 }
128 128
129 bool GrTextureProvider::existsResourceWithUniqueKey(const GrUniqueKey& key) cons t { 129 bool GrTextureProvider::existsResourceWithUniqueKey(const GrUniqueKey& key) cons t {
130 return this->isAbandoned() ? false : fCache->hasUniqueKey(key); 130 return this->isAbandoned() ? false : fCache->hasUniqueKey(key);
131 } 131 }
132 132
133 GrGpuResource* GrTextureProvider::findAndRefResourceByUniqueKey(const GrUniqueKe y& key) { 133 GrGpuResource* GrTextureProvider::findAndRefResourceByUniqueKey(const GrUniqueKe y& key) {
134 return this->isAbandoned() ? NULL : fCache->findAndRefUniqueResource(key); 134 return this->isAbandoned() ? nullptr : fCache->findAndRefUniqueResource(key) ;
135 } 135 }
OLDNEW
« no previous file with comments | « src/gpu/GrTextContext.cpp ('k') | src/gpu/GrVertices.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698