| 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 18 matching lines...) Expand all Loading... |
| 29 | 29 |
| 30 GrGpu::GrGpu(GrContext* context) | 30 GrGpu::GrGpu(GrContext* context) |
| 31 : INHERITED(context) | 31 : INHERITED(context) |
| 32 , fResetTimestamp(kExpiredTimestamp+1) | 32 , fResetTimestamp(kExpiredTimestamp+1) |
| 33 , fResetBits(kAll_GrBackendState) | 33 , fResetBits(kAll_GrBackendState) |
| 34 , fVertexPool(NULL) | 34 , fVertexPool(NULL) |
| 35 , fIndexPool(NULL) | 35 , fIndexPool(NULL) |
| 36 , fVertexPoolUseCnt(0) | 36 , fVertexPoolUseCnt(0) |
| 37 , fIndexPoolUseCnt(0) | 37 , fIndexPoolUseCnt(0) |
| 38 , fQuadIndexBuffer(NULL) { | 38 , fQuadIndexBuffer(NULL) { |
| 39 | |
| 40 fClipMaskManager.setGpu(this); | |
| 41 | |
| 42 fGeomPoolStateStack.push_back(); | 39 fGeomPoolStateStack.push_back(); |
| 43 #ifdef SK_DEBUG | 40 #ifdef SK_DEBUG |
| 44 GeometryPoolState& poolState = fGeomPoolStateStack.back(); | 41 GeometryPoolState& poolState = fGeomPoolStateStack.back(); |
| 45 poolState.fPoolVertexBuffer = (GrVertexBuffer*)DEBUG_INVAL_BUFFER; | 42 poolState.fPoolVertexBuffer = (GrVertexBuffer*)DEBUG_INVAL_BUFFER; |
| 46 poolState.fPoolStartVertex = DEBUG_INVAL_START_IDX; | 43 poolState.fPoolStartVertex = DEBUG_INVAL_START_IDX; |
| 47 poolState.fPoolIndexBuffer = (GrIndexBuffer*)DEBUG_INVAL_BUFFER; | 44 poolState.fPoolIndexBuffer = (GrIndexBuffer*)DEBUG_INVAL_BUFFER; |
| 48 poolState.fPoolStartIndex = DEBUG_INVAL_START_IDX; | 45 poolState.fPoolStartIndex = DEBUG_INVAL_START_IDX; |
| 49 #endif | 46 #endif |
| 50 } | 47 } |
| 51 | 48 |
| (...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 243 return this->onWriteTexturePixels(texture, left, top, width, height, | 240 return this->onWriteTexturePixels(texture, left, top, width, height, |
| 244 config, buffer, rowBytes); | 241 config, buffer, rowBytes); |
| 245 } | 242 } |
| 246 | 243 |
| 247 void GrGpu::resolveRenderTarget(GrRenderTarget* target) { | 244 void GrGpu::resolveRenderTarget(GrRenderTarget* target) { |
| 248 SkASSERT(target); | 245 SkASSERT(target); |
| 249 this->handleDirtyContext(); | 246 this->handleDirtyContext(); |
| 250 this->onResolveRenderTarget(target); | 247 this->onResolveRenderTarget(target); |
| 251 } | 248 } |
| 252 | 249 |
| 253 static const GrStencilSettings& winding_path_stencil_settings() { | |
| 254 GR_STATIC_CONST_SAME_STENCIL_STRUCT(gSettings, | |
| 255 kIncClamp_StencilOp, | |
| 256 kIncClamp_StencilOp, | |
| 257 kAlwaysIfInClip_StencilFunc, | |
| 258 0xFFFF, 0xFFFF, 0xFFFF); | |
| 259 return *GR_CONST_STENCIL_SETTINGS_PTR_FROM_STRUCT_PTR(&gSettings); | |
| 260 } | |
| 261 | |
| 262 static const GrStencilSettings& even_odd_path_stencil_settings() { | |
| 263 GR_STATIC_CONST_SAME_STENCIL_STRUCT(gSettings, | |
| 264 kInvert_StencilOp, | |
| 265 kInvert_StencilOp, | |
| 266 kAlwaysIfInClip_StencilFunc, | |
| 267 0xFFFF, 0xFFFF, 0xFFFF); | |
| 268 return *GR_CONST_STENCIL_SETTINGS_PTR_FROM_STRUCT_PTR(&gSettings); | |
| 269 } | |
| 270 | |
| 271 void GrGpu::getPathStencilSettingsForFillType(SkPath::FillType fill, GrStencilSe
ttings* outStencilSettings) { | |
| 272 | |
| 273 switch (fill) { | |
| 274 default: | |
| 275 SkFAIL("Unexpected path fill."); | |
| 276 /* fallthrough */; | |
| 277 case SkPath::kWinding_FillType: | |
| 278 case SkPath::kInverseWinding_FillType: | |
| 279 *outStencilSettings = winding_path_stencil_settings(); | |
| 280 break; | |
| 281 case SkPath::kEvenOdd_FillType: | |
| 282 case SkPath::kInverseEvenOdd_FillType: | |
| 283 *outStencilSettings = even_odd_path_stencil_settings(); | |
| 284 break; | |
| 285 } | |
| 286 fClipMaskManager.adjustPathStencilParams(outStencilSettings); | |
| 287 } | |
| 288 | |
| 289 | |
| 290 //////////////////////////////////////////////////////////////////////////////// | 250 //////////////////////////////////////////////////////////////////////////////// |
| 291 | 251 |
| 292 static const int MAX_QUADS = 1 << 12; // max possible: (1 << 14) - 1; | 252 static const int MAX_QUADS = 1 << 12; // max possible: (1 << 14) - 1; |
| 293 | 253 |
| 294 GR_STATIC_ASSERT(4 * MAX_QUADS <= 65535); | 254 GR_STATIC_ASSERT(4 * MAX_QUADS <= 65535); |
| 295 | 255 |
| 296 static const uint16_t gQuadIndexPattern[] = { | 256 static const uint16_t gQuadIndexPattern[] = { |
| 297 0, 1, 2, 0, 2, 3 | 257 0, 1, 2, 0, 2, 3 |
| 298 }; | 258 }; |
| 299 | 259 |
| (...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 547 } | 507 } |
| 548 | 508 |
| 549 void GrGpu::releaseIndexArray() { | 509 void GrGpu::releaseIndexArray() { |
| 550 // if index source was array, we stowed data in the pool | 510 // if index source was array, we stowed data in the pool |
| 551 const GeometrySrcState& geoSrc = this->getGeomSrc(); | 511 const GeometrySrcState& geoSrc = this->getGeomSrc(); |
| 552 SkASSERT(kArray_GeometrySrcType == geoSrc.fIndexSrc); | 512 SkASSERT(kArray_GeometrySrcType == geoSrc.fIndexSrc); |
| 553 size_t bytes = geoSrc.fIndexCount * sizeof(uint16_t); | 513 size_t bytes = geoSrc.fIndexCount * sizeof(uint16_t); |
| 554 fIndexPool->putBack(bytes); | 514 fIndexPool->putBack(bytes); |
| 555 --fIndexPoolUseCnt; | 515 --fIndexPoolUseCnt; |
| 556 } | 516 } |
| OLD | NEW |