TemporalConstraintView::TemporalConstraintView( TemporalConstraintPresenter &presenter, QGraphicsObject* parent) : ConstraintView {presenter, parent}, m_bgColor{ScenarioStyle::instance().ConstraintDefaultBackground}, m_labelItem{new SimpleTextItem{this}}, m_counterItem{new SimpleTextItem{this}} { this->setParentItem(parent); this->setZValue(ZPos::Constraint); m_leftBrace = new LeftBraceView{*this, this}; m_leftBrace->setX(minWidth()); m_rightBrace = new RightBraceView{*this, this}; m_rightBrace->setX(maxWidth()); const int fontSize = 12; auto f = Skin::instance().SansFont; f.setBold(false); f.setPointSize(fontSize); f.setStyleStrategy(QFont::NoAntialias); m_labelItem->setFont(f); m_labelItem->setPos(0, -16); m_labelItem->setAcceptedMouseButtons(Qt::MouseButton::NoButton); m_labelItem->setAcceptHoverEvents(false); f.setPointSize(7); f.setStyleStrategy(QFont::NoAntialias); m_counterItem->setFont(f); m_counterItem->setColor(ColorRef(&Skin::Light)); m_counterItem->setAcceptedMouseButtons(Qt::MouseButton::NoButton); m_counterItem->setAcceptHoverEvents(false); }
void FullViewConstraintView::paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget) { int min_w = static_cast<int>(minWidth()); int max_w = static_cast<int>(maxWidth()); int def_w = static_cast<int>(defaultWidth()); QColor c; if(isSelected()) { c = ScenarioStyle::instance().ConstraintSelected; } else if(parentItem()->isSelected()) { c = ScenarioStyle::instance().ConstraintFullViewParentSelected; } else { c = ScenarioStyle::instance().ConstraintBase; } m_solidPen.setColor(c); m_dashPen.setColor(c); if(min_w == max_w) { painter->setPen(m_solidPen); painter->drawLine(0, 0, def_w, 0); } else { // Firs the line going from 0 to the min painter->setPen(m_solidPen); painter->drawLine(0, 0, min_w, 0); // The little hat painter->drawLine(min_w, -5, min_w, -15); painter->drawLine(min_w, -15, max_w, -15); painter->drawLine(max_w, -5, max_w, -15); // Finally the dashed line painter->setPen(m_dashPen); painter->drawLine(min_w, 0, max_w, 0); } /* QLinearGradient gradient {qreal(max_w), 0, qreal(max_w + 200), 0}; gradient.setColorAt(0, Qt::black); gradient.setColorAt(1, Qt::transparent); QBrush brush {gradient}; painter->setBrush(brush); painter->setPen(QPen(brush, 4)); painter->drawLine(max_w, 0, max_w + 200, 0); */ }
double DetectorModule::stripOccupancyPerEventBarrel() const { double rho = center().Rho()/10.; double theta = center().Theta(); double myOccupancyBarrel=(1.63e-4)+(2.56e-4)*rho-(1.92e-6)*rho*rho; double factor = fabs(sin(theta))*2; // 2 is a magic adjustment factor double dphideta = phiAperture() * etaAperture(); double minNSegments = minSegments(); int numStripsAcrossEstimate = sensors().begin()->numStripsAcrossEstimate(); double modWidth = (maxWidth() + minWidth())/2.; double occupancy = myOccupancyBarrel / factor / (90/1e3) * (dphideta / minNSegments) * (modWidth / numStripsAcrossEstimate); return occupancy; }
double DetectorModule::stripOccupancyPerEventEndcap() const { double rho = center().Rho()/10.; double theta = center().Theta(); double z = center().Z()/10.; double myOccupancyEndcap = (-6.20e-5)+(1.75e-4)*rho-(1.08e-6)*rho*rho+(1.50e-5)*(z); double factor=fabs(cos(theta))*2; // 2 is a magic adjustment factor double dphideta = phiAperture() * etaAperture(); double minNSegments = minSegments(); int numStripsAcrossEstimate = sensors().begin()->numStripsAcrossEstimate(); double modWidth = (maxWidth() + minWidth())/2.; double occupancy = myOccupancyEndcap / factor / (90/1e3) * (dphideta / minNSegments) * (modWidth / numStripsAcrossEstimate); return occupancy; }
void TemporalConstraintView::paint( QPainter* painter, const QStyleOptionGraphicsItem*, QWidget*) { qreal min_w = minWidth(); qreal max_w = maxWidth(); qreal def_w = defaultWidth(); qreal play_w = playWidth(); // Draw the stuff present if there is a rack *in the model* ? if(presenter().rack()) { // Background auto rect = boundingRect(); rect.adjust(0,15,0,-10); rect.setWidth(this->defaultWidth()); painter->fillRect(rect, m_bgColor); // Fake timenode continuation auto color = ScenarioStyle::instance().RackSideBorder; QPen pen{color, 2, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin}; painter->setPen(pen); painter->drawLine(rect.topLeft(), rect.bottomLeft()); painter->drawLine(rect.topRight(), rect.bottomRight()); } QPainterPath solidPath, dashedPath, leftBrace, rightBrace; // Paths if(infinite()) { if(min_w != 0.) { solidPath.lineTo(min_w, 0); leftBrace.moveTo(min_w, -10); leftBrace.arcTo(min_w - 10, -10, 20, 20, 90, 180); } // TODO end state should be hidden dashedPath.moveTo(min_w, 0); dashedPath.lineTo(def_w, 0); } else if(min_w == max_w) // TODO rigid() { solidPath.lineTo(def_w, 0); } else { if(min_w != 0.) solidPath.lineTo(min_w, 0); dashedPath.moveTo(min_w, 0); dashedPath.lineTo(max_w, 0); leftBrace.moveTo(min_w + 10, -10); leftBrace.arcTo(min_w, -10, 20, 20, 90, 180); leftBrace.closeSubpath(); rightBrace.moveTo(max_w, 10); rightBrace.arcTo(max_w - 10, -10, 20, 20, 270, 180); rightBrace.closeSubpath(); rightBrace.translate(-10, 0); // TODO bleh. } QPainterPath playedPath; if(play_w != 0.) { playedPath.lineTo(play_w, 0); } // Colors QColor constraintColor; // TODO make a switch instead if(isSelected()) { constraintColor = ScenarioStyle::instance().ConstraintSelected; } else if(warning()) { constraintColor = ScenarioStyle::instance().ConstraintWarning; } else { constraintColor = ScenarioStyle::instance().ConstraintBase; } if(! isValid()) { constraintColor = ScenarioStyle::instance().ConstraintInvalid; this->setZValue(this->zValue()+ 1); } else { this->setZValue(parentObject()->zValue() + 3); } m_solidPen.setColor(constraintColor); m_dashPen.setColor(constraintColor); // Drawing painter->setPen(m_solidPen); if(!solidPath.isEmpty()) painter->drawPath(solidPath); if(!leftBrace.isEmpty()) painter->drawPath(leftBrace); if(!rightBrace.isEmpty()) painter->drawPath(rightBrace); painter->setPen(m_dashPen); if(!dashedPath.isEmpty()) painter->drawPath(dashedPath); leftBrace.closeSubpath(); rightBrace.closeSubpath(); QPen anotherPen(Qt::transparent, 4); painter->setPen(anotherPen); QColor blueish = m_solidPen.color().lighter(); blueish.setAlphaF(0.3); painter->setBrush(blueish); painter->drawPath(leftBrace); painter->drawPath(rightBrace); static const QPen playedPen{ QBrush{ScenarioStyle::instance().ConstraintPlayFill}, 4, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin }; painter->setPen(playedPen); if(!playedPath.isEmpty()) painter->drawPath(playedPath); static const int fontSize = 12; QRectF labelRect{0,0, defaultWidth(), (-fontSize - 2.)}; auto f = ProcessFonts::Sans(); f.setPointSize(fontSize); painter->setFont(f); painter->setPen(m_labelColor); painter->drawText(labelRect, Qt::AlignCenter, m_label); #if defined(ISCORE_SCENARIO_DEBUG_RECTS) painter->setPen(Qt::darkRed); painter->setBrush(Qt::NoBrush); painter->drawRect(boundingRect()); #endif }
void TemporalConstraintView::paint( QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget) { // Draw the rack bg if(auto rack = presenter().rack()) { auto rackRect = rack->view().boundingRect(); painter->fillRect(rackRect, QColor::fromRgba(qRgba(0, 127, 229, 76))); auto color = qApp->palette("ScenarioPalette").base().color(); QPen pen{color, 2, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin}; painter->setPen(pen); painter->drawLine(rackRect.topLeft(), rackRect.bottomLeft()); painter->drawLine(rackRect.topRight(), rackRect.bottomRight()); } QPainterPath solidPath, dashedPath, leftBrace, rightBrace; // m_endState->setPos(defaultWidth(), 0); // Paths if(infinite()) { if(minWidth() != 0) { solidPath.lineTo(minWidth(), 0); leftBrace.moveTo(minWidth(), -10); leftBrace.arcTo(minWidth() - 10, -10, 20, 20, 90, 180); } // TODO end state should be hidden dashedPath.moveTo(minWidth(), 0); dashedPath.lineTo(defaultWidth(), 0); } else if(minWidth() == maxWidth()) // TODO rigid() { solidPath.lineTo(defaultWidth(), 0); } else { if(minWidth() != 0) solidPath.lineTo(minWidth(), 0); dashedPath.moveTo(minWidth(), 0); dashedPath.lineTo(maxWidth(), 0); leftBrace.moveTo(minWidth(), -10); leftBrace.arcTo(minWidth() - 10, -10, 20, 20, 90, 180); rightBrace.moveTo(maxWidth(), 10); rightBrace.arcTo(maxWidth() - 10, -10, 20, 20, 270, 180); } QPainterPath playedPath; if(playWidth() != 0) { playedPath.lineTo(playWidth(), 0); } // Colors QColor constraintColor; if(isSelected()) { constraintColor = QColor::fromRgbF(0.188235, 0.54902, 0.776471); } else { constraintColor = qApp->palette("ScenarioPalette").base().color(); } if(warning()) { constraintColor = QColor{200,150,0}; } if(! isValid()) { constraintColor = Qt::red; } m_solidPen.setColor(constraintColor); m_dashPen.setColor(constraintColor); // Drawing painter->setPen(m_solidPen); if(!solidPath.isEmpty()) painter->drawPath(solidPath); if(!leftBrace.isEmpty()) painter->drawPath(leftBrace); if(!rightBrace.isEmpty()) painter->drawPath(rightBrace); painter->setPen(m_dashPen); if(!dashedPath.isEmpty()) painter->drawPath(dashedPath); leftBrace.closeSubpath(); rightBrace.closeSubpath(); QPen anotherPen(Qt::transparent, 4); painter->setPen(anotherPen); QColor blueish = m_solidPen.color().lighter(); blueish.setAlphaF(0.3); painter->setBrush(blueish); painter->drawPath(leftBrace); painter->drawPath(rightBrace); static const QPen playedPen{ QBrush{Qt::green}, 4, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin }; static const QPen dashedPlayedPen{ QBrush{Qt::green}, 4, Qt::DashLine, Qt::RoundCap, Qt::RoundJoin }; painter->setPen(playedPen); if(!playedPath.isEmpty()) painter->drawPath(playedPath); int fontSize = 12; QRectF labelRect{0,0, defaultWidth(), (-fontSize - 2.)}; QFont f("Ubuntu"); f.setPixelSize(fontSize); painter->setFont(f); painter->setPen(m_labelColor); painter->drawText(labelRect, Qt::AlignCenter, m_label); /* painter->setPen(Qt::darkRed); painter->setBrush(Qt::NoBrush); painter->drawRect(boundingRect()); */ }
void TemporalConstraintView::paint( QPainter* painter, const QStyleOptionGraphicsItem*, QWidget*) { auto& skin = ScenarioStyle::instance(); qreal min_w = minWidth(); qreal max_w = maxWidth(); qreal def_w = defaultWidth(); qreal play_w = playWidth(); m_labelItem->setPos(def_w / 2. - m_labelItem->boundingRect().width() / 2., -17); m_counterItem->setPos(def_w - m_counterItem->boundingRect().width() - 5, 5); m_leftBrace->setX(min_w); m_rightBrace->setX(max_w); // Draw the stuff present if there is a rack *in the model* ? if(presenter().rack()) { // Background auto rect = boundingRect(); rect.adjust(0,4,0,-10); rect.setWidth(this->defaultWidth()); QColor bgColor = m_bgColor.getColor(); bgColor.setAlpha(m_hasFocus ? 84 : 76); painter->fillRect(rect, bgColor); // Fake timenode continuation auto color = skin.RackSideBorder.getColor(); QPen pen{color, 2, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin}; painter->setPen(pen); painter->drawLine(rect.topLeft(), rect.bottomLeft()); painter->drawLine(rect.topRight(), rect.bottomRight()); } QPainterPath solidPath, dashedPath, leftBrace, rightBrace; // Paths if(infinite()) { if(min_w != 0.) { solidPath.lineTo(min_w, 0); m_leftBrace->show(); } m_rightBrace->hide(); // TODO end state should be hidden dashedPath.moveTo(min_w, 0); dashedPath.lineTo(def_w, 0); } else if(min_w == max_w) // TODO rigid() { solidPath.lineTo(def_w, 0); m_leftBrace->hide(); m_rightBrace->hide(); } else { if(min_w != 0.) solidPath.lineTo(min_w, 0); dashedPath.moveTo(min_w, 0); dashedPath.lineTo(max_w, 0); m_leftBrace->show(); m_rightBrace->show(); } QPainterPath playedPath; if(play_w != 0.) { playedPath.lineTo(std::min(play_w, std::max(def_w, max_w)), 0); } // Colors QColor constraintColor; // TODO make a switch instead if(isSelected()) { constraintColor = skin.ConstraintSelected.getColor(); } else if(warning()) { constraintColor = skin.ConstraintWarning.getColor(); } else { constraintColor = skin.ConstraintBase.getColor(); } if(! isValid() || m_state == ConstraintExecutionState::Disabled) { constraintColor = skin.ConstraintInvalid.getColor(); } m_solidPen.setColor(constraintColor); m_dashPen.setColor(constraintColor); // Drawing painter->setPen(m_solidPen); if(!solidPath.isEmpty()) painter->drawPath(solidPath); painter->setPen(m_dashPen); if(!dashedPath.isEmpty()) painter->drawPath(dashedPath); leftBrace.closeSubpath(); rightBrace.closeSubpath(); QPen anotherPen(Qt::transparent, 4); painter->setPen(anotherPen); QColor blueish = m_solidPen.color().lighter(); blueish.setAlphaF(0.3); painter->setBrush(blueish); const QPen playedPen{ skin.ConstraintPlayFill.getColor(), 4, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin }; painter->setPen(playedPen); if(!playedPath.isEmpty()) painter->drawPath(playedPath); { auto& dur = presenter().model().duration; auto progress = dur.defaultDuration() * dur.playPercentage(); if(!progress.isZero()) { QString percent = progress.toString(); m_counterItem->setText(percent); } } #if defined(ISCORE_SCENARIO_DEBUG_RECTS) painter->setPen(Qt::darkRed); painter->setBrush(Qt::NoBrush); painter->drawRect(boundingRect()); #endif }
bool ExynosMPP::isProcessingSupported(hwc_layer_1_t &layer, int format, bool local_path, int loc_out_downscale) { if (local_path && loc_out_downscale == 0) return false; if (isUsingMSC() && local_path) return false; private_handle_t *handle = private_handle_t::dynamicCast(layer.handle); int max_w = maxWidth(layer); int max_h = maxHeight(layer); int min_w = minWidth(layer); int min_h = minHeight(layer); int crop_max_w = 0; int crop_max_h = 0; if (isUsingMSC()) { crop_max_w = 8192; crop_max_h = 8192; } else { crop_max_w = isRotated(layer) ? 2016 : 4800; crop_max_h = isRotated(layer) ? 2016 : 3344; } int crop_min_w = isRotated(layer) ? 32: 64; int crop_min_h = isRotated(layer) ? 64: 32; int srcAlign = sourceAlign(handle->format); int dstAlign; if (local_path) dstAlign = destinationAlign(HAL_PIXEL_FORMAT_EXYNOS_YCbCr_420_SP_M); else dstAlign = destinationAlign(HAL_PIXEL_FORMAT_BGRA_8888); int maxDstWidth; int maxDstHeight; bool rot90or270 = !!(layer.transform & HAL_TRANSFORM_ROT_90); // n.b.: HAL_TRANSFORM_ROT_270 = HAL_TRANSFORM_ROT_90 | // HAL_TRANSFORM_ROT_180 int src_w = WIDTH(layer.sourceCropf), src_h = HEIGHT(layer.sourceCropf); int dest_w, dest_h; if (rot90or270) { dest_w = HEIGHT(layer.displayFrame); dest_h = WIDTH(layer.displayFrame); } else { dest_w = WIDTH(layer.displayFrame); dest_h = HEIGHT(layer.displayFrame); } if (getDrmMode(handle->flags) != NO_DRM) alignCropAndCenter(dest_w, dest_h, NULL, GSC_DST_CROP_W_ALIGNMENT_RGB888); int max_downscale = local_path ? loc_out_downscale : 16; maxDstWidth = 2560; maxDstHeight = 1600; int max_upscale = 8; /* check whether GSC can handle with local path */ if (local_path) { /* GSC OTF can't handle rot90 or rot270 */ if (!rotationSupported(rot90or270)) return 0; /* * if display co-ordinates are out of the lcd resolution, * skip that scenario to OpenGL. * GSC OTF can't handle such scenarios. */ if (layer.displayFrame.left < 0 || layer.displayFrame.top < 0 || layer.displayFrame.right > mDisplay->mXres || layer.displayFrame.bottom > mDisplay->mYres) return 0; /* GSC OTF can't handle GRALLOC_USAGE_PROTECTED layer */ if (getDrmMode(handle->flags) != NO_DRM) return 0; return isFormatSupportedByGsc(format) && isFormatSupportedByGscOtf(format) && mDisplay->mHwc->mS3DMode == S3D_MODE_DISABLED && paritySupported(dest_w, dest_h) && handle->stride <= max_w && src_w <= dest_w * max_downscale && dest_w <= maxDstWidth && dest_w <= src_w * max_upscale && handle->vstride <= max_h && src_h <= dest_h * max_downscale && dest_h <= maxDstHeight && dest_h <= src_h * max_upscale && src_w <= crop_max_w && src_h <= crop_max_h && src_w >= crop_min_w && src_h >= crop_min_h; } bool need_gsc_op_twice = false; if (getDrmMode(handle->flags) != NO_DRM) { need_gsc_op_twice = ((dest_w > src_w * max_upscale) || (dest_h > src_h * max_upscale)) ? true : false; if (need_gsc_op_twice) max_upscale = 8 * 8; } else { if (!mDisplay->mHasDrmSurface) { need_gsc_op_twice = false; max_upscale = 8; } } if (getDrmMode(handle->flags) != NO_DRM) { /* make even for gscaler */ layer.sourceCropf.top = (unsigned int)layer.sourceCropf.top & ~1; layer.sourceCropf.left = (unsigned int)layer.sourceCropf.left & ~1; layer.sourceCropf.bottom = (unsigned int)layer.sourceCropf.bottom & ~1; layer.sourceCropf.right = (unsigned int)layer.sourceCropf.right & ~1; } /* check whether GSC can handle with M2M */ return isFormatSupportedByGsc(format) && src_w >= min_w && src_h >= min_h && isDstCropWidthAligned(dest_w) && handle->stride <= max_w && handle->stride % srcAlign == 0 && src_w < dest_w * max_downscale && dest_w <= src_w * max_upscale && handle->vstride <= max_h && handle->vstride % srcAlign == 0 && src_h < dest_h * max_downscale && dest_h <= src_h * max_upscale && // per 46.2 (!rot90or270 || (unsigned int)layer.sourceCropf.top % 2 == 0) && (!rot90or270 || (unsigned int)layer.sourceCropf.left % 2 == 0) && src_w <= crop_max_w && src_h <= crop_max_h && src_w >= crop_min_w && src_h >= crop_min_h; // per 46.3.1.6 }