| Index: src/gpu/GrGpu.cpp
|
| diff --git a/src/gpu/GrGpu.cpp b/src/gpu/GrGpu.cpp
|
| index e7adf0b3219ae8c2f55165042342f92afdc53d83..c83a651a6c728efa7efa5c604df87a3ee31aad49 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,57 @@ 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;
|
| + SkSTArray<16, SkPoint, true> samplePattern;
|
| + this->onGetMultisampleSpecs(rt, stencil, &specs->fEffectiveSampleCnt, &samplePattern);
|
| + if (this->caps()->sampleLocationsSupport()) {
|
| + SkASSERT(!samplePattern.empty());
|
| + const auto& result = fKnownSamplePatterns.emplace(samplePattern, 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::SamplePatternComparator::operator()(const SamplePattern& a,
|
| + const SamplePattern& b) const {
|
| + if (a.count() != b.count()) {
|
| + return a.count() < b.count();
|
| + }
|
| + for (int i = 0; i < a.count(); ++i) {
|
| + // This doesn't have geometric meaning. We just need to define an ordering for std::map.
|
| + if (a[i].x() != b[i].x()) {
|
| + return a[i].x() < b[i].x();
|
| + }
|
| + if (a[i].y() != b[i].y()) {
|
| + return a[i].y() < b[i].y();
|
| + }
|
| + }
|
| + return false; // Equal.
|
| +}
|
| +
|
| ////////////////////////////////////////////////////////////////////////////////
|
|
|
| void GrGpu::draw(const DrawArgs& args, const GrVertices& vertices) {
|
|
|