OLD | NEW |
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 Loading... |
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 (kWrapped_LifeCycle != lifeCycle) { | 90 if (kWrapped_LifeCycle != lifeCycle && !GrPixelConfigIsCompressed(desc.fConf
ig)) { |
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 } |
OLD | NEW |