aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar commit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>2014-03-10 07:40:03 +0000
committerGravatar commit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>2014-03-10 07:40:03 +0000
commitb471a32460a44043e1f00d28cbefc87579dc30c5 (patch)
tree45d6a1f65ae6268bca369b6502e0f2f33df049f9
parenta5cb2141325c73dd34d005e9d0b6905ebfa2c659 (diff)
Add API for GrContext to recommend rendertarget sample count
Add GrContext::getRecommendedSampleCount method that can be used to determine which GPU backend and what exact sample count is recommendeded for a particular render target at particular dpi. Make this initially recommend 4xMSAA for contexts which have NVPR enabled if dpi is 250 or more, 16 if dpi is less than 250 and no MSAA for others. BUG=chromium:347962 R=bsalomon@google.com Author: kkinnunen@nvidia.com Review URL: https://codereview.chromium.org/188403003 git-svn-id: http://skia.googlecode.com/svn/trunk@13717 2bbb7eff-a529-9590-31e7-b0007b416f81
-rw-r--r--include/gpu/GrContext.h13
-rw-r--r--src/gpu/GrContext.cpp17
2 files changed, 30 insertions, 0 deletions
diff --git a/include/gpu/GrContext.h b/include/gpu/GrContext.h
index ad3789b1a8..1834586578 100644
--- a/include/gpu/GrContext.h
+++ b/include/gpu/GrContext.h
@@ -306,6 +306,19 @@ public:
*/
int getMaxSampleCount() const;
+ /**
+ * Returns the recommended sample count for a render target when using this
+ * context.
+ *
+ * @param config the configuration of the render target.
+ * @param dpi the display density in dots per inch.
+ *
+ * @return sample count that should be perform well and have good enough
+ * rendering quality for the display. Alternatively returns 0 if
+ * MSAA is not supported or recommended to be used by default.
+ */
+ int getRecommendedSampleCount(GrPixelConfig config, SkScalar dpi) const;
+
///////////////////////////////////////////////////////////////////////////
// Backend Surfaces
diff --git a/src/gpu/GrContext.cpp b/src/gpu/GrContext.cpp
index bb0f4fa9fa..c7e3433938 100644
--- a/src/gpu/GrContext.cpp
+++ b/src/gpu/GrContext.cpp
@@ -1703,6 +1703,23 @@ bool GrContext::isConfigRenderable(GrPixelConfig config, bool withMSAA) const {
return fGpu->caps()->isConfigRenderable(config, withMSAA);
}
+int GrContext::getRecommendedSampleCount(GrPixelConfig config,
+ SkScalar dpi) const {
+ if (!this->isConfigRenderable(config, true)) {
+ return 0;
+ }
+ int chosenSampleCount = 0;
+ if (fGpu->caps()->pathRenderingSupport()) {
+ if (dpi >= 250.0f) {
+ chosenSampleCount = 4;
+ } else {
+ chosenSampleCount = 16;
+ }
+ }
+ return chosenSampleCount <= fGpu->caps()->maxSampleCount() ?
+ chosenSampleCount : 0;
+}
+
void GrContext::setupDrawBuffer() {
SkASSERT(NULL == fDrawBuffer);
SkASSERT(NULL == fDrawBufferVBAllocPool);