+deUint8 LineRenderCase::checkLineContinuity (const tcu::ConstPixelBufferAccess& access, const tcu::IVec2& begin, const tcu::IVec2& end, int componentNdx, int& messageLimitCounter) const
+{
+ bool line = false;
+ const tcu::IVec2 advance = (begin.x() == end.x()) ? (tcu::IVec2(0, 1)) : (tcu::IVec2(1, 0));
+ int missedPixels = 0;
+ int totalPixels = 0;
+ deUint8 errorMask = 0;
+
+ for (tcu::IVec2 cursor = begin; cursor != end; cursor += advance)
+ {
+ const bool hit = (access.getPixelInt(cursor.x(), cursor.y())[componentNdx] != 0);
+
+ if (hit)
+ line = true;
+ else if (line && !hit)
+ {
+ // non-continuous line detected
+ const tcu::IVec2 advanceNeighbor = tcu::IVec2(1, 1) - advance;
+ const tcu::IVec2 cursorNeighborPos = cursor + advanceNeighbor;
+ const tcu::IVec2 cursorNeighborNeg = cursor - advanceNeighbor;
+ // hw precision issues may lead to a line being non-straight -> check neighboring pixels
+ if ((access.getPixelInt(cursorNeighborPos.x(), cursorNeighborPos.y())[componentNdx] == 0) && (access.getPixelInt(cursorNeighborNeg.x(), cursorNeighborNeg.y())[componentNdx] == 0))
+ ++missedPixels;
+ }
+ ++totalPixels;
+ }
+
+ if (missedPixels > 0 && --messageLimitCounter >= 0)
+ {
+ m_testCtx.getLog()
+ << tcu::TestLog::Message
+ << "Found non-continuous " << ((advance.x() == 1) ? ("horizontal") : ("vertical")) << " line near " << begin << ". "
+ << "Missed pixels: " << missedPixels
+ << tcu::TestLog::EndMessage;
+ // allow 10% missing pixels for warning
+ if (missedPixels <= deRoundFloatToInt32(totalPixels * 0.1f))
+ errorMask = SCANRESULT_LINE_CONT_WARN_BIT;
+ else
+ errorMask = SCANRESULT_LINE_CONT_ERR_BIT;
+ }
+
+ return errorMask;
+}
+