示例#1
0
  //
  // Process
  //
  // Process the orderer
  //
  void Base::Process()
  {
    if (newState)
    {
      // Clear new state flag
      newState = FALSE;

      // Enter the new state
      currentState->Enter();
    }
    else
    {
      currentState->Process();
    }

    // Has the list of constructors/units changed ?
    if (processTokens)
    {
      processTokens = FALSE;

      units.PurgeDead();
      constructorsIdle.PurgeDead();
      constructorsWorking.PurgeDead();

      // Process all of the tokens waiting for constructors in the system
      NBinTree<Token>::Iterator w(&tokensWaiting);
      while (Token *token = w++)
      {
        token->CheckConstructor(units, constructorsIdle);
      }
    }

    // Are we auto disrupting ?
    if (autoDisrupt != -1)
    {
      // Has sufficient cycles elapsed since the last time we sorted the disruptors ?
      if (GameTime::SimCycle() - disruptorCycle > 300)
      {
        // Save the cycle we processed
        disruptorCycle = GameTime::SimCycle();

        // Check to see if the index has gone out of range
        if (disruptorIndex > disruptors.GetCount())
        {
          disruptors.PurgeDead();
          disruptorIndex = 0;
        }

        // Get the list node
        UnitObjListNode *node = disruptors[disruptorIndex];

        if (node)
        {
          // Get the unit list
          UnitObj *unit = node->GetPointer();

          // If it was alive then find the most undisrupted spot and send that unit there
          if (unit)
          {
            // Iterate the map, find the cluster with the most defense and the least disruption
            MapCluster *mapCluster = WorldCtrl::GetCluster(0, 0);
            MapCluster *winningCluster = NULL;

            U32 team = GetObject().GetTeam()->GetId();
            Point<U32> cluster;
            U32 minDisruption = U32_MAX;
            U32 maxDefense = 0;

            for (cluster.z = 0; cluster.z < WorldCtrl::ClusterMapZ(); cluster.z++)
            {
              for (cluster.x = 0; cluster.x < WorldCtrl::ClusterMapX(); cluster.x++)
              {
                U32 defense = mapCluster->ai.GetDefense(team, autoDisrupt);

                if (defense)
                {
                  U32 disruption = mapCluster->ai.GetDisruption();

                  if (disruption < minDisruption)
                  {
                    minDisruption = disruption;
                    maxDefense = defense;
                    winningCluster = mapCluster;
                  }
                  else if (disruption == minDisruption && defense > maxDefense)
                  {
                    maxDefense = defense;
                    winningCluster = mapCluster;
                  }
                }

                mapCluster++;
              }
            }

            if (winningCluster)
            {
              Point<F32> point = winningCluster->GetMidPoint();
              Vector location(point.x, Terrain::FindFloor(point.x, point.z), point.z);

              // Move this disruptor to the middle of this cluster
              Orders::Game::ClearSelected::Generate(GetObject());
              Orders::Game::AddSelected::Generate(GetObject(), unit);
              Orders::Game::Move::Generate(GetObject(), location, FALSE, Orders::FLUSH);
            }
          }

          disruptorIndex++;
        }
      }
    }
  }
示例#2
0
void FloatRect::dump(PrintStream& out) const
{
    out.print(location(), " ", size());
}
LayoutPoint LayoutMultiColumnFlowThread::visualPointToFlowThreadPoint(const LayoutPoint& visualPoint) const
{
    LayoutUnit blockOffset = isHorizontalWritingMode() ? visualPoint.y() : visualPoint.x();
    const LayoutMultiColumnSet* columnSet = nullptr;
    for (const LayoutMultiColumnSet* candidate = firstMultiColumnSet(); candidate; candidate = candidate->nextSiblingMultiColumnSet()) {
        columnSet = candidate;
        if (candidate->logicalBottom() > blockOffset)
            break;
    }
    return columnSet ? columnSet->visualPointToFlowThreadPoint(toLayoutPoint(visualPoint + location() - columnSet->location())) : visualPoint;
}
示例#4
0
bool scrollarea::has_scrollbar() const
{
	return shown_size_ < full_size_ && scrollbar_.is_valid_height(location().h);
}
示例#5
0
void TInfoSinkBase::location(const TSourceLoc& loc) {
    location(loc.first_file, loc.first_line);
}
示例#6
0
Chunk::Chunk(int x, int z, unsigned int seed)
: m_x(x), m_z(z)
{
	PerlinNoise heightMap(seed);
	PerlinNoise noise(seed + 1);
	PerlinNoise caves(seed + 2);

	// Lower means more mountains and valleys
	const float SMOOTHNESS = 25.0;

	// Larger means flatter
	const float DETAIL = 1 / 16.0;

	// Larger means more overhangs and caves
	const float CARVING = 2.0;

	// Larger means more caves
	const float CAVES = 3.0;

	for (int i = 0; i < SIZE; ++i)
	{
		for (int j = 0; j < SIZE; ++j)
		{
			float heightSample = heightMap.sample(SMOOTHNESS * (x * SIZE + i), 0.0, SMOOTHNESS * (z * SIZE + j));
			float height = (DEPTH / 2) + SCALE * heightSample; //(0.5 + 0.25 * heightSample);

			for (int k = 0; k < DEPTH; ++k)
			{
				float sample = noise.sample(DETAIL * (x * SIZE + i), CARVING * DETAIL * k, DETAIL * (z * SIZE + j));
				sample += (height - k) / (SCALE / 4.0);

				// Ground threshold
				if (sample > 0.0f)
				{
					// Stone threshold
					if (sample > 0.5f)
						newBlock(x * SIZE + i, k, z * SIZE + j, BlockLibrary::STONE);
					else
						newBlock(x * SIZE + i, k, z * SIZE + j, BlockLibrary::DIRT);
				}
			}
		}
	}

	// Convert top-level dirt to grass
	for (int i = 0; i < SIZE; ++i)
	{
		for (int j = 0; j < SIZE; ++j)
		{
			// Fill any gap below sea level with water
			for (int k = 0; k < 0.45 * DEPTH; ++k)
			{
				Coordinate location(x * SIZE + i, k, z * SIZE + j);
				if (!get(location))
				{
					newBlock(location.x, location.y, location.z, BlockLibrary::WATER);
				}
			}
		}
	}

	// Cut out some caves
	for (int i = 0; i < SIZE; ++i)
	{
		for (int j = 0; j < SIZE; ++j)
		{
			for (int k = 0; k < DEPTH; ++k)
			{
				Coordinate location(x * SIZE + i, k, z * SIZE + j);
				if (m_blocks.find(location) == m_blocks.end())
					continue;

				float caveSample = caves.sample(DETAIL * (x * SIZE + i), CAVES * DETAIL * k, DETAIL * (z * SIZE + j));
				caveSample = pow(caveSample, 3.0);

				// Ground threshold
				if (caveSample <= -0.1)
				{
					removeBlock(location);
				}
			}

			// Convert top-level dirt to grass
			for (int k = DEPTH - 1; k >= 0; --k)
			{
				Coordinate location(x * SIZE + i, k, z * SIZE + j);

				if (get(location))
				{
					auto& block = m_blocks[location];
					if (block->blockType == BlockLibrary::DIRT)
						block->blockType = BlockLibrary::GRASS;

					// We only work on the top-most block in a column.
					break;
				}
			}
		}
	}
}
示例#7
0
Ast::Ast() : AstNode(AST_AST, this, location())
{
	// TODO Auto-generated constructor stub

}
示例#8
0
static void compare_handles(int n,grib_handle* h1,grib_handle* h2,FILE* out)
{
    size_t len1 = 0;
    size_t len2 = 0;

    double *dval1 = NULL, *dval2 = NULL, *dval3 = NULL;
    double maxe = 0,mine = 0;
    double maxa = 0,mina = 0;
    int i,maxi = 0,maxai = 0;
    double lat,lon;

    GRIB_CHECK(grib_get_size(h1,"values",&len1),NULL);
    GRIB_CHECK(grib_get_size(h2,"values",&len2),NULL);

    if(len1 != len2)
    {
        printf("Field size mismatch %ld != %ld\n",(long)len1,(long)len2);
        exit(1);
    }

    dval1 = (double*)grib_context_malloc(h1->context,len1*sizeof(double));
    Assert(dval1);
    dval2 = (double*)grib_context_malloc(h2->context,len2*sizeof(double));
    Assert(dval2);
    if(out)
        dval3 = (double*)grib_context_malloc(h2->context,len2*sizeof(double));
    Assert(dval2);

    GRIB_CHECK(grib_get_double_array(h1,"values",dval1,&len1),NULL);
    GRIB_CHECK(grib_get_double_array(h2,"values",dval2,&len2),NULL);


    for(i = 0; i < len1; i++)
    {
        double e = err(dval1[i],dval2[i]);
        double a = fabs(dval1[i]-dval2[i]);
        if(i == 0)  maxe = mine = e;
        if(i == 0)  maxa = mina = a;
        if(out) dval3[i] = absolute ? a : e;
        if(e < mine) mine = e;
        if(e > maxe) {
            maxe = e;
            maxi = i;
        }
        if(a < mina) mina = a;
        if(a > maxa) {
            maxa = a;
            maxai = i;
        }
    }

    if(out)
    {
        const void *buffer;
        size_t size;
        GRIB_CHECK(grib_set_long(h1,"generatingProcessIdentifier",255),NULL); /* To prevent Magics to scale the field */
        GRIB_CHECK(grib_set_long(h1,"numberOfBitsContainingEachPackedValue",24),NULL);
        GRIB_CHECK(grib_set_double_array(h1,"values",dval3,len1),NULL);
        GRIB_CHECK(grib_get_message(h1,&buffer,&size),NULL);

        if(fwrite(buffer,1,size,out) != size)
        {
            perror(outname);
            exit(1);
        }

    }

    printf("Field %ld: min relative error: %g%%, max relative error: %g%% [%g,%g,%g]\n",(long)n,mine*100,maxe*100,
           dval1[maxi],dval2[maxi],fabs(dval1[maxi]-dval2[maxi]));

    if(location(h1,maxi,&lat,&lon))
        printf("   latitude = %g, longitude = %g\n",lat,lon);

    printf("Field %ld: min absolute error: %g, max absolute error: %g [%g,%g]\n",(long)n,mina,maxa,
           dval1[maxai],dval2[maxai]);
    if(location(h1,maxai,&lat,&lon))
        printf("   latitude = %g, longitude = %g\n",lat,lon);


    grib_context_free(h1->context,dval1);
    grib_context_free(h2->context,dval2);
    grib_context_free(h2->context,dval3);
}
示例#9
0
void RenderReplaced::paint(PaintInfo& paintInfo, const LayoutPoint& paintOffset)
{
    if (!shouldPaint(paintInfo, paintOffset))
        return;
    
    LayoutPoint adjustedPaintOffset = paintOffset + location();
    
    if (hasBoxDecorations() && (paintInfo.phase == PaintPhaseForeground || paintInfo.phase == PaintPhaseSelection)) 
        paintBoxDecorations(paintInfo, adjustedPaintOffset);
    
    if (paintInfo.phase == PaintPhaseMask) {
        paintMask(paintInfo, adjustedPaintOffset);
        return;
    }

    LayoutRect paintRect = LayoutRect(adjustedPaintOffset, size());
    if ((paintInfo.phase == PaintPhaseOutline || paintInfo.phase == PaintPhaseSelfOutline) && style().outlineWidth())
        paintOutline(paintInfo, paintRect);
    
    if (paintInfo.phase != PaintPhaseForeground && paintInfo.phase != PaintPhaseSelection && !canHaveChildren())
        return;
    
    if (!paintInfo.shouldPaintWithinRoot(*this))
        return;
    
    bool drawSelectionTint = selectionState() != SelectionNone && !document().printing();
    if (paintInfo.phase == PaintPhaseSelection) {
        if (selectionState() == SelectionNone)
            return;
        drawSelectionTint = false;
    }

    bool completelyClippedOut = false;
    if (style().hasBorderRadius()) {
        LayoutRect borderRect = LayoutRect(adjustedPaintOffset, size());

        if (borderRect.isEmpty())
            completelyClippedOut = true;
        else {
            // Push a clip if we have a border radius, since we want to round the foreground content that gets painted.
            paintInfo.context->save();
            RoundedRect roundedInnerRect = style().getRoundedInnerBorderFor(paintRect,
                paddingTop() + borderTop(), paddingBottom() + borderBottom(), paddingLeft() + borderLeft(), paddingRight() + borderRight(), true, true);
            clipRoundedInnerRect(paintInfo.context, paintRect, roundedInnerRect);
        }
    }

    if (!completelyClippedOut) {
        paintReplaced(paintInfo, adjustedPaintOffset);

        if (style().hasBorderRadius())
            paintInfo.context->restore();
    }
        
    // The selection tint never gets clipped by border-radius rounding, since we want it to run right up to the edges of
    // surrounding content.
    if (drawSelectionTint) {
        LayoutRect selectionPaintingRect = localSelectionRect();
        selectionPaintingRect.moveBy(adjustedPaintOffset);
        paintInfo.context->fillRect(pixelSnappedIntRect(selectionPaintingRect), selectionBackgroundColor(), style().colorSpace());
    }
}
示例#10
0
	/// Ray test with entity, default is intersection between ray and entity sphere
	virtual bool ray_test(math::vec3 const& ray_near, math::vec3 const& ray_far) const
	{
		return distance(location(), ray_near, ray_far) <= radius();
	}
示例#11
0
void
Scene::parse_istream(std::istream& in)
{
  // This is not a fully featured .obj file reader, it just takes some
  // inspiration from it:
  // http://www.martinreddy.net/gfx/3d/OBJ.spec
  std::unordered_map<std::string, SceneNode*> nodes;
  std::unordered_map<std::string, std::unique_ptr<SceneNode> > unattached_children;

  std::string name;
  std::string parent;
  std::string material = "phong";
  glm::vec3 location(0.0f, 0.0f, 0.0f);
  glm::quat rotation(1.0f, 0.0f, 0.0f, 0.0f);
  glm::vec3 scale(1.0f, 1.0f, 1.0f);
  std::vector<glm::vec3>  normal;
  std::vector<glm::vec3>  position;
  std::vector<glm::vec3>  texcoord;
  std::vector<int>        index;
  std::vector<glm::vec4>  bone_weight;
  std::vector<glm::ivec4> bone_index;
  std::vector<int>        bone_count;

  auto commit_object = [&]{
    if (!name.empty())
    {
      ModelPtr model;

      if (!position.empty())
      {
        // fill in some texcoords if there aren't enough
        if (texcoord.size() < position.size())
        {
          texcoord.resize(position.size());
          for(FaceLst::size_type i = position.size()-1; i < texcoord.size(); ++i)
          {
            texcoord[i] = glm::vec3(0.0f, 0.0f, 0.0f);
          }
        }

        {
          // create Mesh
          std::unique_ptr<Mesh> mesh(new Mesh(GL_TRIANGLES));

          mesh->attach_float_array("position", position);
          mesh->attach_float_array("texcoord", texcoord);
          mesh->attach_float_array("normal",   normal);
          mesh->attach_element_array(index);

          if (!bone_weight.empty() && !bone_index.empty())
          {
            mesh->attach_float_array("bone_weight", bone_weight);
            mesh->attach_int_array("bone_index", bone_index);
          }

          // create Model
          model = std::make_shared<Model>();
          model->add_mesh(std::move(mesh));

          if (boost::algorithm::ends_with(material, ".material"))
          {
            model->set_material(MaterialFactory::get().from_file(m_directory / boost::filesystem::path(material)));
          }
          else
          {
            model->set_material(MaterialFactory::get().create(material));
          }
        }
      }

      // create SceneNode
      {
        std::unique_ptr<SceneNode> node(new SceneNode(name));
        node->set_position(location);
        node->set_orientation(rotation);
        node->set_scale(scale);

        if (model)
        {
          node->attach_model(model);
        }

        if (nodes.find(name) != nodes.end())
        {
          throw std::runtime_error("duplicate object name: " + name);
        }

        nodes[name] = node.get();
        if (parent.empty())
        {
          m_node->attach_child(std::move(node));
        }
        else
        {
          unattached_children[parent] = std::move(node);
        }
      }

      // clear for the next mesh
      name.clear();
      parent.clear();
      normal.clear();
      texcoord.clear();
      position.clear();
      index.clear();
      location = glm::vec3(0.0f, 0.0f, 0.0f);
      rotation = glm::quat(1.0f, 0.0f, 0.0f, 0.0f);
      scale = glm::vec3(1.0f, 1.0f, 1.0f);
    }
  };

  std::string line;
  int line_number = 0;
  while(std::getline(in, line))
  {
    line_number += 1;

    boost::tokenizer<boost::char_separator<char> > tokens(line, boost::char_separator<char>(" ", ""));
    auto it = tokens.begin();
    if (it != tokens.end())
    {
#define INCR_AND_CHECK {                                                \
        ++it;                                                           \
        if (it == tokens.end())                                         \
        {                                                               \
          throw std::runtime_error((boost::format("not enough tokens at line %d") % line_number).str()); \
        }                                                               \
      }

      try
      {
        if (*it == "o")
        {
          // object
          commit_object();

          INCR_AND_CHECK;
          log_debug("object: '%s'", *it);
          name = *it;
        }
        else if (*it == "g")
        {
          // group
        }
        else if (*it == "parent")
        {
          INCR_AND_CHECK;
          parent = *it;
        }
        else if (*it == "mat")
        {
          INCR_AND_CHECK;
          material = *it;
        }
        else if (*it == "loc")
        {
          INCR_AND_CHECK;
          location.x = boost::lexical_cast<float>(*it);
          INCR_AND_CHECK;
          location.y = boost::lexical_cast<float>(*it);
          INCR_AND_CHECK;
          location.z = boost::lexical_cast<float>(*it);
        }
        else if (*it == "rot")
        {
          INCR_AND_CHECK;
          rotation.w = boost::lexical_cast<float>(*it);
          INCR_AND_CHECK;
          rotation.x = boost::lexical_cast<float>(*it);
          INCR_AND_CHECK;
          rotation.y = boost::lexical_cast<float>(*it);
          INCR_AND_CHECK;
          rotation.z = boost::lexical_cast<float>(*it);
        }
        else if (*it == "scale")
        {
          INCR_AND_CHECK;
          scale.x = boost::lexical_cast<float>(*it);
          INCR_AND_CHECK;
          scale.y = boost::lexical_cast<float>(*it);
          INCR_AND_CHECK;
          scale.z = boost::lexical_cast<float>(*it);
        }
        else if (*it == "v")
        {
          glm::vec3 v;

          INCR_AND_CHECK;
          v.x = boost::lexical_cast<float>(*it);
          INCR_AND_CHECK;
          v.y = boost::lexical_cast<float>(*it);
          INCR_AND_CHECK;
          v.z = boost::lexical_cast<float>(*it);

          position.push_back(v);
        }
        else if (*it == "vt")
        {
          glm::vec3 vt;

          INCR_AND_CHECK;
          vt.s = boost::lexical_cast<float>(*it);
          INCR_AND_CHECK;
          vt.t = boost::lexical_cast<float>(*it);

          texcoord.push_back(vt);
        }
        else if (*it == "vn")
        {
          glm::vec3 vn;

          INCR_AND_CHECK;
          vn.x = boost::lexical_cast<float>(*it);
          INCR_AND_CHECK;
          vn.y = boost::lexical_cast<float>(*it);
          INCR_AND_CHECK;
          vn.z = boost::lexical_cast<float>(*it);

          normal.push_back(vn);
        }
        else if (*it == "bw")
        {
          glm::vec4 bw;

          INCR_AND_CHECK;
          bw.x = boost::lexical_cast<float>(*it);
          INCR_AND_CHECK;
          bw.y = boost::lexical_cast<float>(*it);
          INCR_AND_CHECK;
          bw.z = boost::lexical_cast<float>(*it);
          INCR_AND_CHECK;
          bw.w = boost::lexical_cast<float>(*it);

          bone_weight.push_back(bw);
        }
        else if (*it == "bi")
        {
          glm::ivec4 bi;

          INCR_AND_CHECK;
          bi.x = boost::lexical_cast<int>(*it);
          INCR_AND_CHECK;
          bi.y = boost::lexical_cast<int>(*it);
          INCR_AND_CHECK;
          bi.z = boost::lexical_cast<int>(*it);
          INCR_AND_CHECK;
          bi.w = boost::lexical_cast<int>(*it);

          bone_index.push_back(bi);
        }
        else if (*it == "f")
        {
          INCR_AND_CHECK;
          index.push_back(boost::lexical_cast<int>(*it));
          INCR_AND_CHECK;
          index.push_back(boost::lexical_cast<int>(*it));
          INCR_AND_CHECK;
          index.push_back(boost::lexical_cast<int>(*it));
        }
        else if ((*it)[0] == '#')
        {
          // ignore comments
        }
        else
        {
          throw std::runtime_error((boost::format("unhandled token %s") % *it).str());
        }
      }
      catch(const std::exception& err)
      {
        throw std::runtime_error((boost::format("unknown:%d: %s") % line_number % err.what()).str());
      }
    }
  }

  commit_object();

  // reconstruct parent/child relationships
  for(auto& it : unattached_children)
  {
    auto p = nodes.find(it.first);
    if (p == nodes.end())
    {
      throw std::runtime_error("parent not found: " + it.first);
    }
    else
    {
      p->second->attach_child(std::move(it.second));
    }
  }
}
FloatRect VisualViewport::visibleRect() const
{
    return FloatRect(location(), visibleSize());
}
示例#13
0
文件: octree.cpp 项目: rjw57/mcvoxel
location location::operator - (const location& rhs) const
{
	return location(x-rhs.x, y-rhs.y, z-rhs.z);
}
示例#14
0
文件: octree.cpp 项目: rjw57/mcvoxel
location location::operator + (const location& rhs) const
{
	return location(x+rhs.x, y+rhs.y, z+rhs.z);
}
示例#15
0
bool HybridScanExecutor::DInit() {
 auto status = AbstractScanExecutor::DInit();

 if (!status) return false;

  const planner::HybridScanPlan &node = GetPlanNode<planner::HybridScanPlan>();

  table_ = node.GetTable();
  index_ = node.GetDataIndex();
  type_ = node.GetHybridType();

  if (type_ == planner::SEQ) {
    current_tile_group_offset_ = START_OID;
    if (table_ != nullptr) {
      table_tile_group_count_ = table_->GetTileGroupCount();
      if (column_ids_.empty()) {
        column_ids_.resize(table_->GetSchema()->GetColumnCount());
        std::iota(column_ids_.begin(), column_ids_.end(), 0);
      }
    }

  } else if (type_ == planner::INDEX) {
    result_itr_ = START_OID;
    index_done_ = false;

    column_ids_ = node.GetColumnIds();
    key_column_ids_ = node.GetKeyColumnIds();
    expr_types_ = node.GetExprTypes();
    values_ = node.GetValues();
    runtime_keys_ = node.GetRunTimeKeys();
    predicate_ = node.GetPredicate();

    if (runtime_keys_.size() != 0) {
      assert(runtime_keys_.size() == values_.size());

      if (!key_ready_) {
        values_.clear();

        for (auto expr : runtime_keys_) {
          auto value = expr->Evaluate(nullptr, nullptr, executor_context_);
          LOG_INFO("Evaluated runtime scan key: %s", value.GetInfo().c_str());
          values_.push_back(value);
        }

        key_ready_ = true;
      }
    }

    if (table_ != nullptr) {
      full_column_ids_.resize(table_->GetSchema()->GetColumnCount());
      std::iota(full_column_ids_.begin(), full_column_ids_.end(), 0);
    }
  } else { // Hybrid type.
    table_tile_group_count_ = table_->GetTileGroupCount();
    int offset = index_->GetIndexedTileGroupOff();
    indexed_tile_offset_ = (offset == -1) ? INVALID_OID : (oid_t)offset;

    if (indexed_tile_offset_ == INVALID_OID) {
      current_tile_group_offset_ = START_OID;
    } else {
      current_tile_group_offset_ = indexed_tile_offset_ + 1;
      std::shared_ptr<storage::TileGroup> tile_group; 
      if (current_tile_group_offset_ < table_tile_group_count_) {
        tile_group =
          table_->GetTileGroup(current_tile_group_offset_);
      } else {
        tile_group =
          table_->GetTileGroup(table_tile_group_count_ - 1);
      }
      
      oid_t tuple_id = 0;
      ItemPointer location(tile_group->GetTileGroupId(), tuple_id);
      block_threshold = location.block;
    }

    result_itr_ = START_OID;
    index_done_ = false;

    column_ids_ = node.GetColumnIds();
    key_column_ids_ = node.GetKeyColumnIds();
    expr_types_ = node.GetExprTypes();
    values_ = node.GetValues();
    runtime_keys_ = node.GetRunTimeKeys();
    predicate_ = node.GetPredicate();

    if (runtime_keys_.size() != 0) {
      assert(runtime_keys_.size() == values_.size());

      if (!key_ready_) {
        values_.clear();

        for (auto expr : runtime_keys_) {
          auto value = expr->Evaluate(nullptr, nullptr, executor_context_);
          LOG_INFO("Evaluated runtime scan key: %s", value.GetInfo().c_str());
          values_.push_back(value);
        }

        key_ready_ = true;
      }
    }
    
    if (table_ != nullptr) {
      full_column_ids_.resize(table_->GetSchema()->GetColumnCount());
      std::iota(full_column_ids_.begin(), full_column_ids_.end(), 0);
    }
  }

  return true;
}
    // Test the functionality specific to SolidMechanicsProblemDefinition
    void TestSolidMechanicsProblemDefinition() throw(Exception)
    {
        TS_ASSERT_EQUALS(SolidMechanicsProblemDefinition<2>::FREE, DBL_MAX);
        TS_ASSERT_LESS_THAN(0, SolidMechanicsProblemDefinition<2>::FREE);

        QuadraticMesh<2> mesh(0.5, 1.0, 1.0);

        SolidMechanicsProblemDefinition<2> problem_defn(mesh);

        //////////////////////////////////
        // Fixed nodes
        //////////////////////////////////

        std::vector<unsigned> fixed_nodes;
        fixed_nodes.push_back(0);
        fixed_nodes.push_back(4);
        problem_defn.SetZeroDisplacementNodes(fixed_nodes);
        TS_ASSERT_EQUALS(problem_defn.rGetDirichletNodes().size(), 2u);
        TS_ASSERT_EQUALS(problem_defn.rGetDirichletNodes()[0], 0u);
        TS_ASSERT_EQUALS(problem_defn.rGetDirichletNodes()[1], 4u);
        TS_ASSERT_EQUALS(problem_defn.rGetDirichletNodeValues().size(), 2u);

        TS_ASSERT_DELTA(problem_defn.rGetDirichletNodeValues()[0](0), 0.0, 1e-12);
        TS_ASSERT_DELTA(problem_defn.rGetDirichletNodeValues()[0](1), 0.0, 1e-12);
        TS_ASSERT_DELTA(problem_defn.rGetDirichletNodeValues()[1](0), 0.0, 1e-12);
        TS_ASSERT_DELTA(problem_defn.rGetDirichletNodeValues()[1](1), 0.0, 1e-12);

        fixed_nodes.push_back(8);
        fixed_nodes.push_back(9);
        fixed_nodes.push_back(10);


        std::vector<c_vector<double,2> > locations;
        c_vector<double,2> location = zero_vector<double>(2);
        // Node 0 is to be placed at (0,0)
        locations.push_back(location);

        // Node 4 is to be placed at (0,0.1)
        location(1)=0.1;
        locations.push_back(location);

        // Node 8 is to be placed at (0.1,0.1)
        location(0)=0.1;
        locations.push_back(location);

        // Node 9 is to be placed at (0.5,FREE)
        location(0) = 0.5;
        location(1) = SolidMechanicsProblemDefinition<2>::FREE;
        locations.push_back(location);

        // Node 9 is to be placed at (FREE,1.5)
        location(0) = SolidMechanicsProblemDefinition<2>::FREE;
        location(1) = 1.5;
        locations.push_back(location);

        problem_defn.SetFixedNodes(fixed_nodes, locations);

        TS_ASSERT_EQUALS(problem_defn.rGetDirichletNodes().size(), 5u);
        TS_ASSERT_EQUALS(problem_defn.rGetDirichletNodeValues().size(), 5u);

        // the fully fixed nodes
        TS_ASSERT_EQUALS(problem_defn.rGetDirichletNodes()[0], 0u);
        TS_ASSERT_EQUALS(problem_defn.rGetDirichletNodes()[1], 4u);
        TS_ASSERT_EQUALS(problem_defn.rGetDirichletNodes()[2], 8u);

        TS_ASSERT_DELTA(problem_defn.rGetDirichletNodeValues()[0](0), 0.0 - mesh.GetNode(0)->rGetLocation()[0], 1e-12);
        TS_ASSERT_DELTA(problem_defn.rGetDirichletNodeValues()[0](1), 0.0 - mesh.GetNode(0)->rGetLocation()[1], 1e-12);
        TS_ASSERT_DELTA(problem_defn.rGetDirichletNodeValues()[1](0), 0.0 - mesh.GetNode(4)->rGetLocation()[0], 1e-12);
        TS_ASSERT_DELTA(problem_defn.rGetDirichletNodeValues()[1](1), 0.1 - mesh.GetNode(4)->rGetLocation()[1], 1e-12);
        TS_ASSERT_DELTA(problem_defn.rGetDirichletNodeValues()[2](0), 0.1 - mesh.GetNode(8)->rGetLocation()[0], 1e-12);
        TS_ASSERT_DELTA(problem_defn.rGetDirichletNodeValues()[2](1), 0.1 - mesh.GetNode(8)->rGetLocation()[1], 1e-12);

        // the partial fixed nodes
        TS_ASSERT_EQUALS(problem_defn.rGetDirichletNodes()[3], 9u);
        TS_ASSERT_EQUALS(problem_defn.rGetDirichletNodes()[4], 10u);
        TS_ASSERT_DELTA(problem_defn.rGetDirichletNodeValues()[3](0), 0.5 - mesh.GetNode(9)->rGetLocation()[0], 1e-12);
        TS_ASSERT_DELTA(problem_defn.rGetDirichletNodeValues()[3](1), SolidMechanicsProblemDefinition<2>::FREE, 1e-12);
        TS_ASSERT_DELTA(problem_defn.rGetDirichletNodeValues()[4](0), SolidMechanicsProblemDefinition<2>::FREE, 1e-12);
        TS_ASSERT_DELTA(problem_defn.rGetDirichletNodeValues()[4](1), 1.5 - mesh.GetNode(10)->rGetLocation()[1], 1e-12);


        ///////////////////////////////////////
        // Set an incompressible material law
        ///////////////////////////////////////
        TS_ASSERT_THROWS_THIS(problem_defn.Validate(), "No material law has been set");

        // set a homogeneous law
        MooneyRivlinMaterialLaw<2> incomp_mooney_rivlin_law(1.0);
        problem_defn.SetMaterialLaw(INCOMPRESSIBLE,&incomp_mooney_rivlin_law);

        TS_ASSERT_EQUALS(problem_defn.IsHomogeneousMaterial(), true);
        TS_ASSERT_EQUALS(problem_defn.GetCompressibilityType(), INCOMPRESSIBLE);
        TS_ASSERT_EQUALS(problem_defn.GetIncompressibleMaterialLaw(0), &incomp_mooney_rivlin_law);

        // set a heterogeneous law
        MooneyRivlinMaterialLaw<2> incomp_mooney_rivlin_law_2(2.0);
        std::vector<AbstractMaterialLaw<2>*> laws;
        for(unsigned i=0; i<mesh.GetNumElements()/2; i++)
        {
            laws.push_back(&incomp_mooney_rivlin_law);
        }
        for(unsigned i=mesh.GetNumElements()/2; i<mesh.GetNumElements(); i++)
        {
            laws.push_back(&incomp_mooney_rivlin_law_2);
        }

        problem_defn.SetMaterialLaw(INCOMPRESSIBLE,laws);

        TS_ASSERT_EQUALS(problem_defn.IsHomogeneousMaterial(), false);
        for(unsigned i=0; i<mesh.GetNumElements()/2; i++)
        {
            TS_ASSERT_EQUALS(problem_defn.GetIncompressibleMaterialLaw(i), &incomp_mooney_rivlin_law);
        }
        for(unsigned i=mesh.GetNumElements()/2; i<mesh.GetNumElements(); i++)
        {
            TS_ASSERT_EQUALS(problem_defn.GetIncompressibleMaterialLaw(i), &incomp_mooney_rivlin_law_2);
        }

        /////////////////////////////////////////////////////////////////////////
        // Set a compressible material law (clears the incompressible laws)
        /////////////////////////////////////////////////////////////////////////

        CompressibleMooneyRivlinMaterialLaw<2> comp_mooney_rivlin_law(2.0, 1.0);
        problem_defn.SetMaterialLaw(COMPRESSIBLE,&comp_mooney_rivlin_law);

        TS_ASSERT_EQUALS(problem_defn.IsHomogeneousMaterial(), true);
        TS_ASSERT_EQUALS(problem_defn.GetCompressibilityType(), COMPRESSIBLE);
        TS_ASSERT_EQUALS(problem_defn.GetCompressibleMaterialLaw(0), &comp_mooney_rivlin_law);

        // set a heterogeneous law
        CompressibleMooneyRivlinMaterialLaw<2> comp_mooney_rivlin_law_2(4.0, 1.0);
        std::vector<AbstractMaterialLaw<2>*> comp_laws;
        for(unsigned i=0; i<mesh.GetNumElements()/2; i++)
        {
            comp_laws.push_back(&comp_mooney_rivlin_law);
        }
        for(unsigned i=mesh.GetNumElements()/2; i<mesh.GetNumElements(); i++)
        {
            comp_laws.push_back(&comp_mooney_rivlin_law_2);
        }

        problem_defn.SetMaterialLaw(COMPRESSIBLE,comp_laws);

        TS_ASSERT_EQUALS(problem_defn.IsHomogeneousMaterial(), false);
        for(unsigned i=0; i<mesh.GetNumElements()/2; i++)
        {
            TS_ASSERT_EQUALS(problem_defn.GetCompressibleMaterialLaw(i), &comp_mooney_rivlin_law);
        }
        for(unsigned i=mesh.GetNumElements()/2; i<mesh.GetNumElements(); i++)
        {
            TS_ASSERT_EQUALS(problem_defn.GetCompressibleMaterialLaw(i), &comp_mooney_rivlin_law_2);
        }

        // should not throw anything
        problem_defn.Validate();

        TS_ASSERT_THROWS_THIS(problem_defn.SetMaterialLaw(INCOMPRESSIBLE,&comp_mooney_rivlin_law),"Compressibility type was declared as INCOMPRESSIBLE but a compressible material law was given");
        TS_ASSERT_THROWS_THIS(problem_defn.SetMaterialLaw(COMPRESSIBLE,&incomp_mooney_rivlin_law),"Incompressibility type was declared as COMPRESSIBLE but an incompressible material law was given");

        ///////////////////////////////
        // solver stuff
        ///////////////////////////////
        TS_ASSERT_EQUALS(problem_defn.GetSolveUsingSnes(), false);
        TS_ASSERT_EQUALS(problem_defn.GetVerboseDuringSolve(), false);

        problem_defn.SetSolveUsingSnes();
        problem_defn.SetVerboseDuringSolve();

        TS_ASSERT_EQUALS(problem_defn.GetSolveUsingSnes(), true);
        TS_ASSERT_EQUALS(problem_defn.GetVerboseDuringSolve(), true);

        problem_defn.SetSolveUsingSnes(false);
        problem_defn.SetVerboseDuringSolve(false);

        TS_ASSERT_EQUALS(problem_defn.GetSolveUsingSnes(), false);
        TS_ASSERT_EQUALS(problem_defn.GetVerboseDuringSolve(), false);

    }
示例#17
0
void Chunk::newBlock(int x, int y, int z, BlockLibrary::Tag tag)
{
	Coordinate location(x, y, z);
	m_blocks[location] = std::unique_ptr<Block>(new Block(location, tag));
}
int WebScrollbarThemeClientImpl::y() const {
  return location().y();
}
示例#19
0
void progress_bar::draw_contents()
{
	surface surf = video().getSurface();
	SDL_Rect area = location();

	if(area.w >= 2 && area.h >= 2) {
		int fcr =  21, fcg =  53, fcb =  80;		// RGB-values for finished piece.
		int bcr =   0, bcg =   0, bcb =   0;		// Border color.
		int gcr = 255, gcg = 255, gcb = 255;		// Groove color.
		int	lightning_thickness = 2;
		static const SDL_Color selected_text_color = {0xCC,0xCC,0xCC,0};

		SDL_Rect inner_area = sdl::create_rect(area.x + 1
				, area.y + 1
				, area.w - 2
				, area.h - 2);

		sdl::fill_rect(surf,&area,SDL_MapRGB(surf->format,bcr,bcg,bcb));
		sdl::fill_rect(surf,&inner_area,SDL_MapRGB(surf->format,gcr,gcg,gcb));

		inner_area.w = (inner_area.w*progress_)/100;
		sdl::fill_rect(surf,&inner_area,SDL_MapRGB(surf->format,fcr,fcg,fcb));

		SDL_Rect lightning = inner_area;
		lightning.h = lightning_thickness;
		//we add 25% of white to the color of the bar to simulate a light effect
		sdl::fill_rect(surf,&lightning,SDL_MapRGB(surf->format,(fcr*3+255)/4,(fcg*3+255)/4,(fcb*3+255)/4));
		lightning.y = inner_area.y+inner_area.h-lightning.h;
		//remove 50% of color to simulate a shadow effect
		sdl::fill_rect(surf,&lightning,SDL_MapRGB(surf->format,fcr/2,fcg/2,fcb/2));

		const std::string text = text_.empty() ? str_cast(progress_) + "%" :
		                         text_ + " (" + str_cast(progress_) + "%)";
		SDL_Rect text_area = font::text_area(text,font::SIZE_NORMAL);

		text_area.x = area.x + area.w/2 - text_area.w/2;
		text_area.y = area.y + area.h/2 - text_area.h/2;

		font::draw_text(
			&video(),
			location(),
			font::SIZE_NORMAL,
			font::BLACK_COLOR,
			text,
			text_area.x,
			text_area.y
		);

		// Draw a white text section for the highlighted area
		// of the bar
		SDL_Rect selected_text_location = location();
		selected_text_location.w = inner_area.w;
		selected_text_location.h = inner_area.h;
		{
			clip_rect_setter clippy(surf, &selected_text_location);
			font::draw_text(
				&video(),
				selected_text_location,
				font::SIZE_NORMAL,
				selected_text_color,
				text,
				text_area.x,
				text_area.y
			);
		}
	}

	update_rect(location());
}
IntRect WebScrollbarThemeClientImpl::frameRect() const {
  return IntRect(location(), size());
}
示例#21
0
const char* win32_access_violation::what() const
{
	sprintf_s<>(messageBuffer_, "Access violation at %p, trying to %s %p", location(), isWrite_?"write":"read", badAddress_);

	return messageBuffer_;
}
void battle_prediction_pane::draw_unit(int x_off, int damage_line_skip, int left_strings_width,
									   const std::vector<std::string>& left_strings,
									   const std::vector<std::string>& right_strings,
									   const std::string& label, int label_width,
									   surface& hp_distrib, int hp_distrib_width)
{
	surface screen = resources::screen->get_screen_surface();
	int i;

	// NOTE. A preview pane is not made to be used alone and it is not
	// centered in the middle of the dialog. We "fix" this problem by moving
	// the clip rectangle 10 pixels to the right. This is a kludge and it
	// should be removed by 1) writing a custom dialog handler, or
	// 2) modify preview_pane so that it accepts {left, middle, right} as
	// layout possibilities.

	// Get clip rectangle and center it
	SDL_Rect clip_rect = location();
	clip_rect.x += 10;

	// Current vertical offset. We draw the dialog line-by-line, starting at the top.
	int y_off = 15;

	// Draw unit label.
	font::draw_text_line(screen, clip_rect, font::SIZE_15, font::NORMAL_COLOR, label,
						 clip_rect.x + x_off + (units_width_ - label_width) / 2, clip_rect.y + y_off, 0, TTF_STYLE_BOLD);

	y_off += 24;

	// Draw unit left and right strings except the last two (total damage and unscathed probability).
	for(i = 0; i < static_cast<int>(left_strings.size()) - 2; i++) {
		font::draw_text_line(screen, clip_rect, font::SIZE_NORMAL, font::NORMAL_COLOR, left_strings[i],
							 clip_rect.x + x_off, clip_rect.y + y_off + (font::SIZE_NORMAL + inter_line_gap_) * i,
							 0, TTF_STYLE_NORMAL);

		font::draw_text_line(screen, clip_rect, font::SIZE_NORMAL, font::NORMAL_COLOR, right_strings[i],
							 clip_rect.x + x_off + left_strings_width + inter_column_gap_,
							 clip_rect.y + y_off + (font::SIZE_NORMAL + inter_line_gap_) * i, 0, TTF_STYLE_NORMAL);
	}

	// Ensure both damage lines are aligned.
	y_off += damage_line_skip * (font::SIZE_NORMAL + inter_line_gap_) + 14;

	// Draw total damage and unscathed probability.
	for(i = 0; i < 2; i++) {
		const std::string& left_string = left_strings[left_strings.size() - 2 + i];
		const std::string& right_string = right_strings[right_strings.size() - 2 + i];

		font::draw_text_line(screen, clip_rect, font::SIZE_NORMAL, font::NORMAL_COLOR, left_string,
							 clip_rect.x + x_off, clip_rect.y + y_off + (font::SIZE_NORMAL + inter_line_gap_) * i,
							 0, TTF_STYLE_NORMAL);

		font::draw_text_line(screen, clip_rect, font::SIZE_NORMAL, font::NORMAL_COLOR, right_string,
							 clip_rect.x + x_off + left_strings_width + inter_column_gap_,
							 clip_rect.y + y_off + (font::SIZE_NORMAL + inter_line_gap_) * i, 0, TTF_STYLE_NORMAL);
	}

	y_off += 2 * (font::SIZE_NORMAL + inter_line_gap_) + 14;

	// Draw hitpoints distribution string.
	font::draw_text(screen, clip_rect, font::SIZE_SMALL, font::NORMAL_COLOR, hp_distrib_string_,
					clip_rect.x + x_off + (units_width_ - hp_distrib_string_width_) / 2, clip_rect.y + y_off);

	y_off += 19;

	// Draw hitpoints distributions.
	video().blit_surface(clip_rect.x + x_off + (units_width_ - hp_distrib_width) / 2, clip_rect.y + y_off, hp_distrib);
}
示例#23
0
bool FileHDF5::operator==(const FileHDF5 &other) const {
    return location() == other.location();
}
示例#24
0
void RenderMathMLRoot::paint(PaintInfo& info, const LayoutPoint& paintOffset)
{
    RenderMathMLBlock::paint(info, paintOffset);
    
    if (info.context->paintingDisabled())
        return;
    
    IntPoint adjustedPaintOffset = roundedIntPoint(paintOffset + location() + contentBoxRect().location());
    
    int startX = adjustedPaintOffset.x();
    int frontWidth = lroundf(gFrontWidthEms * style()->fontSize());
    int overbarWidth = roundToInt(getBoxModelObjectWidth(firstChild())) + m_overbarLeftPointShift;
    
    int baseHeight = roundToInt(getBoxModelObjectHeight(firstChild()));
    int rootPad = lroundf(gSpaceAboveEms * style()->fontSize());
    adjustedPaintOffset.setY(adjustedPaintOffset.y() - rootPad);
    
    float radicalDipLeftPointYPos = (index() ? gRootRadicalDipLeftPointYPos : gSqrtRadicalDipLeftPointYPos) * baseHeight;
    
    FloatPoint overbarLeftPoint(startX - m_overbarLeftPointShift, adjustedPaintOffset.y());
    FloatPoint bottomPoint(startX - gRadicalBottomPointXFront * frontWidth, adjustedPaintOffset.y() + baseHeight + gRadicalBottomPointLower);
    FloatPoint dipLeftPoint(startX - gRadicalDipLeftPointXFront * frontWidth, adjustedPaintOffset.y() + radicalDipLeftPointYPos);
    FloatPoint leftEnd(startX - frontWidth, dipLeftPoint.y() + gRadicalLeftEndYShiftEms * style()->fontSize());
    
    GraphicsContextStateSaver stateSaver(*info.context);
    
    info.context->setStrokeThickness(gRadicalLineThicknessEms * style()->fontSize());
    info.context->setStrokeStyle(SolidStroke);
    info.context->setStrokeColor(style()->visitedDependentColor(CSSPropertyColor), ColorSpaceDeviceRGB);
    info.context->setLineJoin(MiterJoin);
    info.context->setMiterLimit(style()->fontSize());
    
    Path root;
    
    root.moveTo(FloatPoint(overbarLeftPoint.x() + overbarWidth, adjustedPaintOffset.y()));
    // draw top
    root.addLineTo(overbarLeftPoint);
    // draw from top left corner to bottom point of radical
    root.addLineTo(bottomPoint);
    // draw from bottom point to top of left part of radical base "dip"
    root.addLineTo(dipLeftPoint);
    // draw to end
    root.addLineTo(leftEnd);
    
    info.context->strokePath(root);
    
    GraphicsContextStateSaver maskStateSaver(*info.context);
    
    // Build a mask to draw the thick part of the root.
    Path mask;
    
    mask.moveTo(overbarLeftPoint);
    mask.addLineTo(bottomPoint);
    mask.addLineTo(dipLeftPoint);
    mask.addLineTo(FloatPoint(2 * dipLeftPoint.x() - leftEnd.x(), 2 * dipLeftPoint.y() - leftEnd.y()));
    
    info.context->clip(mask);
    
    // Draw the thick part of the root.
    info.context->setStrokeThickness(gRadicalThickLineThicknessEms * style()->fontSize());
    info.context->setLineCap(SquareCap);
    
    Path line;
    line.moveTo(bottomPoint);
    line.addLineTo(dipLeftPoint);
    
    info.context->strokePath(line);
}
示例#25
0
void TInfoSinkBase::message(TPrefixType p, const TSourceLoc& loc, const char* m) {
    prefix(p);
    location(loc);
    sink.append(m);
    sink.append("\n");
}
示例#26
0
static void
test_azimuth()
{
    double test_data1[24] = {
        9.660271,
        28.185910,
        44.824283,
        59.416812,
        72.404059,
        84.420232,
        96.113747,
        108.120524,
        121.080364,
        135.609075,
        152.122820,
        170.453770,
        -170.455922,
        -152.140313,
        -135.650092,
        -121.146412,
        -108.210341,
        -96.225746,
        -84.552904,
        -72.554841,
        -59.579269,
        -44.983118,
        -28.311449,
        -9.711208
    };

    double test_data2[24] = {
        135.535117,
        121.014248,
        108.070607,
        96.083211,
        84.410044,
        72.414117,
        59.445455,
        44.866010,
        28.227658,
        9.680160,
        -9.682373,
        -28.245579,
        -44.907783,
        -59.512321,
        -72.504563,
        -84.522294,
        -96.215579,
        -108.220331,
        -121.174709,
        -135.691072,
        -152.181075,
        -170.475266,
        170.477364,
        152.198463
    };

    GeoPoint location(Angle::Degrees(fixed(7)), Angle::Degrees(fixed(51)));

    BrokenDateTime dt;
    dt.year = 2010;
    dt.month = 9;
    dt.day = 24;
    dt.minute = 30;
    dt.second = 0;

    for (unsigned hour = 0; hour < 24; hour++) {
        dt.hour = hour;

        SunEphemeris::Result sun =
            SunEphemeris::CalcSunTimes(location, dt, fixed_zero);

        ok1(equals(sun.azimuth, test_data1[hour]));
    }

    location.latitude.Flip();

    for (unsigned hour = 0; hour < 24; hour++) {
        dt.hour = hour;

        SunEphemeris::Result sun =
            SunEphemeris::CalcSunTimes(location, dt, fixed_two);

        ok1(equals(sun.azimuth, test_data2[hour]));
    }
}
示例#27
0
void wsSolve(Array2D<char> const& wsArray,       //Wordsearch array to solve.
             StrLocMap&           matchMap)      //List of words and their locations
{
    /**
      * @brief Given the array (wsArray) and the list of words to find (domain of
      *        matchMap), wsSolve will fill the range of matchMap with the locations
      *        of the words to find. For instance, if matchMap contains
      *        (string1, locationData), wsSolve() fills in locationData
      *        with the location of the string. If the word is not found,
      *        locationData will remain unmodified.
      *
      *        The algorithm itself is quite complex. See wsSolveDoc.h for more
      *        information.
      *
      * @author MPW
      * @date 7/19/2008
      * @version 1
      *
      */

   typedef std::vector<Coord> CoordVec;

   //Declare the array of vectors of strings and set them all to empty vectors.
   Array2D<VecStr> occupied(wsArray.getWidth(), wsArray.getHeight());

   for (unsigned y = 0; y != wsArray.getHeight(); ++y)
   {
       for (unsigned x = 0; x != wsArray.getWidth(); ++x)
           occupied(x, y) = std::vector<std::string>();
   }

    //Find the list of letters to make a location list for, and for each letter,
    //pair the letter with a vector containing the coordinates of each occurrence
    //of that letter.

    //We go through the list, finding each letter to cache.
    std::map<char, CoordVec> cacheList;
    char prevChar = 0;
    char currentChar = 0;
    for (StrLocMap::iterator itr = matchMap.begin(); itr != matchMap.end();)
    {
        //currentChar is still from the previous loop! Hence, we set prevChar to
        //currentChar and update currentChar.
        prevChar = currentChar;
        currentChar = itr->first[0];

        //If the letter here is the same as the one before, it repeats (since
        //maps sort their elements in alphabetical order) (if this is
        //the first loop, this will never happen; prevChar will be nul, and no first
        //letter of a string can be nul; therefore, we don't count the first element
        //as appearing twice).
        if (currentChar == prevChar)
        {
            cacheList.insert(std::make_pair(currentChar, CoordVec()));

            //This trasverses the map until we get to a different character.
            while ((++itr != matchMap.end()) && (itr->first[0] == currentChar));

            //This is so the ++itr below does not execute.
            continue;
        }

        ++itr;
    }

    //Copy each of the strings into a multimap; this will sort the strings by
    //length.
    std::multimap<unsigned, std::string> strList;
    for (StrLocMap::iterator itr = matchMap.begin(); itr != matchMap.end(); ++itr)
        strList.insert(std::make_pair(itr->first.size(), itr->first));

    //Start the find.
    for (std::multimap<unsigned, std::string>::reverse_iterator itr = strList.rbegin();
         itr != strList.rend(); ++itr)
    {
        std::string& str = itr->second;
        bool isCached = !(cacheList.find(str[0]) == cacheList.end()); //Whether or not
                                                                      //the first letter
                                                                      //of the current
                                                                      //string is
                                                                      //cached.

        Coord startLocation(0, 0); //Location to start searching at; if the first
                                   //letter of the word's locations have been cached,
                                   //and none of the cached positions are the
                                   //location where str is found, startLocation is
                                   //set to the spot one after the last cached
                                   //position.
        if (isCached)
        {
            CoordVec& coordVec = cacheList[str[0]];
            if (coordVec.size() != 0)
            {
                //We assert here that the cached locations are in "ascending order";
                //see wsSolveDoc.h for more information.

                for (unsigned i = 0; i != coordVec.size(); ++i)
                {
                    //Contains the list of all possible directions the word can have
                    //at the given coordinates; see wsSolveDoc.h for more information.
                    std::vector<Direction> possibleDirList;
                    findWordAt(wsArray, str, coordVec[i], possibleDirList);

                    //Go through the vector, either until we find a valid direction
                    //the word can have, or until there are no possible directions
                    //the word can have left. (There's a chance possibleDir.empty() is
                    //already true, so in that case, just skip over that part.)
                    for (std::vector<Direction>::iterator itr2 = possibleDirList.begin();
                         itr2 != possibleDirList.end(); ++itr2)
                    {
                        if (!areAllOccupiedBySuperstring(occupied, str, coordVec[i], *itr2))
                        {
                            //You found the word!
                            matchMap[str] = LocationData(coordVec[i], *itr2);
                            setOccupied(occupied, str, coordVec[i], *itr2);

                            goto lblContinue;
                        }
                    }
                }
            }
        }

        //If the word was found in a cache, we skip over to lblContinue; however, we
        //would then be skipping over some variable declarations in the current
        //scope. This is banned by C++ syntax, so we wrap the following code in
        //another block.
        {
            Coord const endLocation(wsArray.getWidth(), wsArray.getHeight());
            Coord       location(startLocation);

            //Find the next occurrence of the character you're searching for.
            while ((location = searchForLetter(wsArray, str[0], location)) != endLocation)
            {
                //Cache this position (if relevant).
                if (isCached)
                    cacheList[str[0]].push_back(location);

                //Contains the list of all possible directions the word can have
                //at the given coordinates; see wsSolveDoc.h for more information.
                std::vector<Direction> possibleDirList;
                findWordAt(wsArray, str, location, possibleDirList);

                for (std::vector<Direction>::iterator itr2 = possibleDirList.begin();
                     itr2 != possibleDirList.end(); ++itr2)
                {
                    if (!areAllOccupiedBySuperstring(occupied, str, location, *itr2))
                    {
                        //You found the word!
                        matchMap[str] = LocationData(location, *itr2);
                        setOccupied(occupied, str, location, *itr2);

                        //You're done with this loop; you then enter the next loop
                        //(i.e., you search for the next string.)
                        goto lblContinue;
                    }
                }
                //Increase the location's position by 1; if it goes past the end of
                //the row, go down another row.
                if (location.pX < wsArray.getWidth())
                    ++location.pX;
                else
                {
                    if (location.pY < wsArray.getHeight())
                    {
                        //This code executes if you're on the last position on the
                        //last row; in that case, you're done.
                        ++location.pY;
                        location.pX = 0;
                    }
                    else
                        break;
                }
            }
        }

        lblContinue:
        continue;
    }
}
示例#28
0
bool HybridScanExecutor::SeqScanUtil() {
  assert(children_.size() == 0);
  // LOG_INFO("Hybrid executor, Seq Scan :: 0 child");

  assert(table_ != nullptr);
  assert(column_ids_.size() > 0);

  auto &transaction_manager =
    concurrency::TransactionManagerFactory::GetInstance();

  // Retrieve next tile group.
  while (current_tile_group_offset_ < table_tile_group_count_) {
    auto tile_group =
      table_->GetTileGroup(current_tile_group_offset_++);
    auto tile_group_header = tile_group->GetHeader();

    oid_t active_tuple_count = tile_group->GetNextTupleSlot();


    // Construct position list by looping through tile group
    // and applying the predicate.
    oid_t upper_bound_block = 0;
    if (item_pointers_.size() > 0) {
      auto reverse_iter = item_pointers_.rbegin();
      upper_bound_block = reverse_iter->block;
    }

    std::vector<oid_t> position_list;
    for (oid_t tuple_id = 0; tuple_id < active_tuple_count; tuple_id++) {

      ItemPointer location(tile_group->GetTileGroupId(), tuple_id);
      if (type_ == planner::HYBRID &&
          item_pointers_.size() > 0 &&
          location.block <= upper_bound_block) {
        if (item_pointers_.find(location) != item_pointers_.end()) {
          continue;
        }
      }

      // check transaction visibility
      if (transaction_manager.IsVisible(tile_group_header, tuple_id)) {
        // if the tuple is visible, then perform predicate evaluation.
        if (predicate_ == nullptr) {
          position_list.push_back(tuple_id);
        } else {
          expression::ContainerTuple<storage::TileGroup> tuple(
            tile_group.get(), tuple_id);
          auto eval = predicate_->Evaluate(&tuple, nullptr, executor_context_)
            .IsTrue();
          if (eval == true) {
            position_list.push_back(tuple_id);
          }
        }
      } else {
          expression::ContainerTuple<storage::TileGroup> tuple(
            tile_group.get(), tuple_id);
          auto eval = predicate_->Evaluate(&tuple, nullptr, executor_context_)
            .IsTrue();
          if (eval == true) {
            position_list.push_back(tuple_id);
            auto res = transaction_manager.PerformRead(location);
            if (!res) {
              transaction_manager.SetTransactionResult(RESULT_FAILURE);
              return res;
            }
          }
      }
    }
      // Don't return empty tiles
      if (position_list.size() == 0) {
        continue;
      }

      // Construct logical tile.
      std::unique_ptr<LogicalTile> logical_tile(LogicalTileFactory::GetTile());
      logical_tile->AddColumns(tile_group, column_ids_);
      logical_tile->AddPositionList(std::move(position_list));
      LOG_INFO("Hybrid executor, Seq Scan :: Got a logical tile");
      SetOutput(logical_tile.release());
      return true;
  }


  return false;
}
示例#29
0
void StyleResolver::applySVGProperty(CSSPropertyID id, CSSValue* value)
{
    ASSERT(value);
    CSSPrimitiveValue* primitiveValue = 0;
    if (value->isPrimitiveValue())
        primitiveValue = static_cast<CSSPrimitiveValue*>(value);

    const State& state = m_state;
    SVGRenderStyle* svgstyle = state.style()->accessSVGStyle();

    bool isInherit = state.parentNode() && value->isInheritedValue();
    bool isInitial = value->isInitialValue() || (!state.parentNode() && value->isInheritedValue());

    // What follows is a list that maps the CSS properties into their
    // corresponding front-end RenderStyle values. Shorthands(e.g. border,
    // background) occur in this list as well and are only hit when mapping
    // "inherit" or "initial" into front-end values.
    switch (id)
    {
        // ident only properties
        case CSSPropertyAlignmentBaseline:
        {
            HANDLE_INHERIT_AND_INITIAL(alignmentBaseline, AlignmentBaseline)
            if (!primitiveValue)
                break;

            svgstyle->setAlignmentBaseline(*primitiveValue);
            break;
        }
        case CSSPropertyBaselineShift:
        {
            HANDLE_INHERIT_AND_INITIAL(baselineShift, BaselineShift);
            if (!primitiveValue)
                break;

            if (primitiveValue->getIdent()) {
                switch (primitiveValue->getIdent()) {
                case CSSValueBaseline:
                    svgstyle->setBaselineShift(BS_BASELINE);
                    break;
                case CSSValueSub:
                    svgstyle->setBaselineShift(BS_SUB);
                    break;
                case CSSValueSuper:
                    svgstyle->setBaselineShift(BS_SUPER);
                    break;
                default:
                    break;
                }
            } else {
                svgstyle->setBaselineShift(BS_LENGTH);
                svgstyle->setBaselineShiftValue(SVGLength::fromCSSPrimitiveValue(primitiveValue));
            }

            break;
        }
        case CSSPropertyKerning:
        {
            HANDLE_INHERIT_AND_INITIAL(kerning, Kerning);
            if (primitiveValue)
                svgstyle->setKerning(SVGLength::fromCSSPrimitiveValue(primitiveValue));
            break;
        }
        case CSSPropertyDominantBaseline:
        {
            HANDLE_INHERIT_AND_INITIAL(dominantBaseline, DominantBaseline)
            if (primitiveValue)
                svgstyle->setDominantBaseline(*primitiveValue);
            break;
        }
        case CSSPropertyColorInterpolation:
        {
            HANDLE_INHERIT_AND_INITIAL(colorInterpolation, ColorInterpolation)
            if (primitiveValue)
                svgstyle->setColorInterpolation(*primitiveValue);
            break;
        }
        case CSSPropertyColorInterpolationFilters:
        {
            HANDLE_INHERIT_AND_INITIAL(colorInterpolationFilters, ColorInterpolationFilters)
            if (primitiveValue)
                svgstyle->setColorInterpolationFilters(*primitiveValue);
            break;
        }
        case CSSPropertyColorProfile:
        {
            // Not implemented.
            break;
        }
        case CSSPropertyColorRendering:
        {
            HANDLE_INHERIT_AND_INITIAL(colorRendering, ColorRendering)
            if (primitiveValue)
                svgstyle->setColorRendering(*primitiveValue);
            break;
        }
        case CSSPropertyClipRule:
        {
            HANDLE_INHERIT_AND_INITIAL(clipRule, ClipRule)
            if (primitiveValue)
                svgstyle->setClipRule(*primitiveValue);
            break;
        }
        case CSSPropertyFillRule:
        {
            HANDLE_INHERIT_AND_INITIAL(fillRule, FillRule)
            if (primitiveValue)
                svgstyle->setFillRule(*primitiveValue);
            break;
        }
        case CSSPropertyStrokeLinejoin:
        {
            HANDLE_INHERIT_AND_INITIAL(joinStyle, JoinStyle)
            if (primitiveValue)
                svgstyle->setJoinStyle(*primitiveValue);
            break;
        }
        case CSSPropertyShapeRendering:
        {
            HANDLE_INHERIT_AND_INITIAL(shapeRendering, ShapeRendering)
            if (primitiveValue)
                svgstyle->setShapeRendering(*primitiveValue);
            break;
        }
        // end of ident only properties
        case CSSPropertyFill:
        {
            if (isInherit) {
                const SVGRenderStyle* svgParentStyle = state.parentStyle()->svgStyle();
                svgstyle->setFillPaint(svgParentStyle->fillPaintType(), svgParentStyle->fillPaintColor(), svgParentStyle->fillPaintUri(), applyPropertyToRegularStyle(), applyPropertyToVisitedLinkStyle());
                return;
            }
            if (isInitial) {
                svgstyle->setFillPaint(SVGRenderStyle::initialFillPaintType(), SVGRenderStyle::initialFillPaintColor(), SVGRenderStyle::initialFillPaintUri(), applyPropertyToRegularStyle(), applyPropertyToVisitedLinkStyle());
                return;
            }
            if (value->isSVGPaint()) {
                SVGPaint* svgPaint = static_cast<SVGPaint*>(value);
                svgstyle->setFillPaint(svgPaint->paintType(), colorFromSVGColorCSSValue(svgPaint, state.style()->color()), svgPaint->uri(), applyPropertyToRegularStyle(), applyPropertyToVisitedLinkStyle());
            }
            break;
        }
        case CSSPropertyStroke:
        {
            if (isInherit) {
                const SVGRenderStyle* svgParentStyle = state.parentStyle()->svgStyle();
                svgstyle->setStrokePaint(svgParentStyle->strokePaintType(), svgParentStyle->strokePaintColor(), svgParentStyle->strokePaintUri(), applyPropertyToRegularStyle(), applyPropertyToVisitedLinkStyle());
                return;
            }
            if (isInitial) {
                svgstyle->setStrokePaint(SVGRenderStyle::initialStrokePaintType(), SVGRenderStyle::initialStrokePaintColor(), SVGRenderStyle::initialStrokePaintUri(), applyPropertyToRegularStyle(), applyPropertyToVisitedLinkStyle());
                return;
            }
            if (value->isSVGPaint()) {
                SVGPaint* svgPaint = static_cast<SVGPaint*>(value);
                svgstyle->setStrokePaint(svgPaint->paintType(), colorFromSVGColorCSSValue(svgPaint, state.style()->color()), svgPaint->uri(), applyPropertyToRegularStyle(), applyPropertyToVisitedLinkStyle());
            }
            break;
        }
        case CSSPropertyStrokeWidth:
        {
            HANDLE_INHERIT_AND_INITIAL(strokeWidth, StrokeWidth)
            if (primitiveValue)
                svgstyle->setStrokeWidth(SVGLength::fromCSSPrimitiveValue(primitiveValue));
            break;
        }
        case CSSPropertyStrokeDasharray:
        {
            HANDLE_INHERIT_AND_INITIAL(strokeDashArray, StrokeDashArray)
            if (!value->isValueList()) {
                svgstyle->setStrokeDashArray(SVGRenderStyle::initialStrokeDashArray());
                break;
            }

            CSSValueList* dashes = static_cast<CSSValueList*>(value);

            Vector<SVGLength> array;
            size_t length = dashes->length();
            for (size_t i = 0; i < length; ++i) {
                CSSValue* currValue = dashes->itemWithoutBoundsCheck(i);
                if (!currValue->isPrimitiveValue())
                    continue;

                CSSPrimitiveValue* dash = static_cast<CSSPrimitiveValue*>(dashes->itemWithoutBoundsCheck(i));
                array.append(SVGLength::fromCSSPrimitiveValue(dash));
            }

            svgstyle->setStrokeDashArray(array);
            break;
        }
        case CSSPropertyStrokeDashoffset:
        {
            HANDLE_INHERIT_AND_INITIAL(strokeDashOffset, StrokeDashOffset)
            if (primitiveValue)
                svgstyle->setStrokeDashOffset(SVGLength::fromCSSPrimitiveValue(primitiveValue));
            break;
        }
        case CSSPropertyFillOpacity:
        {
            HANDLE_INHERIT_AND_INITIAL(fillOpacity, FillOpacity)
            if (!primitiveValue)
                return;

            float f = 0.0f;
            int type = primitiveValue->primitiveType();
            if (type == CSSPrimitiveValue::CSS_PERCENTAGE)
                f = primitiveValue->getFloatValue() / 100.0f;
            else if (type == CSSPrimitiveValue::CSS_NUMBER)
                f = primitiveValue->getFloatValue();
            else
                return;

            svgstyle->setFillOpacity(f);
            break;
        }
        case CSSPropertyStrokeOpacity:
        {
            HANDLE_INHERIT_AND_INITIAL(strokeOpacity, StrokeOpacity)
            if (!primitiveValue)
                return;

            float f = 0.0f;
            int type = primitiveValue->primitiveType();
            if (type == CSSPrimitiveValue::CSS_PERCENTAGE)
                f = primitiveValue->getFloatValue() / 100.0f;
            else if (type == CSSPrimitiveValue::CSS_NUMBER)
                f = primitiveValue->getFloatValue();
            else
                return;

            svgstyle->setStrokeOpacity(f);
            break;
        }
        case CSSPropertyStopOpacity:
        {
            HANDLE_INHERIT_AND_INITIAL(stopOpacity, StopOpacity)
            if (!primitiveValue)
                return;

            float f = 0.0f;
            int type = primitiveValue->primitiveType();
            if (type == CSSPrimitiveValue::CSS_PERCENTAGE)
                f = primitiveValue->getFloatValue() / 100.0f;
            else if (type == CSSPrimitiveValue::CSS_NUMBER)
                f = primitiveValue->getFloatValue();
            else
                return;

            svgstyle->setStopOpacity(f);
            break;
        }
        case CSSPropertyMarkerStart:
        {
            HANDLE_INHERIT_AND_INITIAL(markerStartResource, MarkerStartResource)
            if (!primitiveValue)
                return;

            String s;
            int type = primitiveValue->primitiveType();
            if (type == CSSPrimitiveValue::CSS_URI)
                s = primitiveValue->getStringValue();

            svgstyle->setMarkerStartResource(SVGURIReference::fragmentIdentifierFromIRIString(s, state.document()));
            break;
        }
        case CSSPropertyMarkerMid:
        {
            HANDLE_INHERIT_AND_INITIAL(markerMidResource, MarkerMidResource)
            if (!primitiveValue)
                return;

            String s;
            int type = primitiveValue->primitiveType();
            if (type == CSSPrimitiveValue::CSS_URI)
                s = primitiveValue->getStringValue();

            svgstyle->setMarkerMidResource(SVGURIReference::fragmentIdentifierFromIRIString(s, state.document()));
            break;
        }
        case CSSPropertyMarkerEnd:
        {
            HANDLE_INHERIT_AND_INITIAL(markerEndResource, MarkerEndResource)
            if (!primitiveValue)
                return;

            String s;
            int type = primitiveValue->primitiveType();
            if (type == CSSPrimitiveValue::CSS_URI)
                s = primitiveValue->getStringValue();

            svgstyle->setMarkerEndResource(SVGURIReference::fragmentIdentifierFromIRIString(s, state.document()));
            break;
        }
        case CSSPropertyStrokeLinecap:
        {
            HANDLE_INHERIT_AND_INITIAL(capStyle, CapStyle)
            if (primitiveValue)
                svgstyle->setCapStyle(*primitiveValue);
            break;
        }
        case CSSPropertyStrokeMiterlimit:
        {
            HANDLE_INHERIT_AND_INITIAL(strokeMiterLimit, StrokeMiterLimit)
            if (!primitiveValue)
                return;

            float f = 0.0f;
            int type = primitiveValue->primitiveType();
            if (type == CSSPrimitiveValue::CSS_NUMBER)
                f = primitiveValue->getFloatValue();
            else
                return;

            svgstyle->setStrokeMiterLimit(f);
            break;
        }
        case CSSPropertyFilter:
        {
            HANDLE_INHERIT_AND_INITIAL(filterResource, FilterResource)
            if (!primitiveValue)
                return;

            String s;
            int type = primitiveValue->primitiveType();
            if (type == CSSPrimitiveValue::CSS_URI)
                s = primitiveValue->getStringValue();

            svgstyle->setFilterResource(SVGURIReference::fragmentIdentifierFromIRIString(s, state.document()));
            break;
        }
        case CSSPropertyMask:
        {
            HANDLE_INHERIT_AND_INITIAL(maskerResource, MaskerResource)
            if (!primitiveValue)
                return;

            String s;
            int type = primitiveValue->primitiveType();
            if (type == CSSPrimitiveValue::CSS_URI)
                s = primitiveValue->getStringValue();

            svgstyle->setMaskerResource(SVGURIReference::fragmentIdentifierFromIRIString(s, state.document()));
            break;
        }
        case CSSPropertyClipPath:
        {
            HANDLE_INHERIT_AND_INITIAL(clipperResource, ClipperResource)
            if (!primitiveValue)
                return;

            String s;
            int type = primitiveValue->primitiveType();
            if (type == CSSPrimitiveValue::CSS_URI)
                s = primitiveValue->getStringValue();

            svgstyle->setClipperResource(SVGURIReference::fragmentIdentifierFromIRIString(s, state.document()));
            break;
        }
        case CSSPropertyTextAnchor:
        {
            HANDLE_INHERIT_AND_INITIAL(textAnchor, TextAnchor)
            if (primitiveValue)
                svgstyle->setTextAnchor(*primitiveValue);
            break;
        }
        case CSSPropertyWritingMode:
        {
            HANDLE_INHERIT_AND_INITIAL(writingMode, WritingMode)
            if (primitiveValue)
                svgstyle->setWritingMode(*primitiveValue);
            break;
        }
        case CSSPropertyStopColor:
        {
            HANDLE_INHERIT_AND_INITIAL(stopColor, StopColor);
            if (value->isSVGColor())
                svgstyle->setStopColor(colorFromSVGColorCSSValue(static_cast<SVGColor*>(value), state.style()->color()));
            break;
        }
       case CSSPropertyLightingColor:
        {
            HANDLE_INHERIT_AND_INITIAL(lightingColor, LightingColor);
            if (value->isSVGColor())
                svgstyle->setLightingColor(colorFromSVGColorCSSValue(static_cast<SVGColor*>(value), state.style()->color()));
            break;
        }
        case CSSPropertyFloodOpacity:
        {
            HANDLE_INHERIT_AND_INITIAL(floodOpacity, FloodOpacity)
            if (!primitiveValue)
                return;

            float f = 0.0f;
            int type = primitiveValue->primitiveType();
            if (type == CSSPrimitiveValue::CSS_PERCENTAGE)
                f = primitiveValue->getFloatValue() / 100.0f;
            else if (type == CSSPrimitiveValue::CSS_NUMBER)
                f = primitiveValue->getFloatValue();
            else
                return;

            svgstyle->setFloodOpacity(f);
            break;
        }
        case CSSPropertyFloodColor:
        {
            HANDLE_INHERIT_AND_INITIAL(floodColor, FloodColor);
            if (value->isSVGColor())
                svgstyle->setFloodColor(colorFromSVGColorCSSValue(static_cast<SVGColor*>(value), state.style()->color()));
            break;
        }
        case CSSPropertyGlyphOrientationHorizontal:
        {
            HANDLE_INHERIT_AND_INITIAL(glyphOrientationHorizontal, GlyphOrientationHorizontal)
            if (!primitiveValue)
                return;

            if (primitiveValue->primitiveType() == CSSPrimitiveValue::CSS_DEG) {
                int orientation = angleToGlyphOrientation(primitiveValue->getFloatValue());
                ASSERT(orientation != -1);

                svgstyle->setGlyphOrientationHorizontal((EGlyphOrientation) orientation);
            }

            break;
        }
        case CSSPropertyGlyphOrientationVertical:
        {
            HANDLE_INHERIT_AND_INITIAL(glyphOrientationVertical, GlyphOrientationVertical)
            if (!primitiveValue)
                return;

            if (primitiveValue->primitiveType() == CSSPrimitiveValue::CSS_DEG) {
                int orientation = angleToGlyphOrientation(primitiveValue->getFloatValue());
                ASSERT(orientation != -1);

                svgstyle->setGlyphOrientationVertical((EGlyphOrientation) orientation);
            } else if (primitiveValue->getIdent() == CSSValueAuto)
                svgstyle->setGlyphOrientationVertical(GO_AUTO);

            break;
        }
        case CSSPropertyEnableBackground:
            // Silently ignoring this property for now
            // http://bugs.webkit.org/show_bug.cgi?id=6022
            break;
        case CSSPropertyWebkitSvgShadow: {
            if (isInherit)
                return svgstyle->setShadow(adoptPtr(state.parentStyle()->svgStyle()->shadow() ? new ShadowData(*state.parentStyle()->svgStyle()->shadow()) : 0));
            if (isInitial || primitiveValue) // initial | none
                return svgstyle->setShadow(nullptr);

            if (!value->isValueList())
                return;

            CSSValueList *list = static_cast<CSSValueList*>(value);
            if (!list->length())
                return;

            CSSValue* firstValue = list->itemWithoutBoundsCheck(0);
            if (!firstValue->isShadowValue())
                return;
            ShadowValue* item = static_cast<ShadowValue*>(firstValue);
            IntPoint location(item->x->computeLength<int>(state.style(), state.rootElementStyle()),
                item->y->computeLength<int>(state.style(), state.rootElementStyle()));
            int blur = item->blur ? item->blur->computeLength<int>(state.style(), state.rootElementStyle()) : 0;
            Color color;
            if (item->color)
                color = colorFromPrimitiveValue(item->color.get());

            // -webkit-svg-shadow does should not have a spread or style
            ASSERT(!item->spread);
            ASSERT(!item->style);

            OwnPtr<ShadowData> shadowData = adoptPtr(new ShadowData(location, blur, 0, Normal, false, color.isValid() ? color : Color::transparent));
            svgstyle->setShadow(shadowData.release());
            return;
        }
        case CSSPropertyVectorEffect: {
            HANDLE_INHERIT_AND_INITIAL(vectorEffect, VectorEffect)
            if (!primitiveValue)
                break;

            svgstyle->setVectorEffect(*primitiveValue);
            break;
        }
        case CSSPropertyMaskType: {
            HANDLE_INHERIT_AND_INITIAL(maskType, MaskType)
            if (!primitiveValue)
                break;

            svgstyle->setMaskType(*primitiveValue);
            break;
        }
        default:
            // If you crash here, it's because you added a css property and are not handling it
            // in either this switch statement or the one in StyleResolver::applyProperty
            ASSERT_WITH_MESSAGE(0, "unimplemented propertyID: %d", id);
            return;
    }
}
示例#30
0
//TODO move to widget
bool tristate_button::hit(int x, int y) const {
	return sdl::point_in_rect(x, y, location());
}