OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2012 Google Inc. | 3 * Copyright 2012 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 "GrClipMaskManager.h" | 9 #include "GrClipMaskManager.h" |
10 #include "GrAAConvexPathRenderer.h" | 10 #include "GrAAConvexPathRenderer.h" |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
63 const SkPath& origPath, | 63 const SkPath& origPath, |
64 const SkStrokeRec& stroke, | 64 const SkStrokeRec& stroke, |
65 bool doAA) { | 65 bool doAA) { |
66 GrPathRendererChain::DrawType type = doAA ? | 66 GrPathRendererChain::DrawType type = doAA ? |
67 GrPathRendererChain::kColorAntiAlias_Dr
awType : | 67 GrPathRendererChain::kColorAntiAlias_Dr
awType : |
68 GrPathRendererChain::kColor_DrawType; | 68 GrPathRendererChain::kColor_DrawType; |
69 // the gpu alpha mask will draw the inverse paths as non-inverse to a temp b
uffer | 69 // the gpu alpha mask will draw the inverse paths as non-inverse to a temp b
uffer |
70 SkPath::FillType fillType = SkPath::ConvertToNonInverseFillType(origPath.get
FillType()); | 70 SkPath::FillType fillType = SkPath::ConvertToNonInverseFillType(origPath.get
FillType()); |
71 | 71 |
72 // the 'false' parameter disallows use of the SW path renderer | 72 // the 'false' parameter disallows use of the SW path renderer |
73 GrPathRenderer::AutoClearPath acp(context->getPathRenderer(origPath, stroke,
gpu, | 73 GrPathRenderer::AutoClearPath acp(context->getPathRenderer(origPath, stroke,
gpu, |
74 false, type, fill
Type)); | 74 false, type, fill
Type)); |
75 return NULL == acp.renderer(); | 75 return NULL == acp.renderer(); |
76 } | 76 } |
77 | 77 |
78 /* | 78 /* |
79 * This method traverses the clip stack to see if the GrSoftwarePathRenderer | 79 * This method traverses the clip stack to see if the GrSoftwarePathRenderer |
80 * will be used on any element. If so, it returns true to indicate that the | 80 * will be used on any element. If so, it returns true to indicate that the |
81 * entire clip should be rendered in SW and then uploaded en masse to the gpu. | 81 * entire clip should be rendered in SW and then uploaded en masse to the gpu. |
82 */ | 82 */ |
83 bool GrClipMaskManager::useSWOnlyPath(const ElementList& elements) { | 83 bool GrClipMaskManager::useSWOnlyPath(const ElementList& elements) { |
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
303 default: | 303 default: |
304 SkASSERT(false); | 304 SkASSERT(false); |
305 break; | 305 break; |
306 } | 306 } |
307 } | 307 } |
308 | 308 |
309 } | 309 } |
310 | 310 |
311 //////////////////////////////////////////////////////////////////////////////// | 311 //////////////////////////////////////////////////////////////////////////////// |
312 bool GrClipMaskManager::drawFilledPath(GrTexture* target, | 312 bool GrClipMaskManager::drawFilledPath(GrTexture* target, |
313 GrPathRenderer* pathRenderer, | 313 GrPathRenderer* pathRenderer, |
314 bool isAA) { | 314 bool isAA) { |
315 GrDrawState* drawState = fGpu->drawState(); | 315 GrDrawState* drawState = fGpu->drawState(); |
316 | 316 |
317 drawState->setRenderTarget(target->asRenderTarget()); | 317 drawState->setRenderTarget(target->asRenderTarget()); |
318 | 318 |
319 SkStrokeRec stroke(SkStrokeRec::kFill_InitStyle); | 319 SkStrokeRec stroke(SkStrokeRec::kFill_InitStyle); |
320 pathRenderer->drawPath(stroke, fGpu, isAA); | 320 pathRenderer->drawPath(stroke, fGpu, isAA); |
321 return true; | 321 return true; |
322 } | 322 } |
323 | 323 |
(...skipping 18 matching lines...) Expand all Loading... |
342 fGpu->drawSimpleRect(element->getRect(), NULL); | 342 fGpu->drawSimpleRect(element->getRect(), NULL); |
343 } | 343 } |
344 return true; | 344 return true; |
345 case Element::kPath_Type: { | 345 case Element::kPath_Type: { |
346 SkStrokeRec stroke(SkStrokeRec::kFill_InitStyle); | 346 SkStrokeRec stroke(SkStrokeRec::kFill_InitStyle); |
347 GrPathRendererChain::DrawType type; | 347 GrPathRendererChain::DrawType type; |
348 type = element->isAA() ? GrPathRendererChain::kColorAntiAlias_DrawTy
pe : | 348 type = element->isAA() ? GrPathRendererChain::kColorAntiAlias_DrawTy
pe : |
349 GrPathRendererChain::kColor_DrawType; | 349 GrPathRendererChain::kColor_DrawType; |
350 SkPath::FillType fillType = element->getPath().getFillType(); | 350 SkPath::FillType fillType = element->getPath().getFillType(); |
351 GrPathRenderer::AutoClearPath acp(this->getContext()->getPathRendere
r( | 351 GrPathRenderer::AutoClearPath acp(this->getContext()->getPathRendere
r( |
352 element->getPath(), | 352 element->getPath(), |
353 stroke, fGpu, false, type, | 353 stroke, fGpu, false, type, |
354 SkPath::ConvertToNonInverseFil
lType(fillType))); | 354 SkPath::ConvertToNonInverseFil
lType(fillType))); |
355 if (NULL == acp.renderer()) { | 355 if (NULL == acp.renderer()) { |
356 return false; | 356 return false; |
357 } | 357 } |
358 acp->drawPath(stroke, fGpu, element->isAA()); | 358 acp->drawPath(stroke, fGpu, element->isAA()); |
359 break; | 359 break; |
360 } | 360 } |
361 default: | 361 default: |
362 // something is wrong if we're trying to draw an empty element. | 362 // something is wrong if we're trying to draw an empty element. |
(...skipping 11 matching lines...) Expand all Loading... |
374 | 374 |
375 switch (element->getType()) { | 375 switch (element->getType()) { |
376 case Element::kRect_Type: | 376 case Element::kRect_Type: |
377 return true; | 377 return true; |
378 case Element::kPath_Type: { | 378 case Element::kPath_Type: { |
379 SkStrokeRec stroke(SkStrokeRec::kFill_InitStyle); | 379 SkStrokeRec stroke(SkStrokeRec::kFill_InitStyle); |
380 GrPathRendererChain::DrawType type = element->isAA() ? | 380 GrPathRendererChain::DrawType type = element->isAA() ? |
381 GrPathRendererChain::kStencilAndColorAntiAlias_DrawType : | 381 GrPathRendererChain::kStencilAndColorAntiAlias_DrawType : |
382 GrPathRendererChain::kStencilAndColor_DrawType; | 382 GrPathRendererChain::kStencilAndColor_DrawType; |
383 SkPath::FillType fillType = element->getPath().getFillType(); | 383 SkPath::FillType fillType = element->getPath().getFillType(); |
384 acp->set(this->getContext()->getPathRenderer(element->getPath(), | 384 acp->set(this->getContext()->getPathRenderer(element->getPath(), |
385 stroke, fGpu, false, type, | 385 stroke, fGpu, false, type, |
386 SkPath::ConvertToNonInverseFi
llType(fillType))); | 386 SkPath::ConvertToNonInverseFi
llType(fillType))); |
387 return NULL != acp->renderer(); | 387 return NULL != acp->renderer(); |
388 } | 388 } |
389 default: | 389 default: |
390 // something is wrong if we're trying to draw an empty element. | 390 // something is wrong if we're trying to draw an empty element. |
391 GrCrash("Unexpected element type"); | 391 GrCrash("Unexpected element type"); |
392 return false; | 392 return false; |
393 } | 393 } |
394 } | 394 } |
395 | 395 |
396 void GrClipMaskManager::mergeMask(GrTexture* dstMask, | 396 void GrClipMaskManager::mergeMask(GrTexture* dstMask, |
(...skipping 687 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1084 | 1084 |
1085 // TODO: dynamically attach a stencil buffer | 1085 // TODO: dynamically attach a stencil buffer |
1086 int stencilBits = 0; | 1086 int stencilBits = 0; |
1087 GrStencilBuffer* stencilBuffer = | 1087 GrStencilBuffer* stencilBuffer = |
1088 drawState.getRenderTarget()->getStencilBuffer(); | 1088 drawState.getRenderTarget()->getStencilBuffer(); |
1089 if (NULL != stencilBuffer) { | 1089 if (NULL != stencilBuffer) { |
1090 stencilBits = stencilBuffer->bits(); | 1090 stencilBits = stencilBuffer->bits(); |
1091 this->adjustStencilParams(settings, clipMode, stencilBits); | 1091 this->adjustStencilParams(settings, clipMode, stencilBits); |
1092 } | 1092 } |
1093 } | 1093 } |
OLD | NEW |