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