| 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 348 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 359 | 359 |
| 360 SkMatrix sampleM; | 360 SkMatrix sampleM; |
| 361 sampleM.setIDiv(srcMask->width(), srcMask->height()); | 361 sampleM.setIDiv(srcMask->width(), srcMask->height()); |
| 362 | 362 |
| 363 drawState->addColorEffect( | 363 drawState->addColorEffect( |
| 364 GrTextureDomainEffect::Create(srcMask, | 364 GrTextureDomainEffect::Create(srcMask, |
| 365 sampleM, | 365 sampleM, |
| 366 GrTextureDomainEffect::MakeTexelDomain(src
Mask, srcBound), | 366 GrTextureDomainEffect::MakeTexelDomain(src
Mask, srcBound), |
| 367 GrTextureDomainEffect::kDecal_WrapMode, | 367 GrTextureDomainEffect::kDecal_WrapMode, |
| 368 GrTextureParams::kNone_FilterMode))->unref
(); | 368 GrTextureParams::kNone_FilterMode))->unref
(); |
| 369 fGpu->drawSimpleRect(SkRect::MakeFromIRect(dstBound), NULL); | 369 fGpu->drawSimpleRect(SkRect::Make(dstBound), NULL); |
| 370 } | 370 } |
| 371 | 371 |
| 372 // get a texture to act as a temporary buffer for AA clip boolean operations | 372 // get a texture to act as a temporary buffer for AA clip boolean operations |
| 373 // TODO: given the expense of createTexture we may want to just cache this too | 373 // TODO: given the expense of createTexture we may want to just cache this too |
| 374 void GrClipMaskManager::getTemp(int width, int height, GrAutoScratchTexture* tem
p) { | 374 void GrClipMaskManager::getTemp(int width, int height, GrAutoScratchTexture* tem
p) { |
| 375 if (NULL != temp->texture()) { | 375 if (NULL != temp->texture()) { |
| 376 // we've already allocated the temp texture | 376 // we've already allocated the temp texture |
| 377 return; | 377 return; |
| 378 } | 378 } |
| 379 | 379 |
| (...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 714 fGpu->drawSimpleRect(element->getRect(), NULL); | 714 fGpu->drawSimpleRect(element->getRect(), NULL); |
| 715 } else { | 715 } else { |
| 716 SkASSERT(Element::kPath_Type == element->getType()); | 716 SkASSERT(Element::kPath_Type == element->getType()); |
| 717 SET_RANDOM_COLOR | 717 SET_RANDOM_COLOR |
| 718 pr->drawPath(*clipPath, stroke, fGpu, false); | 718 pr->drawPath(*clipPath, stroke, fGpu, false); |
| 719 } | 719 } |
| 720 } else { | 720 } else { |
| 721 SET_RANDOM_COLOR | 721 SET_RANDOM_COLOR |
| 722 // The view matrix is setup to do clip space -> stencil spac
e translation, so | 722 // The view matrix is setup to do clip space -> stencil spac
e translation, so |
| 723 // draw rect in clip space. | 723 // draw rect in clip space. |
| 724 fGpu->drawSimpleRect(SkRect::MakeFromIRect(clipSpaceIBounds)
, NULL); | 724 fGpu->drawSimpleRect(SkRect::Make(clipSpaceIBounds), NULL); |
| 725 } | 725 } |
| 726 } | 726 } |
| 727 } | 727 } |
| 728 } | 728 } |
| 729 // set this last because recursive draws may overwrite it back to kNone. | 729 // set this last because recursive draws may overwrite it back to kNone. |
| 730 SkASSERT(kNone_ClipMaskType == fCurrClipMaskType); | 730 SkASSERT(kNone_ClipMaskType == fCurrClipMaskType); |
| 731 fCurrClipMaskType = kStencil_ClipMaskType; | 731 fCurrClipMaskType = kStencil_ClipMaskType; |
| 732 return true; | 732 return true; |
| 733 } | 733 } |
| 734 | 734 |
| (...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 953 | 953 |
| 954 const Element* element = iter.get(); | 954 const Element* element = iter.get(); |
| 955 SkRegion::Op op = element->getOp(); | 955 SkRegion::Op op = element->getOp(); |
| 956 | 956 |
| 957 if (SkRegion::kIntersect_Op == op || SkRegion::kReverseDifference_Op ==
op) { | 957 if (SkRegion::kIntersect_Op == op || SkRegion::kReverseDifference_Op ==
op) { |
| 958 // Intersect and reverse difference require modifying pixels outside
of the geometry | 958 // Intersect and reverse difference require modifying pixels outside
of the geometry |
| 959 // that is being "drawn". In both cases we erase all the pixels outs
ide of the geometry | 959 // that is being "drawn". In both cases we erase all the pixels outs
ide of the geometry |
| 960 // but leave the pixels inside the geometry alone. For reverse diffe
rence we invert all | 960 // but leave the pixels inside the geometry alone. For reverse diffe
rence we invert all |
| 961 // the pixels before clearing the ones outside the geometry. | 961 // the pixels before clearing the ones outside the geometry. |
| 962 if (SkRegion::kReverseDifference_Op == op) { | 962 if (SkRegion::kReverseDifference_Op == op) { |
| 963 SkRect temp = SkRect::MakeFromIRect(clipSpaceIBounds); | 963 SkRect temp = SkRect::Make(clipSpaceIBounds); |
| 964 // invert the entire scene | 964 // invert the entire scene |
| 965 helper.draw(temp, SkRegion::kXOR_Op, false, 0xFF); | 965 helper.draw(temp, SkRegion::kXOR_Op, false, 0xFF); |
| 966 } | 966 } |
| 967 | 967 |
| 968 if (Element::kRect_Type == element->getType()) { | 968 if (Element::kRect_Type == element->getType()) { |
| 969 // convert the rect to a path so we can invert the fill | 969 // convert the rect to a path so we can invert the fill |
| 970 SkPath temp; | 970 SkPath temp; |
| 971 temp.addRect(element->getRect()); | 971 temp.addRect(element->getRect()); |
| 972 temp.setFillType(SkPath::kInverseEvenOdd_FillType); | 972 temp.setFillType(SkPath::kInverseEvenOdd_FillType); |
| 973 | 973 |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1030 | 1030 |
| 1031 // TODO: dynamically attach a stencil buffer | 1031 // TODO: dynamically attach a stencil buffer |
| 1032 int stencilBits = 0; | 1032 int stencilBits = 0; |
| 1033 GrStencilBuffer* stencilBuffer = | 1033 GrStencilBuffer* stencilBuffer = |
| 1034 drawState.getRenderTarget()->getStencilBuffer(); | 1034 drawState.getRenderTarget()->getStencilBuffer(); |
| 1035 if (NULL != stencilBuffer) { | 1035 if (NULL != stencilBuffer) { |
| 1036 stencilBits = stencilBuffer->bits(); | 1036 stencilBits = stencilBuffer->bits(); |
| 1037 this->adjustStencilParams(settings, clipMode, stencilBits); | 1037 this->adjustStencilParams(settings, clipMode, stencilBits); |
| 1038 } | 1038 } |
| 1039 } | 1039 } |
| OLD | NEW |