Index: src/gpu/GrGpu.cpp |
diff --git a/src/gpu/GrGpu.cpp b/src/gpu/GrGpu.cpp |
index e7adf0b3219ae8c2f55165042342f92afdc53d83..d7a8db0891b3c3f2df08c735b84ea48738ab8134 100644 |
--- a/src/gpu/GrGpu.cpp |
+++ b/src/gpu/GrGpu.cpp |
@@ -46,6 +46,7 @@ GrVertices& GrVertices::operator =(const GrVertices& di) { |
GrGpu::GrGpu(GrContext* context) |
: fResetTimestamp(kExpiredTimestamp+1) |
, fResetBits(kAll_GrBackendState) |
+ , fNextSamplePatternID(1) |
, fContext(context) { |
} |
@@ -369,6 +370,55 @@ void GrGpu::resolveRenderTarget(GrRenderTarget* target) { |
this->onResolveRenderTarget(target); |
} |
+const GrGpu::MultisampleSpecs& GrGpu::getMultisampleSpecs(GrRenderTarget* rt, |
+ const GrStencilSettings& stencil) { |
+ skstd::unique_ptr<MultisampleSpecs>* specsPtr; |
+ bool willUseRasterMultisample = rt->hasMixedSamples() && stencil.isDisabled(); |
+ if (willUseRasterMultisample) { |
+ int rasterSampleCnt = rt->desc().fSampleCnt; |
+ SkASSERT(rasterSampleCnt > 0); |
+ fRasterMultisampleSpecs.resize_back(SkTMax(fRasterMultisampleSpecs.count(), |
+ rasterSampleCnt)); |
+ specsPtr = &fRasterMultisampleSpecs[rasterSampleCnt - 1]; |
+ } else { |
+ specsPtr = rt->renderTargetPriv().accessMultisampleSpecs(); |
+ } |
+ if (!specsPtr->get()) { |
+ MultisampleSpecs* specs = new MultisampleSpecs; |
+ SamplePattern pattern; |
+ this->onGetMultisampleSpecs(rt, stencil, &specs->fEffectiveSampleCnt, &pattern); |
+ if (this->caps()->sampleLocationsSupport()) { |
+ SkASSERT(!pattern.empty()); |
+ const auto& result = fKnownSamplePatterns.emplace(pattern, fNextSamplePatternID); |
+ if (result.second) { |
+ // This sample pattern didn't exist already in the map. (We don't expect to see very |
+ // many unique sample patterns). |
+ SkASSERT(fKnownSamplePatterns.size() < 65535); |
+ do {} while (0 == ++fNextSamplePatternID); |
+ } |
+ specs->fSamplePatternID = result.first->second; |
+ specs->fSampleLocations = result.first->first.begin(); |
+ } |
+ specsPtr->reset(specs); |
+ } |
+ return *specsPtr->get(); |
+} |
+ |
+bool GrGpu::SamplePattern::operator <(const SamplePattern& other) const { |
+ if (this->count() != other.count()) { |
+ return this->count() < other.count(); |
+ } |
+ for (int i = 0; i < this->count(); ++i) { |
+ if ((*this)[i].x() != other[i].x()) { |
+ return (*this)[i].x() < other[i].x(); |
+ } |
+ if ((*this)[i].y() != other[i].y()) { |
+ return (*this)[i].y() < other[i].y(); |
+ } |
Mark Kilgard
2016/02/22 18:41:04
should you use SkPoint::operator< instead if it ex
Chris Dalton
2016/02/22 19:10:43
This particular test doesn't have any real geometr
Chris Dalton
2016/02/22 22:17:55
Done.
|
+ } |
+ return false; // Equal. |
+} |
+ |
//////////////////////////////////////////////////////////////////////////////// |
void GrGpu::draw(const DrawArgs& args, const GrVertices& vertices) { |