// ColorStopsAreEqual bool BGradient::ColorStopsAreEqual(const BGradient& other) const { int32 count = CountColorStops(); if (count == other.CountColorStops() && fType == other.fType) { bool equal = true; for (int32 i = 0; i < count; i++) { ColorStop* ourStop = ColorStopAtFast(i); ColorStop* otherStop = other.ColorStopAtFast(i); if (*ourStop != *otherStop) { equal = false; break; } } return equal; } return false; }
status_t ServerLink::AttachGradient(const BGradient& gradient) { GTRACE(("ServerLink::AttachGradient\n")); BGradient::Type gradientType = gradient.GetType(); int32 stopCount = gradient.CountColorStops(); GTRACE(("ServerLink::AttachGradient> color stop count == %d\n", (int)stopCount)); fSender->Attach(&gradientType, sizeof(BGradient::Type)); fSender->Attach(&stopCount, sizeof(int32)); if (stopCount > 0) { for (int i = 0; i < stopCount; i++) { fSender->Attach(gradient.ColorStopAtFast(i), sizeof(BGradient::ColorStop)); } } switch (gradientType) { case BGradient::TYPE_LINEAR: { GTRACE(("ServerLink::AttachGradient> type == TYPE_LINEAR\n")); const BGradientLinear* linear = (BGradientLinear*)&gradient; fSender->Attach(linear->Start()); fSender->Attach(linear->End()); break; } case BGradient::TYPE_RADIAL: { GTRACE(("ServerLink::AttachGradient> type == TYPE_RADIAL\n")); const BGradientRadial* radial = (BGradientRadial*)&gradient; BPoint center = radial->Center(); float radius = radial->Radius(); fSender->Attach(¢er, sizeof(BPoint)); fSender->Attach(&radius, sizeof(float)); break; } case BGradient::TYPE_RADIAL_FOCUS: { GTRACE(("ServerLink::AttachGradient> type == TYPE_RADIAL_FOCUS\n")); const BGradientRadialFocus* radialFocus = (BGradientRadialFocus*)&gradient; BPoint center = radialFocus->Center(); BPoint focal = radialFocus->Focal(); float radius = radialFocus->Radius(); fSender->Attach(¢er, sizeof(BPoint)); fSender->Attach(&focal, sizeof(BPoint)); fSender->Attach(&radius, sizeof(float)); break; } case BGradient::TYPE_DIAMOND: { GTRACE(("ServerLink::AttachGradient> type == TYPE_DIAMOND\n")); const BGradientDiamond* diamond = (BGradientDiamond*)&gradient; BPoint center = diamond->Center(); fSender->Attach(¢er, sizeof(BPoint)); break; } case BGradient::TYPE_CONIC: { GTRACE(("ServerLink::AttachGradient> type == TYPE_CONIC\n")); const BGradientConic* conic = (BGradientConic*)&gradient; BPoint center = conic->Center(); float angle = conic->Angle(); fSender->Attach(¢er, sizeof(BPoint)); fSender->Attach(&angle, sizeof(float)); break; } case BGradient::TYPE_NONE: { GTRACE(("ServerLink::AttachGradient> type == TYPE_NONE\n")); break; } } return B_OK; }