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

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

Issue 1728093005: Move Budgeted enum out of SkSurface, use in GrTextureProvider (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: add aliases for Chrome Created 4 years, 10 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/GrYUVProvider.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 * Copyright 2015 Google Inc. 2 * Copyright 2015 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 #include "GrTextureProvider.h" 8 #include "GrTextureProvider.h"
9 #include "GrTexturePriv.h" 9 #include "GrTexturePriv.h"
10 #include "GrResourceCache.h" 10 #include "GrResourceCache.h"
(...skipping 11 matching lines...) Expand all
22 22
23 GrTextureProvider::GrTextureProvider(GrGpu* gpu, GrResourceCache* cache, GrSingl eOwner* singleOwner) 23 GrTextureProvider::GrTextureProvider(GrGpu* gpu, GrResourceCache* cache, GrSingl eOwner* singleOwner)
24 : fCache(cache) 24 : fCache(cache)
25 , fGpu(gpu) 25 , fGpu(gpu)
26 #ifdef SK_DEBUG 26 #ifdef SK_DEBUG
27 , fSingleOwner(singleOwner) 27 , fSingleOwner(singleOwner)
28 #endif 28 #endif
29 { 29 {
30 } 30 }
31 31
32 GrTexture* GrTextureProvider::createTexture(const GrSurfaceDesc& desc, bool budg eted, 32 GrTexture* GrTextureProvider::createTexture(const GrSurfaceDesc& desc, SkBudgete d budgeted,
33 const void* srcData, size_t rowBytes ) { 33 const void* srcData, size_t rowBytes ) {
34 ASSERT_SINGLE_OWNER 34 ASSERT_SINGLE_OWNER
35 if (this->isAbandoned()) { 35 if (this->isAbandoned()) {
36 return nullptr; 36 return nullptr;
37 } 37 }
38 if ((desc.fFlags & kRenderTarget_GrSurfaceFlag) && 38 if ((desc.fFlags & kRenderTarget_GrSurfaceFlag) &&
39 !fGpu->caps()->isConfigRenderable(desc.fConfig, desc.fSampleCnt > 0)) { 39 !fGpu->caps()->isConfigRenderable(desc.fConfig, desc.fSampleCnt > 0)) {
40 return nullptr; 40 return nullptr;
41 } 41 }
42 if (!GrPixelConfigIsCompressed(desc.fConfig) && 42 if (!GrPixelConfigIsCompressed(desc.fConfig) &&
43 !desc.fTextureStorageAllocator.fAllocateTextureStorage) { 43 !desc.fTextureStorageAllocator.fAllocateTextureStorage) {
44 static const uint32_t kFlags = kExact_ScratchTextureFlag | 44 static const uint32_t kFlags = kExact_ScratchTextureFlag |
45 kNoCreate_ScratchTextureFlag; 45 kNoCreate_ScratchTextureFlag;
46 if (GrTexture* texture = this->refScratchTexture(desc, kFlags)) { 46 if (GrTexture* texture = this->refScratchTexture(desc, kFlags)) {
47 if (!srcData || texture->writePixels(0, 0, desc.fWidth, desc.fHeight , desc.fConfig, 47 if (!srcData || texture->writePixels(0, 0, desc.fWidth, desc.fHeight , desc.fConfig,
48 srcData, rowBytes)) { 48 srcData, rowBytes)) {
49 if (!budgeted) { 49 if (SkBudgeted::kNo == budgeted) {
50 texture->resourcePriv().makeUnbudgeted(); 50 texture->resourcePriv().makeUnbudgeted();
51 } 51 }
52 return texture; 52 return texture;
53 } 53 }
54 texture->unref(); 54 texture->unref();
55 } 55 }
56 } 56 }
57 return fGpu->createTexture(desc, budgeted, srcData, rowBytes); 57 return fGpu->createTexture(desc, budgeted, srcData, rowBytes);
58 } 58 }
59 59
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 GrSurface* surface = static_cast<GrSurface*>(resource); 110 GrSurface* surface = static_cast<GrSurface*>(resource);
111 GrRenderTarget* rt = surface->asRenderTarget(); 111 GrRenderTarget* rt = surface->asRenderTarget();
112 if (rt && fGpu->caps()->discardRenderTargetSupport()) { 112 if (rt && fGpu->caps()->discardRenderTargetSupport()) {
113 rt->discard(); 113 rt->discard();
114 } 114 }
115 return surface->asTexture(); 115 return surface->asTexture();
116 } 116 }
117 } 117 }
118 118
119 if (!(kNoCreate_ScratchTextureFlag & flags)) { 119 if (!(kNoCreate_ScratchTextureFlag & flags)) {
120 return fGpu->createTexture(*desc, true, nullptr, 0); 120 return fGpu->createTexture(*desc, SkBudgeted::kYes, nullptr, 0);
121 } 121 }
122 122
123 return nullptr; 123 return nullptr;
124 } 124 }
125 125
126 GrTexture* GrTextureProvider::wrapBackendTexture(const GrBackendTextureDesc& des c, 126 GrTexture* GrTextureProvider::wrapBackendTexture(const GrBackendTextureDesc& des c,
127 GrWrapOwnership ownership) { 127 GrWrapOwnership ownership) {
128 ASSERT_SINGLE_OWNER 128 ASSERT_SINGLE_OWNER
129 if (this->isAbandoned()) { 129 if (this->isAbandoned()) {
130 return nullptr; 130 return nullptr;
(...skipping 28 matching lines...) Expand all
159 GrTexture* GrTextureProvider::findAndRefTextureByUniqueKey(const GrUniqueKey& ke y) { 159 GrTexture* GrTextureProvider::findAndRefTextureByUniqueKey(const GrUniqueKey& ke y) {
160 ASSERT_SINGLE_OWNER 160 ASSERT_SINGLE_OWNER
161 GrGpuResource* resource = this->findAndRefResourceByUniqueKey(key); 161 GrGpuResource* resource = this->findAndRefResourceByUniqueKey(key);
162 if (resource) { 162 if (resource) {
163 GrTexture* texture = static_cast<GrSurface*>(resource)->asTexture(); 163 GrTexture* texture = static_cast<GrSurface*>(resource)->asTexture();
164 SkASSERT(texture); 164 SkASSERT(texture);
165 return texture; 165 return texture;
166 } 166 }
167 return NULL; 167 return NULL;
168 } 168 }
OLDNEW
« no previous file with comments | « src/gpu/GrTextureParamsAdjuster.cpp ('k') | src/gpu/GrYUVProvider.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698