コード例 #1
0
void KisScanlineFill::fillSelection(KisPixelSelectionSP pixelSelection)
{
    KisRandomConstAccessorSP it = m_d->device->createRandomConstAccessorNG(m_d->startPoint.x(), m_d->startPoint.y());
    KoColor srcColor(it->rawDataConst(), m_d->device->colorSpace());

    const int pixelSize = m_d->device->pixelSize();

    if (pixelSize == 1) {
        SelectionPolicy<true, DifferencePolicyOptimized<quint8>, CopyToSelection>
            policy(m_d->device, srcColor, m_d->threshold);
        policy.setDestinationSelection(pixelSelection);
        runImpl(policy);
    } else if (pixelSize == 2) {
        SelectionPolicy<true, DifferencePolicyOptimized<quint16>, CopyToSelection>
            policy(m_d->device, srcColor, m_d->threshold);
        policy.setDestinationSelection(pixelSelection);
        runImpl(policy);
    } else if (pixelSize == 4) {
        SelectionPolicy<true, DifferencePolicyOptimized<quint32>, CopyToSelection>
            policy(m_d->device, srcColor, m_d->threshold);
        policy.setDestinationSelection(pixelSelection);
        runImpl(policy);
    } else if (pixelSize == 8) {
        SelectionPolicy<true, DifferencePolicyOptimized<quint64>, CopyToSelection>
              policy(m_d->device, srcColor, m_d->threshold);
        policy.setDestinationSelection(pixelSelection);
        runImpl(policy);
    } else {
        SelectionPolicy<true, DifferencePolicySlow, CopyToSelection>
              policy(m_d->device, srcColor, m_d->threshold);
        policy.setDestinationSelection(pixelSelection);
        runImpl(policy);
    }
}
コード例 #2
0
void KisScanlineFill::fillColor(const KoColor &fillColor)
{
    KisRandomConstAccessorSP it = m_d->device->createRandomConstAccessorNG(m_d->startPoint.x(), m_d->startPoint.y());
    KoColor srcColor(it->rawDataConst(), m_d->device->colorSpace());

    const int pixelSize = m_d->device->pixelSize();

    if (pixelSize == 1) {
        SelectionPolicy<false, DifferencePolicyOptimized<quint8>, FillWithColor>
            policy(m_d->device, srcColor, m_d->threshold);
        policy.setFillColor(fillColor);
        runImpl(policy);
    } else if (pixelSize == 2) {
        SelectionPolicy<false, DifferencePolicyOptimized<quint16>, FillWithColor>
            policy(m_d->device, srcColor, m_d->threshold);
        policy.setFillColor(fillColor);
        runImpl(policy);
    } else if (pixelSize == 4) {
        SelectionPolicy<false, DifferencePolicyOptimized<quint32>, FillWithColor>
            policy(m_d->device, srcColor, m_d->threshold);
        policy.setFillColor(fillColor);
        runImpl(policy);
    } else if (pixelSize == 8) {
        SelectionPolicy<false, DifferencePolicyOptimized<quint64>, FillWithColor>
              policy(m_d->device, srcColor, m_d->threshold);
        policy.setFillColor(fillColor);
        runImpl(policy);
    } else {
        SelectionPolicy<false, DifferencePolicySlow, FillWithColor>
              policy(m_d->device, srcColor, m_d->threshold);
        policy.setFillColor(fillColor);
        runImpl(policy);
    }
}
コード例 #3
0
ファイル: sc_agent.cpp プロジェクト: MaximDanilov/sc-machine
sc_result ScAgentAction::run(ScAddr const & listenAddr, ScAddr const & startArcAddr)
{
    ScAddr cmdAddr = mMemoryCtx.getEdgeTarget(startArcAddr);
	if (cmdAddr.isValid())
	{
		if (mMemoryCtx.helperCheckArc(mCmdClassAddr, cmdAddr, sc_type_arc_pos_const_perm))
		{
			mMemoryCtx.eraseElement(startArcAddr);
            ScAddr progressAddr = mMemoryCtx.createEdge(sc_type_arc_pos_const_perm, msCommandProgressdAddr, cmdAddr);
			assert(progressAddr.isValid());
            ScAddr resultAddr = mMemoryCtx.createNode(sc_type_const | sc_type_node_struct);
			assert(resultAddr.isValid());

			runImpl(cmdAddr, resultAddr);

			mMemoryCtx.eraseElement(progressAddr);

            ScAddr const commonArc = mMemoryCtx.createEdge(sc_type_const | sc_type_arc_common, cmdAddr, resultAddr);
			assert(commonArc.isValid());
			ScAddr const arc = mMemoryCtx.createEdge(sc_type_arc_pos_const_perm, msNrelResult, commonArc);
			assert(arc.isValid());

			mMemoryCtx.createEdge(sc_type_arc_pos_const_perm, msCommandFinishedAddr, cmdAddr);

			return SC_RESULT_OK;
		}
	}

	return SC_RESULT_ERROR;
}
コード例 #4
0
ファイル: Float2Int.cpp プロジェクト: sunfishcode/llvm
PreservedAnalyses Float2IntPass::run(Function &F, FunctionAnalysisManager &) {
  if (!runImpl(F))
    return PreservedAnalyses::all();

  PreservedAnalyses PA;
  PA.preserveSet<CFGAnalyses>();
  PA.preserve<GlobalsAA>();
  return PA;
}
コード例 #5
0
PreservedAnalyses SpeculativeExecutionPass::run(Function &F,
                                                FunctionAnalysisManager &AM) {
  auto *TTI = &AM.getResult<TargetIRAnalysis>(F);

  bool Changed = runImpl(F, TTI);

  if (!Changed)
    return PreservedAnalyses::all();
  PreservedAnalyses PA;
  PA.preserve<GlobalsAA>();
  return PA;
}
コード例 #6
0
ファイル: scTimeLine.cpp プロジェクト: kidsang/SaberCore2
bool scTimeLine::_run( u32 dtms )
{
	// 时间控制
	mCurrentTime += dtms;
	if (mCurrentTime < mInterval)
		return true;

	// 缩放时间
	u32 time = (u32)(mCurrentTime * mScaleFactor);
	runImpl(time);

	// 时间控制
	mCurrentTime = 0;

	return true;
}
コード例 #7
0
ファイル: executor.hpp プロジェクト: batizty/LeetCodeScala
  void run() {
    *out << " +++ Start " + name() + " Quiz +++\n";
    *out << header();

    if (running_count < 1) {
      throw "This Test Case Running Count" + std::to_string(running_count) +
          " Less than 1";
    }

    for (int i = 0; i < running_count; i++) {
      *out << "  + Start " + std::to_string(i) + "th/" +
                  std::to_string(running_count) + " run +\n";
      runImpl();
    }

    *out << end();

    summary();
  }
コード例 #8
0
ファイル: CompilationDatabase.cpp プロジェクト: pkesist/clang
  void runImpl(const driver::Action *A, bool Collect) {
    bool CollectChildren = Collect;
    switch (A->getKind()) {
    case driver::Action::CompileJobClass:
      CollectChildren = true;
      break;

    case driver::Action::InputClass: {
      if (Collect) {
        const driver::InputAction *IA = cast<driver::InputAction>(A);
        Inputs.push_back(IA->getInputArg().getSpelling());
      }
    } break;

    default:
      // Don't care about others
      ;
    }

    for (driver::ActionList::const_iterator I = A->begin(), E = A->end();
         I != E; ++I)
      runImpl(*I, CollectChildren);
  }
コード例 #9
0
    virtual bool run(OperationContext* txn,
                     const string& dbname,
                     BSONObj& cmdObj,
                     int options,
                     string& errmsg,
                     BSONObjBuilder& result,
                     bool fromRepl) {
        const std::string ns = parseNsCollectionRequired(dbname, cmdObj);
        Status allowedWriteStatus = userAllowedWriteNS(ns);
        if (!allowedWriteStatus.isOK()) {
            return appendCommandStatus(result, allowedWriteStatus);
        }

        const BSONObj query = cmdObj.getObjectField("query");
        const BSONObj fields = cmdObj.getObjectField("fields");
        const BSONObj update = cmdObj.getObjectField("update");
        const BSONObj sort = cmdObj.getObjectField("sort");

        bool upsert = cmdObj["upsert"].trueValue();
        bool returnNew = cmdObj["new"].trueValue();
        bool remove = cmdObj["remove"].trueValue();

        if (remove) {
            if (upsert) {
                errmsg = "remove and upsert can't co-exist";
                return false;
            }
            if (!update.isEmpty()) {
                errmsg = "remove and update can't co-exist";
                return false;
            }
            if (returnNew) {
                errmsg = "remove and returnNew can't co-exist";
                return false;
            }
        } else if (!cmdObj.hasField("update")) {
            errmsg = "need remove or update";
            return false;
        }

        bool ok = false;
        MONGO_WRITE_CONFLICT_RETRY_LOOP_BEGIN {
            errmsg = "";

            // We can always retry because we only ever modify one document
            ok = runImpl(txn,
                         dbname,
                         ns,
                         query,
                         fields,
                         update,
                         sort,
                         upsert,
                         returnNew,
                         remove,
                         result,
                         errmsg);
        }
        MONGO_WRITE_CONFLICT_RETRY_LOOP_END(txn, "findAndModify", ns);

        if (!ok && errmsg == "no-collection") {
            // Take X lock so we can create collection, then re-run operation.
            ScopedTransaction transaction(txn, MODE_IX);
            Lock::DBLock lk(txn->lockState(), dbname, MODE_X);
            Client::Context ctx(txn, ns, false /* don't check version */);
            if (!fromRepl &&
                !repl::getGlobalReplicationCoordinator()->canAcceptWritesForDatabase(dbname)) {
                return appendCommandStatus(result,
                                           Status(ErrorCodes::NotMaster,
                                                  str::stream()
                                                      << "Not primary while creating collection "
                                                      << ns << " during findAndModify"));
            }
            Database* db = ctx.db();
            if (db->getCollection(ns)) {
                // someone else beat us to it, that's ok
                // we might race while we unlock if someone drops
                // but that's ok, we'll just do nothing and error out
            } else {
                MONGO_WRITE_CONFLICT_RETRY_LOOP_BEGIN {
                    WriteUnitOfWork wuow(txn);
                    uassertStatusOK(userCreateNS(txn, db, ns, BSONObj(), !fromRepl));
                    wuow.commit();
                }
                MONGO_WRITE_CONFLICT_RETRY_LOOP_END(txn, "findAndModify", ns);
            }

            errmsg = "";
            ok = runImpl(txn,
                         dbname,
                         ns,
                         query,
                         fields,
                         update,
                         sort,
                         upsert,
                         returnNew,
                         remove,
                         result,
                         errmsg);
        }
コード例 #10
0
ファイル: CompilationDatabase.cpp プロジェクト: pkesist/clang
 void run(const driver::Action *A) {
   runImpl(A, false);
 }
コード例 #11
0
ファイル: killcursors_cmd.cpp プロジェクト: ajdavis/mongo
 bool run(OperationContext* opCtx,
          const std::string& dbname,
          const BSONObj& cmdObj,
          BSONObjBuilder& result) final {
     return runImpl(opCtx, dbname, cmdObj, result);
 }