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 (!this->caps()->isConfigTexturable(desc.fConfig)) { | 113 if (kUnknown_GrPixelConfig == desc.fConfig) { |
114 return NULL; | 114 return NULL; |
115 } | 115 } |
116 | |
117 if ((desc.fFlags & kRenderTarget_GrTextureFlagBit) && | 116 if ((desc.fFlags & kRenderTarget_GrTextureFlagBit) && |
118 !this->caps()->isConfigRenderable(desc.fConfig, desc.fSampleCnt > 0)) { | 117 !this->caps()->isConfigRenderable(desc.fConfig, desc.fSampleCnt > 0)) { |
119 return NULL; | 118 return NULL; |
120 } | 119 } |
121 | 120 |
122 GrTexture *tex = NULL; | 121 this->handleDirtyContext(); |
123 if (GrPixelConfigIsCompressed(desc.fConfig)) { | 122 GrTexture* tex = this->onCreateTexture(desc, srcData, rowBytes); |
124 // We shouldn't be rendering into this | 123 if (NULL != tex && |
125 SkASSERT((desc.fFlags & kRenderTarget_GrTextureFlagBit) == 0); | 124 (kRenderTarget_GrTextureFlagBit & desc.fFlags) && |
126 | 125 !(kNoStencil_GrTextureFlagBit & desc.fFlags)) { |
127 if (!this->caps()->npotTextureTileSupport() && | 126 SkASSERT(NULL != tex->asRenderTarget()); |
128 (!GrIsPow2(desc.fWidth) || !GrIsPow2(desc.fHeight))) { | 127 // TODO: defer this and attach dynamically |
| 128 if (!this->attachStencilBufferToRenderTarget(tex->asRenderTarget())) { |
| 129 tex->unref(); |
129 return NULL; | 130 return NULL; |
130 } | 131 } |
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 } | |
147 } | 132 } |
148 return tex; | 133 return tex; |
149 } | 134 } |
150 | 135 |
151 bool GrGpu::attachStencilBufferToRenderTarget(GrRenderTarget* rt) { | 136 bool GrGpu::attachStencilBufferToRenderTarget(GrRenderTarget* rt) { |
152 SkASSERT(NULL == rt->getStencilBuffer()); | 137 SkASSERT(NULL == rt->getStencilBuffer()); |
153 GrStencilBuffer* sb = | 138 GrStencilBuffer* sb = |
154 this->getContext()->findStencilBuffer(rt->width(), | 139 this->getContext()->findStencilBuffer(rt->width(), |
155 rt->height(), | 140 rt->height(), |
156 rt->numSamples()); | 141 rt->numSamples()); |
(...skipping 408 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
565 } | 550 } |
566 | 551 |
567 void GrGpu::releaseIndexArray() { | 552 void GrGpu::releaseIndexArray() { |
568 // if index source was array, we stowed data in the pool | 553 // if index source was array, we stowed data in the pool |
569 const GeometrySrcState& geoSrc = this->getGeomSrc(); | 554 const GeometrySrcState& geoSrc = this->getGeomSrc(); |
570 SkASSERT(kArray_GeometrySrcType == geoSrc.fIndexSrc); | 555 SkASSERT(kArray_GeometrySrcType == geoSrc.fIndexSrc); |
571 size_t bytes = geoSrc.fIndexCount * sizeof(uint16_t); | 556 size_t bytes = geoSrc.fIndexCount * sizeof(uint16_t); |
572 fIndexPool->putBack(bytes); | 557 fIndexPool->putBack(bytes); |
573 --fIndexPoolUseCnt; | 558 --fIndexPoolUseCnt; |
574 } | 559 } |
OLD | NEW |