OLD | NEW |
---|---|
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2010 Google Inc. | 3 * Copyright 2010 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 | 9 |
10 #include "GrGpu.h" | 10 #include "GrGpu.h" |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
103 void GrGpu::unimpl(const char msg[]) { | 103 void GrGpu::unimpl(const char msg[]) { |
104 #ifdef SK_DEBUG | 104 #ifdef SK_DEBUG |
105 GrPrintf("--- GrGpu unimplemented(\"%s\")\n", msg); | 105 GrPrintf("--- GrGpu unimplemented(\"%s\")\n", msg); |
106 #endif | 106 #endif |
107 } | 107 } |
108 | 108 |
109 //////////////////////////////////////////////////////////////////////////////// | 109 //////////////////////////////////////////////////////////////////////////////// |
110 | 110 |
111 GrTexture* GrGpu::createTexture(const GrTextureDesc& desc, | 111 GrTexture* GrGpu::createTexture(const GrTextureDesc& desc, |
112 const void* srcData, size_t rowBytes) { | 112 const void* srcData, size_t rowBytes) { |
113 if (kUnknown_GrPixelConfig == desc.fConfig) { | 113 if (!this->caps()->isConfigTexturable(desc.fConfig)) { |
114 return NULL; | 114 return NULL; |
115 } | 115 } |
116 | |
116 if ((desc.fFlags & kRenderTarget_GrTextureFlagBit) && | 117 if ((desc.fFlags & kRenderTarget_GrTextureFlagBit) && |
117 !this->caps()->isConfigRenderable(desc.fConfig, desc.fSampleCnt > 0)) { | 118 !this->caps()->isConfigRenderable(desc.fConfig, desc.fSampleCnt > 0)) { |
118 return NULL; | 119 return NULL; |
119 } | 120 } |
120 | 121 |
121 this->handleDirtyContext(); | 122 GrTexture *tex = NULL; |
122 GrTexture* tex = this->onCreateTexture(desc, srcData, rowBytes); | 123 if (GrPixelConfigIsCompressed(desc.fConfig)) { |
123 if (NULL != tex && | 124 // We shouldn't be rendering into this |
124 (kRenderTarget_GrTextureFlagBit & desc.fFlags) && | 125 SkASSERT((desc.fFlags & kRenderTarget_GrTextureFlagBit) == 0); |
bsalomon
2014/05/30 17:59:57
Since GrContext:createTexture() can be called by c
krajcevski
2014/05/30 18:35:20
The caps() should make sure that compressed format
| |
125 !(kNoStencil_GrTextureFlagBit & desc.fFlags)) { | 126 |
126 SkASSERT(NULL != tex->asRenderTarget()); | 127 if (!this->caps()->npotTextureTileSupport() && |
127 // TODO: defer this and attach dynamically | 128 (!GrIsPow2(desc.fWidth) || !GrIsPow2(desc.fHeight))) { |
128 if (!this->attachStencilBufferToRenderTarget(tex->asRenderTarget())) { | |
129 tex->unref(); | |
130 return NULL; | 129 return NULL; |
131 } | 130 } |
131 | |
132 this->handleDirtyContext(); | |
133 tex = this->onCreateCompressedTexture(desc, srcData); | |
134 } else { | |
135 this->handleDirtyContext(); | |
136 tex = this->onCreateTexture(desc, srcData, rowBytes); | |
137 if (NULL != tex && | |
138 (kRenderTarget_GrTextureFlagBit & desc.fFlags) && | |
139 !(kNoStencil_GrTextureFlagBit & desc.fFlags)) { | |
140 SkASSERT(NULL != tex->asRenderTarget()); | |
141 // TODO: defer this and attach dynamically | |
142 if (!this->attachStencilBufferToRenderTarget(tex->asRenderTarget())) { | |
143 tex->unref(); | |
144 return NULL; | |
145 } | |
146 } | |
132 } | 147 } |
133 return tex; | 148 return tex; |
134 } | 149 } |
135 | 150 |
136 bool GrGpu::attachStencilBufferToRenderTarget(GrRenderTarget* rt) { | 151 bool GrGpu::attachStencilBufferToRenderTarget(GrRenderTarget* rt) { |
137 SkASSERT(NULL == rt->getStencilBuffer()); | 152 SkASSERT(NULL == rt->getStencilBuffer()); |
138 GrStencilBuffer* sb = | 153 GrStencilBuffer* sb = |
139 this->getContext()->findStencilBuffer(rt->width(), | 154 this->getContext()->findStencilBuffer(rt->width(), |
140 rt->height(), | 155 rt->height(), |
141 rt->numSamples()); | 156 rt->numSamples()); |
(...skipping 408 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
550 } | 565 } |
551 | 566 |
552 void GrGpu::releaseIndexArray() { | 567 void GrGpu::releaseIndexArray() { |
553 // if index source was array, we stowed data in the pool | 568 // if index source was array, we stowed data in the pool |
554 const GeometrySrcState& geoSrc = this->getGeomSrc(); | 569 const GeometrySrcState& geoSrc = this->getGeomSrc(); |
555 SkASSERT(kArray_GeometrySrcType == geoSrc.fIndexSrc); | 570 SkASSERT(kArray_GeometrySrcType == geoSrc.fIndexSrc); |
556 size_t bytes = geoSrc.fIndexCount * sizeof(uint16_t); | 571 size_t bytes = geoSrc.fIndexCount * sizeof(uint16_t); |
557 fIndexPool->putBack(bytes); | 572 fIndexPool->putBack(bytes); |
558 --fIndexPoolUseCnt; | 573 --fIndexPoolUseCnt; |
559 } | 574 } |
OLD | NEW |