| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 Google Inc. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 6 */ | 6 */ |
| 7 #include <new> | 7 #include <new> |
| 8 #include "SkBBoxHierarchy.h" | 8 #include "SkBBoxHierarchy.h" |
| 9 #include "SkDrawPictureCallback.h" | 9 #include "SkDrawPictureCallback.h" |
| 10 #include "SkPictureData.h" | 10 #include "SkPictureData.h" |
| (...skipping 651 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 662 SkTQSort<SkPictureStateTree::Draw>( | 662 SkTQSort<SkPictureStateTree::Draw>( |
| 663 reinterpret_cast<SkPictureStateTree::Draw**>(activeOps->fOps.begin()
), | 663 reinterpret_cast<SkPictureStateTree::Draw**>(activeOps->fOps.begin()
), |
| 664 reinterpret_cast<SkPictureStateTree::Draw**>(activeOps->fOps.end()-1
)); | 664 reinterpret_cast<SkPictureStateTree::Draw**>(activeOps->fOps.end()-1
)); |
| 665 } | 665 } |
| 666 | 666 |
| 667 return activeOps; | 667 return activeOps; |
| 668 } | 668 } |
| 669 | 669 |
| 670 #if SK_SUPPORT_GPU | 670 #if SK_SUPPORT_GPU |
| 671 bool SkPictureData::suitableForGpuRasterization(GrContext* context, const char *
*reason, | 671 bool SkPictureData::suitableForGpuRasterization(GrContext* context, const char *
*reason, |
| 672 int sampleCount) const { | 672 int sampleCount) const { |
| 673 // TODO: the heuristic used here needs to be refined | 673 return fContentInfo.suitableForGpuRasterization(context, reason, sampleCount
); |
| 674 static const int kNumPaintWithPathEffectUsesTol = 1; | |
| 675 static const int kNumAAConcavePaths = 5; | |
| 676 | |
| 677 SkASSERT(fContentInfo.numAAHairlineConcavePaths() <= fContentInfo.numAAConca
vePaths()); | |
| 678 | |
| 679 int numNonDashedPathEffects = fContentInfo.numPaintWithPathEffectUses() - | |
| 680 fContentInfo.numFastPathDashEffects(); | |
| 681 | |
| 682 bool suitableForDash = (0 == fContentInfo.numPaintWithPathEffectUses()) || | |
| 683 (numNonDashedPathEffects < kNumPaintWithPathEffectUse
sTol | |
| 684 && 0 == sampleCount); | |
| 685 | |
| 686 bool ret = suitableForDash && | |
| 687 (fContentInfo.numAAConcavePaths() - fContentInfo.numAAHairli
neConcavePaths()) | |
| 688 < kNumAAConcavePaths; | |
| 689 if (!ret && NULL != reason) { | |
| 690 if (!suitableForDash) { | |
| 691 if (0 != sampleCount) { | |
| 692 *reason = "Can't use multisample on dash effect."; | |
| 693 } else { | |
| 694 *reason = "Too many non dashed path effects."; | |
| 695 } | |
| 696 } else if ((fContentInfo.numAAConcavePaths() - fContentInfo.numAAHairlin
eConcavePaths()) | |
| 697 >= kNumAAConcavePaths) | |
| 698 *reason = "Too many anti-aliased concave paths."; | |
| 699 else | |
| 700 *reason = "Unknown reason for GPU unsuitability."; | |
| 701 } | |
| 702 return ret; | |
| 703 } | 674 } |
| 704 | 675 |
| 705 bool SkPictureData::suitableForGpuRasterization(GrContext* context, const char *
*reason, | 676 bool SkPictureData::suitableForGpuRasterization(GrContext* context, const char *
*reason, |
| 706 GrPixelConfig config, SkScalar d
pi) const { | 677 GrPixelConfig config, SkScalar d
pi) const { |
| 707 | 678 |
| 708 if (context != NULL) { | 679 if (context != NULL) { |
| 709 return this->suitableForGpuRasterization(context, reason, | 680 return this->suitableForGpuRasterization(context, reason, |
| 710 context->getRecommendedSampleCo
unt(config, dpi)); | 681 context->getRecommendedSampleCo
unt(config, dpi)); |
| 711 } else { | 682 } else { |
| 712 return this->suitableForGpuRasterization(NULL, reason); | 683 return this->suitableForGpuRasterization(NULL, reason); |
| (...skipping 504 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1217 for (index = 0; index < fPictureCount; index++) | 1188 for (index = 0; index < fPictureCount; index++) |
| 1218 bufferPtr += snprintf(bufferPtr, DUMP_BUFFER_SIZE - (bufferPtr - pBuffer
), | 1189 bufferPtr += snprintf(bufferPtr, DUMP_BUFFER_SIZE - (bufferPtr - pBuffer
), |
| 1219 "picture%p, ", fPictureRefs[index]); | 1190 "picture%p, ", fPictureRefs[index]); |
| 1220 if (fPictureCount > 0) | 1191 if (fPictureCount > 0) |
| 1221 SkDebugf("%s0};\n", pBuffer); | 1192 SkDebugf("%s0};\n", pBuffer); |
| 1222 | 1193 |
| 1223 const_cast<SkPictureData*>(this)->dumpStream(); | 1194 const_cast<SkPictureData*>(this)->dumpStream(); |
| 1224 } | 1195 } |
| 1225 | 1196 |
| 1226 #endif | 1197 #endif |
| OLD | NEW |