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