From: csmartdalton Date: Tue, 23 Aug 2016 13:51:00 +0000 (-0700) Subject: Reduce window rectangles cap to 8 X-Git-Tag: submit/tizen/20180928.044319~116^2~49 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=7535f419e235e224559ee2b4b62ee6bfddc01556;p=platform%2Fupstream%2FlibSkiaSharp.git Reduce window rectangles cap to 8 Lowers the cap to 8 and adds a warning message if this value is ever exceeded. The largest (only) implementation currently supports 8, so there isn't yet reason to go higher. BUG=skia: GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2254013002 Committed: https://skia.googlesource.com/skia/+/52d721580ee22525c285e2d13cf3975a7a1b2843 Review-Url: https://codereview.chromium.org/2254013002 --- diff --git a/src/gpu/GrCaps.cpp b/src/gpu/GrCaps.cpp index 622c6855fa..9f92210ae8 100644 --- a/src/gpu/GrCaps.cpp +++ b/src/gpu/GrCaps.cpp @@ -141,6 +141,8 @@ void GrCaps::applyOptionsOverrides(const GrContextOptions& options) { fMaxTileSize = options.fMaxTileSizeOverride; } if (fMaxWindowRectangles > GrWindowRectangles::kMaxWindows) { + SkDebugf("WARNING: capping window rectangles at %i. HW advertises support for %i.\n", + GrWindowRectangles::kMaxWindows, fMaxWindowRectangles); fMaxWindowRectangles = GrWindowRectangles::kMaxWindows; } } diff --git a/src/gpu/GrWindowRectangles.h b/src/gpu/GrWindowRectangles.h index 682af9353d..b2f6e1ab4a 100644 --- a/src/gpu/GrWindowRectangles.h +++ b/src/gpu/GrWindowRectangles.h @@ -13,7 +13,7 @@ class GrWindowRectangles { public: - constexpr static int kMaxWindows = 16; + constexpr static int kMaxWindows = 8; enum class Mode : bool { kExclusive, @@ -25,7 +25,7 @@ public: ~GrWindowRectangles() { SkSafeUnref(this->rec()); } Mode mode() const { return fMode; } - uint16_t count() const { return fCount; } + int count() const { return fCount; } bool disabled() const { return Mode::kExclusive == fMode && !fCount; } const SkIRect* data() const; diff --git a/src/gpu/gl/GrGLGpu.cpp b/src/gpu/gl/GrGLGpu.cpp index 3e44138328..83d2df29bf 100644 --- a/src/gpu/gl/GrGLGpu.cpp +++ b/src/gpu/gl/GrGLGpu.cpp @@ -2004,17 +2004,21 @@ void GrGLGpu::flushWindowRectangles(const GrWindowRectangles& windows, const GrG if (!this->caps()->maxWindowRectangles() || fHWWindowRects.equal(rt->origin(), rt->getViewport(), windows)) { return; - } + // This is purely a workaround for a spurious warning generated by gcc. Otherwise the above + // assert would be sufficient. https://gcc.gnu.org/bugzilla/show_bug.cgi?id=5912 + int numWindows = SkTMin(windows.count(), int(GrWindowRectangles::kMaxWindows)); + SkASSERT(windows.count() == numWindows); + GrGLIRect glwindows[GrWindowRectangles::kMaxWindows]; const SkIRect* skwindows = windows.data(); - for (int i = 0; i < windows.count(); ++i) { + for (int i = 0; i < numWindows; ++i) { glwindows[i].setRelativeTo(rt->getViewport(), skwindows[i], rt->origin()); } GrGLenum glmode = (Mode::kExclusive == windows.mode()) ? GR_GL_EXCLUSIVE : GR_GL_INCLUSIVE; - GL_CALL(WindowRectangles(glmode, windows.count(), glwindows->asInts())); + GL_CALL(WindowRectangles(glmode, numWindows, glwindows->asInts())); fHWWindowRects.set(rt->origin(), rt->getViewport(), windows); }