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

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

Issue 870743002: Allow unbudgeted resources to be recycled by the cache as scratch. (Closed) Base URL: https://skia.googlesource.com/skia.git@ckey
Patch Set: rebase Created 5 years, 11 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 #include "GrDrawTargetCaps.h" 10 #include "GrDrawTargetCaps.h"
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 return desc.fOrigin; 80 return desc.fOrigin;
81 } 81 }
82 } 82 }
83 } 83 }
84 84
85 ////////////////////////////////////////////////////////////////////////////// 85 //////////////////////////////////////////////////////////////////////////////
86 GrTexture::GrTexture(GrGpu* gpu, LifeCycle lifeCycle, const GrSurfaceDesc& desc) 86 GrTexture::GrTexture(GrGpu* gpu, LifeCycle lifeCycle, const GrSurfaceDesc& desc)
87 : INHERITED(gpu, lifeCycle, desc) 87 : INHERITED(gpu, lifeCycle, desc)
88 , fMipMapsStatus(kNotAllocated_MipMapsStatus) { 88 , fMipMapsStatus(kNotAllocated_MipMapsStatus) {
89 89
90 if (kCached_LifeCycle == lifeCycle) { 90 if (kWrapped_LifeCycle != lifeCycle) {
91 GrScratchKey key; 91 GrScratchKey key;
92 GrTexturePriv::ComputeScratchKey(desc, &key); 92 GrTexturePriv::ComputeScratchKey(desc, &key);
93 this->setScratchKey(key); 93 this->setScratchKey(key);
94 } 94 }
95 // only make sense if alloc size is pow2 95 // only make sense if alloc size is pow2
96 fShiftFixedX = 31 - SkCLZ(fDesc.fWidth); 96 fShiftFixedX = 31 - SkCLZ(fDesc.fWidth);
97 fShiftFixedY = 31 - SkCLZ(fDesc.fHeight); 97 fShiftFixedY = 31 - SkCLZ(fDesc.fHeight);
98 } 98 }
99 99
100 void GrTexturePriv::ComputeScratchKey(const GrSurfaceDesc& desc, GrScratchKey* k ey) { 100 void GrTexturePriv::ComputeScratchKey(const GrSurfaceDesc& desc, GrScratchKey* k ey) {
101 static const GrScratchKey::ResourceType kType = GrScratchKey::GenerateResour ceType(); 101 static const GrScratchKey::ResourceType kType = GrScratchKey::GenerateResour ceType();
102 102
103 GrScratchKey::Builder builder(key, kType, 2); 103 GrScratchKey::Builder builder(key, kType, 2);
104 104
105 GrSurfaceOrigin origin = resolve_origin(desc); 105 GrSurfaceOrigin origin = resolve_origin(desc);
106 uint32_t flags = desc.fFlags & ~kCheckAllocation_GrSurfaceFlag; 106 uint32_t flags = desc.fFlags & ~kCheckAllocation_GrSurfaceFlag;
107 107
108 SkASSERT(desc.fWidth <= SK_MaxU16); 108 SkASSERT(desc.fWidth <= SK_MaxU16);
109 SkASSERT(desc.fHeight <= SK_MaxU16); 109 SkASSERT(desc.fHeight <= SK_MaxU16);
110 SkASSERT(static_cast<int>(desc.fConfig) < (1 << 6)); 110 SkASSERT(static_cast<int>(desc.fConfig) < (1 << 6));
111 SkASSERT(desc.fSampleCnt < (1 << 8)); 111 SkASSERT(desc.fSampleCnt < (1 << 8));
112 SkASSERT(flags < (1 << 10)); 112 SkASSERT(flags < (1 << 10));
113 SkASSERT(static_cast<int>(origin) < (1 << 8)); 113 SkASSERT(static_cast<int>(origin) < (1 << 8));
114 114
115 builder[0] = desc.fWidth | (desc.fHeight << 16); 115 builder[0] = desc.fWidth | (desc.fHeight << 16);
116 builder[1] = desc.fConfig | (desc.fSampleCnt << 6) | (flags << 14) | (origin << 24); 116 builder[1] = desc.fConfig | (desc.fSampleCnt << 6) | (flags << 14) | (origin << 24);
117 } 117 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698