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 "GrCaps.h" | 10 #include "GrCaps.h" |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 return desc.fOrigin; | 74 return desc.fOrigin; |
75 } | 75 } |
76 } | 76 } |
77 } | 77 } |
78 | 78 |
79 ////////////////////////////////////////////////////////////////////////////// | 79 ////////////////////////////////////////////////////////////////////////////// |
80 GrTexture::GrTexture(GrGpu* gpu, LifeCycle lifeCycle, const GrSurfaceDesc& desc) | 80 GrTexture::GrTexture(GrGpu* gpu, LifeCycle lifeCycle, const GrSurfaceDesc& desc) |
81 : INHERITED(gpu, lifeCycle, desc) | 81 : INHERITED(gpu, lifeCycle, desc) |
82 , fMipMapsStatus(kNotAllocated_MipMapsStatus) { | 82 , fMipMapsStatus(kNotAllocated_MipMapsStatus) { |
83 | 83 |
84 if (kWrapped_LifeCycle != lifeCycle && !GrPixelConfigIsCompressed(desc.fConf
ig)) { | 84 if (!this->isExternal() && !GrPixelConfigIsCompressed(desc.fConfig)) { |
85 GrScratchKey key; | 85 GrScratchKey key; |
86 GrTexturePriv::ComputeScratchKey(desc, &key); | 86 GrTexturePriv::ComputeScratchKey(desc, &key); |
87 this->setScratchKey(key); | 87 this->setScratchKey(key); |
88 } | 88 } |
89 // only make sense if alloc size is pow2 | 89 // only make sense if alloc size is pow2 |
90 fShiftFixedX = 31 - SkCLZ(fDesc.fWidth); | 90 fShiftFixedX = 31 - SkCLZ(fDesc.fWidth); |
91 fShiftFixedY = 31 - SkCLZ(fDesc.fHeight); | 91 fShiftFixedY = 31 - SkCLZ(fDesc.fHeight); |
92 } | 92 } |
93 | 93 |
94 void GrTexturePriv::ComputeScratchKey(const GrSurfaceDesc& desc, GrScratchKey* k
ey) { | 94 void GrTexturePriv::ComputeScratchKey(const GrSurfaceDesc& desc, GrScratchKey* k
ey) { |
95 static const GrScratchKey::ResourceType kType = GrScratchKey::GenerateResour
ceType(); | 95 static const GrScratchKey::ResourceType kType = GrScratchKey::GenerateResour
ceType(); |
96 | 96 |
97 GrScratchKey::Builder builder(key, kType, 2); | 97 GrScratchKey::Builder builder(key, kType, 2); |
98 | 98 |
99 GrSurfaceOrigin origin = resolve_origin(desc); | 99 GrSurfaceOrigin origin = resolve_origin(desc); |
100 uint32_t flags = desc.fFlags & ~kCheckAllocation_GrSurfaceFlag; | 100 uint32_t flags = desc.fFlags & ~kCheckAllocation_GrSurfaceFlag; |
101 | 101 |
102 SkASSERT(desc.fWidth <= SK_MaxU16); | 102 SkASSERT(desc.fWidth <= SK_MaxU16); |
103 SkASSERT(desc.fHeight <= SK_MaxU16); | 103 SkASSERT(desc.fHeight <= SK_MaxU16); |
104 SkASSERT(static_cast<int>(desc.fConfig) < (1 << 6)); | 104 SkASSERT(static_cast<int>(desc.fConfig) < (1 << 6)); |
105 SkASSERT(desc.fSampleCnt < (1 << 8)); | 105 SkASSERT(desc.fSampleCnt < (1 << 8)); |
106 SkASSERT(flags < (1 << 10)); | 106 SkASSERT(flags < (1 << 10)); |
107 SkASSERT(static_cast<int>(origin) < (1 << 8)); | 107 SkASSERT(static_cast<int>(origin) < (1 << 8)); |
108 | 108 |
109 builder[0] = desc.fWidth | (desc.fHeight << 16); | 109 builder[0] = desc.fWidth | (desc.fHeight << 16); |
110 builder[1] = desc.fConfig | (desc.fSampleCnt << 6) | (flags << 14) | (origin
<< 24); | 110 builder[1] = desc.fConfig | (desc.fSampleCnt << 6) | (flags << 14) | (origin
<< 24); |
111 } | 111 } |
OLD | NEW |