void GL::EnableClipPlanes(const ConvexPolygon& aPolygon, UniqueId aPolygonId) { MOZ_ASSERT(IsCurrent()); MOZ_ASSERT(aPolygon.NumSides() <= mMaxClipPlanes); if (mClipPolygonId == aPolygonId) { return; } if (aPolygon.IsEmpty()) { if (!mNumClipPlanes) { Enable(GL_CLIP_PLANE0); } else { for (size_t i = 1; i < mNumClipPlanes; i++) { Disable(GL_CLIP_PLANE0 + i); } } mNumClipPlanes = 1; // We specify a single clip plane equation that fails for all vertices. const double planeEquation[] = {0, 0, 0, -1}; ClipPlane(GL_CLIP_PLANE0, planeEquation); mClipPolygonId = aPolygonId; return; } for (size_t i = mNumClipPlanes; i < aPolygon.NumSides(); i++) { Enable(GL_CLIP_PLANE0 + i); } for (size_t i = aPolygon.NumSides(); i < mNumClipPlanes; i++) { Disable(GL_CLIP_PLANE0 + i); } mNumClipPlanes = aPolygon.NumSides(); for (size_t i = 0; i < aPolygon.NumSides(); i++) { const Line& line = aPolygon.Sides()[i]; const double planeEquation[] = {line.A, line.B, 0, -line.C}; ClipPlane(GL_CLIP_PLANE0 + i, planeEquation); } mClipPolygonId = aPolygonId; }
ClipPlane *ClipPlane::getOrCreate(int plane) { return getOrCreateImpl(ClipPlane(plane)); }