aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/GrGpu.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/gpu/GrGpu.cpp')
-rw-r--r--src/gpu/GrGpu.cpp43
1 files changed, 43 insertions, 0 deletions
diff --git a/src/gpu/GrGpu.cpp b/src/gpu/GrGpu.cpp
index a8b022a36d..eb005d110a 100644
--- a/src/gpu/GrGpu.cpp
+++ b/src/gpu/GrGpu.cpp
@@ -36,6 +36,7 @@ GrGpu::GrGpu(GrContext* context)
: fResetTimestamp(kExpiredTimestamp+1)
, fResetBits(kAll_GrBackendState)
, fContext(context) {
+ fMultisampleSpecs.emplace_back(0, 0, nullptr); // Index 0 is an invalid unique id.
}
GrGpu::~GrGpu() {}
@@ -422,6 +423,48 @@ void GrGpu::didWriteToSurface(GrSurface* surface, const SkIRect* bounds, uint32_
}
}
+const GrGpu::MultisampleSpecs& GrGpu::queryMultisampleSpecs(const GrPipeline& pipeline) {
+ GrRenderTarget* rt = pipeline.renderTarget();
+ SkASSERT(rt->numStencilSamples() > 1);
+
+ GrStencilSettings stencil;
+ if (pipeline.isStencilEnabled()) {
+ // TODO: attach stencil and create settings during render target flush.
+ SkASSERT(rt->renderTargetPriv().getStencilAttachment());
+ stencil.reset(*pipeline.getUserStencil(), pipeline.hasStencilClip(),
+ rt->renderTargetPriv().numStencilBits());
+ }
+
+ int effectiveSampleCnt;
+ SkSTArray<16, SkPoint, true> pattern;
+ this->onQueryMultisampleSpecs(rt, pipeline.proxy()->origin(), stencil,
+ &effectiveSampleCnt, &pattern);
+ SkASSERT(effectiveSampleCnt >= rt->numStencilSamples());
+
+ uint8_t id;
+ if (this->caps()->sampleLocationsSupport()) {
+ SkASSERT(pattern.count() == effectiveSampleCnt);
+ const auto& insertResult = fMultisampleSpecsIdMap.insert(
+ MultisampleSpecsIdMap::value_type(pattern, SkTMin(fMultisampleSpecs.count(), 255)));
+ id = insertResult.first->second;
+ if (insertResult.second) {
+ // This means the insert did not find the pattern in the map already, and therefore an
+ // actual insertion took place. (We don't expect to see many unique sample patterns.)
+ const SkPoint* sampleLocations = insertResult.first->first.begin();
+ SkASSERT(id == fMultisampleSpecs.count());
+ fMultisampleSpecs.emplace_back(id, effectiveSampleCnt, sampleLocations);
+ }
+ } else {
+ id = effectiveSampleCnt;
+ for (int i = fMultisampleSpecs.count(); i <= id; ++i) {
+ fMultisampleSpecs.emplace_back(i, i, nullptr);
+ }
+ }
+ SkASSERT(id > 0);
+
+ return fMultisampleSpecs[id];
+}
+
bool GrGpu::SamplePatternComparator::operator()(const SamplePattern& a,
const SamplePattern& b) const {
if (a.count() != b.count()) {