| 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 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 191 this->handleDirtyContext(); | 191 this->handleDirtyContext(); |
| 192 return this->onCreateVertexBuffer(size, dynamic); | 192 return this->onCreateVertexBuffer(size, dynamic); |
| 193 } | 193 } |
| 194 | 194 |
| 195 GrIndexBuffer* GrGpu::createIndexBuffer(uint32_t size, bool dynamic) { | 195 GrIndexBuffer* GrGpu::createIndexBuffer(uint32_t size, bool dynamic) { |
| 196 this->handleDirtyContext(); | 196 this->handleDirtyContext(); |
| 197 return this->onCreateIndexBuffer(size, dynamic); | 197 return this->onCreateIndexBuffer(size, dynamic); |
| 198 } | 198 } |
| 199 | 199 |
| 200 GrPath* GrGpu::createPath(const SkPath& path) { | 200 GrPath* GrGpu::createPath(const SkPath& path) { |
| 201 SkASSERT(this->caps()->pathStencilingSupport()); | 201 SkASSERT(this->caps()->pathRenderingSupport()); |
| 202 this->handleDirtyContext(); | 202 this->handleDirtyContext(); |
| 203 return this->onCreatePath(path); | 203 return this->onCreatePath(path); |
| 204 } | 204 } |
| 205 | 205 |
| 206 void GrGpu::clear(const SkIRect* rect, | 206 void GrGpu::clear(const SkIRect* rect, |
| 207 GrColor color, | 207 GrColor color, |
| 208 GrRenderTarget* renderTarget) { | 208 GrRenderTarget* renderTarget) { |
| 209 GrDrawState::AutoRenderTargetRestore art; | 209 GrDrawState::AutoRenderTargetRestore art; |
| 210 if (NULL != renderTarget) { | 210 if (NULL != renderTarget) { |
| 211 art.set(this->drawState(), renderTarget); | 211 art.set(this->drawState(), renderTarget); |
| (...skipping 28 matching lines...) Expand all Loading... |
| 240 return this->onWriteTexturePixels(texture, left, top, width, height, | 240 return this->onWriteTexturePixels(texture, left, top, width, height, |
| 241 config, buffer, rowBytes); | 241 config, buffer, rowBytes); |
| 242 } | 242 } |
| 243 | 243 |
| 244 void GrGpu::resolveRenderTarget(GrRenderTarget* target) { | 244 void GrGpu::resolveRenderTarget(GrRenderTarget* target) { |
| 245 SkASSERT(target); | 245 SkASSERT(target); |
| 246 this->handleDirtyContext(); | 246 this->handleDirtyContext(); |
| 247 this->onResolveRenderTarget(target); | 247 this->onResolveRenderTarget(target); |
| 248 } | 248 } |
| 249 | 249 |
| 250 static const GrStencilSettings& winding_path_stencil_settings() { |
| 251 GR_STATIC_CONST_SAME_STENCIL_STRUCT(gSettings, |
| 252 kIncClamp_StencilOp, |
| 253 kIncClamp_StencilOp, |
| 254 kAlwaysIfInClip_StencilFunc, |
| 255 0xFFFF, 0xFFFF, 0xFFFF); |
| 256 return *GR_CONST_STENCIL_SETTINGS_PTR_FROM_STRUCT_PTR(&gSettings); |
| 257 } |
| 258 |
| 259 static const GrStencilSettings& even_odd_path_stencil_settings() { |
| 260 GR_STATIC_CONST_SAME_STENCIL_STRUCT(gSettings, |
| 261 kInvert_StencilOp, |
| 262 kInvert_StencilOp, |
| 263 kAlwaysIfInClip_StencilFunc, |
| 264 0xFFFF, 0xFFFF, 0xFFFF); |
| 265 return *GR_CONST_STENCIL_SETTINGS_PTR_FROM_STRUCT_PTR(&gSettings); |
| 266 } |
| 267 |
| 268 void GrGpu::getPathStencilSettingsForFillType(SkPath::FillType fill, GrStencilSe
ttings* outStencilSettings) { |
| 269 |
| 270 switch (fill) { |
| 271 default: |
| 272 GrCrash("Unexpected path fill."); |
| 273 /* fallthrough */; |
| 274 case SkPath::kWinding_FillType: |
| 275 case SkPath::kInverseWinding_FillType: |
| 276 *outStencilSettings = winding_path_stencil_settings(); |
| 277 break; |
| 278 case SkPath::kEvenOdd_FillType: |
| 279 case SkPath::kInverseEvenOdd_FillType: |
| 280 *outStencilSettings = even_odd_path_stencil_settings(); |
| 281 break; |
| 282 } |
| 283 fClipMaskManager.adjustPathStencilParams(outStencilSettings); |
| 284 } |
| 285 |
| 250 | 286 |
| 251 //////////////////////////////////////////////////////////////////////////////// | 287 //////////////////////////////////////////////////////////////////////////////// |
| 252 | 288 |
| 253 static const int MAX_QUADS = 1 << 12; // max possible: (1 << 14) - 1; | 289 static const int MAX_QUADS = 1 << 12; // max possible: (1 << 14) - 1; |
| 254 | 290 |
| 255 GR_STATIC_ASSERT(4 * MAX_QUADS <= 65535); | 291 GR_STATIC_ASSERT(4 * MAX_QUADS <= 65535); |
| 256 | 292 |
| 257 static inline void fill_indices(uint16_t* indices, int quadCount) { | 293 static inline void fill_indices(uint16_t* indices, int quadCount) { |
| 258 for (int i = 0; i < quadCount; ++i) { | 294 for (int i = 0; i < quadCount; ++i) { |
| 259 indices[6 * i + 0] = 4 * i + 0; | 295 indices[6 * i + 0] = 4 * i + 0; |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 342 info.getDstCopy(), | 378 info.getDstCopy(), |
| 343 &are)) { | 379 &are)) { |
| 344 return; | 380 return; |
| 345 } | 381 } |
| 346 this->onGpuDraw(info); | 382 this->onGpuDraw(info); |
| 347 } | 383 } |
| 348 | 384 |
| 349 void GrGpu::onStencilPath(const GrPath* path, const SkStrokeRec&, SkPath::FillTy
pe fill) { | 385 void GrGpu::onStencilPath(const GrPath* path, const SkStrokeRec&, SkPath::FillTy
pe fill) { |
| 350 this->handleDirtyContext(); | 386 this->handleDirtyContext(); |
| 351 | 387 |
| 352 // TODO: make this more efficient (don't copy and copy back) | |
| 353 GrAutoTRestore<GrStencilSettings> asr(this->drawState()->stencil()); | |
| 354 | |
| 355 this->setStencilPathSettings(*path, fill, this->drawState()->stencil()); | |
| 356 GrDrawState::AutoRestoreEffects are; | 388 GrDrawState::AutoRestoreEffects are; |
| 357 if (!this->setupClipAndFlushState(kStencilPath_DrawType, NULL, &are)) { | 389 if (!this->setupClipAndFlushState(kStencilPath_DrawType, NULL, &are)) { |
| 358 return; | 390 return; |
| 359 } | 391 } |
| 360 | 392 |
| 361 this->onGpuStencilPath(path, fill); | 393 this->onGpuStencilPath(path, fill); |
| 362 } | 394 } |
| 363 | 395 |
| 396 void GrGpu::onFillPath(const GrPath* path, const SkStrokeRec& stroke, SkPath::Fi
llType fill, |
| 397 const GrDeviceCoordTexture* dstCopy) { |
| 398 this->handleDirtyContext(); |
| 399 |
| 400 drawState()->setDefaultVertexAttribs(); |
| 401 |
| 402 GrDrawState::AutoRestoreEffects are; |
| 403 if (!this->setupClipAndFlushState(kFillPath_DrawType, dstCopy, &are)) { |
| 404 return; |
| 405 } |
| 406 |
| 407 this->onGpuFillPath(path, fill); |
| 408 } |
| 409 |
| 364 void GrGpu::finalizeReservedVertices() { | 410 void GrGpu::finalizeReservedVertices() { |
| 365 SkASSERT(NULL != fVertexPool); | 411 SkASSERT(NULL != fVertexPool); |
| 366 fVertexPool->unlock(); | 412 fVertexPool->unlock(); |
| 367 } | 413 } |
| 368 | 414 |
| 369 void GrGpu::finalizeReservedIndices() { | 415 void GrGpu::finalizeReservedIndices() { |
| 370 SkASSERT(NULL != fIndexPool); | 416 SkASSERT(NULL != fIndexPool); |
| 371 fIndexPool->unlock(); | 417 fIndexPool->unlock(); |
| 372 } | 418 } |
| 373 | 419 |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 491 } | 537 } |
| 492 | 538 |
| 493 void GrGpu::releaseIndexArray() { | 539 void GrGpu::releaseIndexArray() { |
| 494 // if index source was array, we stowed data in the pool | 540 // if index source was array, we stowed data in the pool |
| 495 const GeometrySrcState& geoSrc = this->getGeomSrc(); | 541 const GeometrySrcState& geoSrc = this->getGeomSrc(); |
| 496 SkASSERT(kArray_GeometrySrcType == geoSrc.fIndexSrc); | 542 SkASSERT(kArray_GeometrySrcType == geoSrc.fIndexSrc); |
| 497 size_t bytes = geoSrc.fIndexCount * sizeof(uint16_t); | 543 size_t bytes = geoSrc.fIndexCount * sizeof(uint16_t); |
| 498 fIndexPool->putBack(bytes); | 544 fIndexPool->putBack(bytes); |
| 499 --fIndexPoolUseCnt; | 545 --fIndexPoolUseCnt; |
| 500 } | 546 } |
| OLD | NEW |