void SearchButton::paintEvent(QPaintEvent *e){ QPainter p(this); p.setRenderHint(p.Antialiasing); QColor fg; if (this->isChecked()){ QColor c1,c2; QLinearGradient lg1(0,0,0,this->height()); c1.setRgb(54,102,164); c2.setRgb(102,157,206); p.setPen(c1); lg1.setColorAt(0,c2); lg1.setColorAt(1,c1); p.setBrush(lg1); p.drawRect(0,0,this->width(),this->height()); fg.setRgb(255,255,255); } else fg.setRgb(60,60,60); QPen p1; p1.setColor(fg); p1.setWidth(4); p1.setCapStyle(Qt::RoundCap); p.setBrush(Qt::transparent); p.setPen(p1); int xc,yc; xc=this->width()/2; yc=this->height()/2; p.drawEllipse(xc-7,yc-6,10,10); p.drawLine(xc+2,yc+4,xc+5,yc+8); e->accept(); }
FiberPool_::~FiberPool_() { { std::lock_guard<std::mutex> lg(_clearMutex); _exitSign = true; if (_clearWait) { _clearWait = false; _clearVar.notify_one(); } } _clearThread.join(); int ic = 0; for (int i = 0; i < 256; i++) { std::lock_guard<std::mutex> lg1(_fiberPool[i]._mutex); while (!_fiberPool[i]._pool.empty()) { coro_pull_interface* pull = _fiberPool[i]._pool.back(); _fiberPool[i]._pool.pop_back(); DeleteFiber(pull->_fiber._fiberHandle); delete pull; _stackCount--; } } assert(0 == _stackCount); }
ActorStackPool_::~ActorStackPool_() { { boost::lock_guard<boost::mutex> lg(_clearMutex); _exit = true; if (_clearWait) { _clearWait = false; _clearVar.notify_one(); } } _clearThread.join(); int ic = 0; vector<void*> tempPool; tempPool.resize(_stackCount); for (int i = 0; i < 256; i++) { boost::lock_guard<boost::mutex> lg1(_stackPool[i]._mutex); while (!_stackPool[i]._pool.empty()) { StackPck_ pck = _stackPool[i]._pool.back(); _stackPool[i]._pool.pop_back(); tempPool[ic++] = ((char*)pck._stack.sp) - pck._stack.size; CHECK_STACK(pck); _stackCount--; } } assert(0 == _stackCount); sort(tempPool.begin(), tempPool.end()); for (int j = 0; j < (int)tempPool.size(); j++) { free(tempPool[j]); } }
int main() { #ifdef STACK_TESTS_ON /* [STACK] */ std::thread stack_thread(stack_test_suite_main); if (stack_thread.joinable()) { stack_thread.detach(); // F&F } std::cout << stack_thread.get_id() << std::endl; #endif #ifdef QUEUE_TESTS_ON /* [QUEUE] */ std::thread queue_thread(queue_test_suite_main); //queue_thread.detach(); if (queue_thread.joinable()) { queue_thread.join(); } #endif std::thread __ttt; std::cout << __ttt.get_id() << std::endl; std::cout << std::thread::hardware_concurrency() << std::endl; std::cout << std::this_thread::get_id() << std::endl; std::mutex m1; std::mutex m2; //std::lock_guard<std::mutex> g(m1); { std::lock(m1, m2); std::lock_guard<std::mutex> lg1(m1, std::adopt_lock); std::lock_guard<std::mutex> lg2(m2, std::adopt_lock); } std::lock(m1, m2); std::lock_guard<std::mutex> lg1(m1, std::adopt_lock); std::lock_guard<std::mutex> lg2(m2, std::adopt_lock); }
int main() { boost::mutex m0; boost::unique_lock<boost::mutex> lk0(m0); { boost::reverse_lock<boost::unique_lock<boost::mutex> > lg0(lk0); boost::reverse_lock<boost::unique_lock<boost::mutex> > lg1(lg0); } }
void lg1_api(const mxArray * const prhs[1]) { real_T scale; /* Marshall function inputs */ scale = emlrt_marshallIn(emlrtAliasP(prhs[0]), "scale"); /* Invoke the target function */ lg1(scale); }
void mySpeedWatch::drawCrown(QPainter *painter) { painter->save(); int radius = 100; QLinearGradient lg1(0, -radius, 0, radius); lg1.setColorAt(0, QColor(255, 255, 255)); lg1.setColorAt(1, QColor(166, 166, 166)); painter->setBrush(lg1); painter->drawEllipse(-radius, -radius, radius << 1, radius << 1); painter->restore(); }
int main() { boost::mutex m0; boost::mutex m1; boost::unique_lock<boost::mutex> lk0(m0); boost::unique_lock<boost::mutex> lk1(m1); { boost::reverse_lock<boost::unique_lock<boost::mutex> > lg0(lk0); boost::reverse_lock<boost::unique_lock<boost::mutex> > lg1(lk1); lg1 = lg0; } }
void HighlightButton::paintEvent(QPaintEvent *) { QPainter painter(this); painter.translate(width() / 2, height() / 2); painter.setRenderHint(QPainter::Antialiasing); painter.setPen(Qt::transparent); painter.fillRect(-width(), -height(), width() * 2, height() * 2, Qt::gray); int radius = 100; // 外边框 QLinearGradient lg1(0, -radius, 0, radius); lg1.setColorAt(0, QColor(255, 255, 255)); lg1.setColorAt(1, QColor(166, 166, 166)); painter.setBrush(lg1); painter.drawEllipse(-radius, -radius, radius << 1, radius << 1); // 内边框 radius -= 13; QLinearGradient lg2(0, -radius, 0, radius); lg2.setColorAt(0, QColor(155, 155, 155)); lg2.setColorAt(1, QColor(255, 255, 255)); painter.setBrush(lg2); painter.drawEllipse(-radius, -radius, radius << 1, radius << 1); // 内部的圆 radius -= 4; QRadialGradient rg(0, 0, radius); rg.setColorAt(0, QColor(245, 0, 0)); rg.setColorAt(0.6, QColor(210, 0, 0)); rg.setColorAt(1, QColor(140, 0, 0)); painter.setBrush(rg); painter.drawEllipse(-radius, -radius, radius << 1, radius << 1); // 高光 radius -= 3; QPainterPath path; path.addEllipse(-radius, -radius - 2, radius << 1, radius << 1); QPainterPath bigEllipse; radius *= 2; bigEllipse.addEllipse(-radius, -radius + 140, radius << 1, radius << 1); path -= bigEllipse; QLinearGradient lg3(0, -radius / 2, 0, 0); lg3.setColorAt(0, QColor(255, 255, 255, 220)); lg3.setColorAt(1, QColor(255, 255, 255, 30)); painter.setBrush(lg3); painter.drawPath(path); }
void FilterButton::paintEvent(QPaintEvent *e){ QPainter p(this); p.setRenderHint(p.Antialiasing); QColor fg; if (this->isChecked()){ QColor c1,c2; QLinearGradient lg1(0,0,0,this->height()); c1.setRgb(54,102,164); c2.setRgb(102,157,206); p.setPen(c1); lg1.setColorAt(0,c2); lg1.setColorAt(1,c1); p.setBrush(lg1); p.drawRect(0,0,this->width(),this->height()); fg.setRgb(255,255,255); } else fg.setRgb(60,60,60); /* QPen p1; p1.setColor(fg); p1.setWidth(4); p1.setCapStyle(Qt::RoundCap); p.setBrush(Qt::transparent); p.setPen(p1);*/ int xc,yc; xc=this->width()/2; yc=this->height()/2; QPolygon pol(6); pol.setPoint(0,xc-8,yc-6); pol.setPoint(1,xc+8,yc-6); pol.setPoint(2,xc+2,yc+2); pol.setPoint(3,xc+2,yc+7); pol.setPoint(4,xc-2,yc+7); pol.setPoint(5,xc-2,yc+2); p.setBrush(fg); p.setPen(Qt::transparent); p.drawPolygon(pol); e->accept(); }
void tst_QBrush::testQGradientCopyConstructor() { { QLinearGradient lg1(101, 102, 103, 104); QLinearGradient lg2 = lg1; QCOMPARE(lg1.start(), lg2.start()); QCOMPARE(lg1.finalStop(), lg2.finalStop()); QGradient g = lg1; QCOMPARE(((QLinearGradient *) &g)->start(), lg1.start()); QCOMPARE(((QLinearGradient *) &g)->finalStop(), lg1.finalStop()); } { QRadialGradient rg1(101, 102, 103, 104, 105); QRadialGradient rg2 = rg1; QCOMPARE(rg1.center(), rg2.center()); QCOMPARE(rg1.focalPoint(), rg2.focalPoint()); QCOMPARE(rg1.radius(), rg2.radius()); QGradient g = rg1; QCOMPARE(((QRadialGradient *) &g)->center(), rg1.center()); QCOMPARE(((QRadialGradient *) &g)->focalPoint(), rg1.focalPoint()); QCOMPARE(((QRadialGradient *) &g)->radius(), rg1.radius()); } { QConicalGradient cg1(101, 102, 103); QConicalGradient cg2 = cg1; QCOMPARE(cg1.center(), cg2.center()); QCOMPARE(cg1.angle(), cg2.angle()); QGradient g = cg1; QCOMPARE(((QConicalGradient *) &g)->center(), cg1.center()); QCOMPARE(((QConicalGradient *) &g)->angle(), cg1.angle()); } }