Ejemplo n.º 1
0
scalar KasmiMassonHill::calcHeight(scalar dist, scalar xi0, scalar xi1) const{

	// equal:
	if(xi0 == xi1) return zofxi(xi0);

	// calc x values at boundaries:
	scalar x0 = xofxi(xi0);
	scalar x1 = xofxi(xi1);

	// if close enough, return mean height:
	scalar d0 = mag(x0 - dist);
	scalar d1 = mag(x1 - dist);

	if(d0 <= resolution() && d1 <= resolution()){

		// calc heights
		scalar z0 = zofxi(xi0);
		scalar z1 = zofxi(xi1);

		return d1 / (d0 + d1) * z0 + d0 / (d0 + d1) * z1;

	}

	// calc middle xi and x there:
	scalar xi = 0.5 * (xi0 + xi1);
	scalar x  = xofxi(xi);

	// call again:
	if(x <= dist) return calcHeight(dist,xi,xi1);
	return calcHeight(dist,xi0,xi);

}
Ejemplo n.º 2
0
QPoint OutputConfig::position(void) const
{
    if( !isActive())
        return QPoint();
    int index = positionCombo->currentIndex();
    if((Relation)positionCombo->itemData(index).toInt() == Absolute)
        return QPoint(absolutePosX->value(), absolutePosY->value());

    foreach(OutputConfig *config, precedingOutputConfigs)
    {
        if( config->output()->id()
            == positionOutputCombo->itemData( positionOutputCombo->currentIndex()).toUInt())
        {
            QPoint pos = config->position();
            switch( (Relation)positionCombo->itemData(index).toInt())
            {
                case LeftOf:
                    return QPoint( pos.x() - resolution().width(), pos.y());
                case RightOf:
                    return QPoint( pos.x() + config->resolution().width(), pos.y());
                case Over:
                    return QPoint( pos.x(), pos.y() - resolution().height());
                case Under:
                    return QPoint( pos.x(), pos.y() + config->resolution().height());
                case SameAs:
                    return pos;
                default:
                    abort();
            }
        }
    }
    return QPoint(0, 0);
}
Ejemplo n.º 3
0
void KasmiMassonHill::calcAll(){

	// init and fill height list:
	heightTable_ = HashTable<scalar>( a_ / resolution() + 1);
	for(label i = 0; i < heightTable_.size(); i++){
		scalar d = i * resolution();
		heightTable_.set(hkey(d), calcHeight(d, 0., a_));
	}

}
void GeospatialBoundingBox::exportInformationFile()	{

	FILE *file_ptr = fopen(_format("%s.info",file_name.c_str()).c_str(), "w");
	fprintf(file_ptr, "centroid: %f %f %f\n", centroid(0), centroid(1), centroid(2));
	fprintf(file_ptr, "resolution: %f %f %f\n",resolution(0), resolution(1), resolution(2));
	fprintf(file_ptr, "min_pt: %f %f %f\n", min_pt(0), min_pt(1), min_pt(2));
	fprintf(file_ptr, "max_pt: %f %f %f\n", max_pt(0), max_pt(1), max_pt(2));
	fprintf(file_ptr, "points: %d\n", number_of_points);
	fclose(file_ptr);
	return;
}
Ejemplo n.º 5
0
void set_fullscreen(CVideo& video, const bool ison)
{
	_set_fullscreen(ison);

	const std::pair<int,int>& res = resolution();
	if(video.isFullScreen() != ison) {
		const int flags = ison ? FULL_SCREEN : 0;
		int bpp = video.bppForMode(res.first, res.second, flags);

		if(bpp > 0) {
			video.setMode(res.first,res.second,bpp,flags);
			if(disp) {
				disp->redraw_everything();
			}
		} else {
			int tmp_flags = flags;
			std::pair<int,int> tmp_res;
			if(detect_video_settings(video, tmp_res, bpp, tmp_flags)) {
				set_resolution(video, tmp_res.first, tmp_res.second);
			// TODO: see if below line is actually needed, possibly for displays that only support 16 bbp
			} else if(video.modePossible(1024,768,16,flags)) {
				set_resolution(video, 1024, 768);
			} else {
				gui2::show_transient_message(video,"",_("The video mode could not be changed. Your window manager must be set to 16 bits per pixel to run the game in windowed mode. Your display must support 1024x768x16 to run the game full screen."));
			}
			// We reinit color cursors, because SDL on Mac seems to forget the SDL_Cursor
			set_color_cursors(preferences::get("color_cursors", false));
		}
	}
}
int main(int argc, char *argv[])
{
	BoundingBox	bbox(vcg::Point3i(-20, -20, -20), vcg::Point3i(20, 20, 20));
	vcg::Point3i			resolution(40, 40, 40);
	
	Volume	volume;
	Walker	walker(bbox, resolution);

	typedef vcg::tri::MarchingCubes<Mesh, Walker>					MarchingCubes;
	typedef vcg::tri::ExtendedMarchingCubes<Mesh, Walker> ExtendedMarchingCubes;

	
	
	// MARCHING CUBES
	Mesh		mc_mesh;
	printf("[MARCHING CUBES] Building mesh...");
	MarchingCubes					mc(mc_mesh, walker);
	walker.BuildMesh<MarchingCubes>(mc_mesh, volume, mc);
	vcg::tri::io::ExporterPLY<Mesh>::Save( mc_mesh, "marching_cubes.ply");
	printf("OK!\n");

	// EXTENDED MARCHING CUBES
	Mesh		emc_mesh;
	printf("[EXTENDED MARCHING CUBES] Building mesh...");
	ExtendedMarchingCubes emc(emc_mesh, walker, 30);
	walker.BuildMesh<ExtendedMarchingCubes>(emc_mesh, volume, emc);
	vcg::tri::io::ExporterPLY<Mesh>::Save( emc_mesh, "extended_marching_cubes.ply");
	printf("OK!\n");
};
Ejemplo n.º 7
0
void PocoTimestamp::update()
{
#if defined(NIT_FAMILY_WIN32)

	FILETIME ft;
	GetSystemTimeAsFileTime(&ft);
	ULARGE_INTEGER epoch; // UNIX epoch (1970-01-01 00:00:00) expressed in Windows NT FILETIME
	epoch.LowPart  = 0xD53E8000;
	epoch.HighPart = 0x019DB1DE;

	ULARGE_INTEGER ts;
	ts.LowPart  = ft.dwLowDateTime;
	ts.HighPart = ft.dwHighDateTime;
	ts.QuadPart -= epoch.QuadPart;
	_ts = ts.QuadPart/10;

#else

	struct timeval tv;
	if (gettimeofday(&tv, NULL))
		NIT_THROW_FMT(EX_SYSTEM, "cannot get time of day");
	_ts = TimeVal(tv.tv_sec)*resolution() + tv.tv_usec;

#endif
}
Ejemplo n.º 8
0
int			resolution(char ***addr_square, t_chain *list, int tetriminos)
{
	int		line;
	int		column;
	char	letter;
	int		i;

	if (check_resolved(addr_square, &letter, &i, tetriminos))
		return (1);
	if (i)
		list = list->next;
	line = -1;
	while ((*addr_square)[++line])
	{
		column = -1;
		while ((*addr_square)[line][++column])
		{
			if (insert_tetrimino(addr_square, list->tetrimino, line, column))
			{
				if (resolution(addr_square, list, tetriminos))
					return (1);
			}
			erase_tetrimino(addr_square, letter);
		}
	}
	return (0);
}
Ejemplo n.º 9
0
static void calc_imaginary(fitinfo *fit)
{
  assert(fit->datatype == FIT_IMAGINARY);

  /* Generate reflectivity amplitude from the profile */
  reflectivity_imag(fit->p.n, fit->p.d, fit->p.rho,
		    fit->p.mu, fit->beam.lambda, fit->beam.alignment,
		    fit->nQ, fit->fitQ, fit->fitA);

  /* FIXME need to support repeated Q with different resolution. For
     the resolution case, this simply means making sure that enough
   */
  assert(fit->nQ == fit->dataA.n);

  /* Compute the convolution of the reflectivity */
  /* FIXME can you simply convolve the real reflectivity? */
  if (fit->work != NULL) {
    resolution(fit->nQ, fit->fitQ, fit->fitA,
               fit->dataA.n, fit->dataA.Q, fit->dataA.dQ, fit->work);
    memcpy(fit->fitA, fit->work, sizeof(Real)*fit->dataA.n);
  }

  /* FIXME sumsq is now based on data Q values rather than
   * theory Q values, so we have grounding problems. */
  assert(fit->work != NULL);
}
Ejemplo n.º 10
0
static void apply_beam_parameters(fitinfo *fit, Real *cross_section,
				  fitdata *data)
{
  /* Account for back absorption, background and intensity.
   * Strictly speaking background and intensity should be
   * applied after resolution is calculated, but mathematically
   * it is equivalent to apply them before or after.  Back absorption,
   * which varies with Q, must be applied before resolution.
   */
  beam_apply(&fit->beam, fit->nQ, fit->fitQ, cross_section);

  /* Compute the convolution of the reflectivity */
  if (fit->work != NULL) {
    /* FIXME We are not allocating enough storage for multiple measurements
       with different resolution.  Make sure that we fail in a controlled
       way until we have a chance to fix this. */
    assert(data->n <= fit->nQ);
    resolution(fit->nQ, fit->fitQ, cross_section,
               data->n, data->Q, data->dQ, fit->work);
    memcpy(cross_section, fit->work, sizeof(Real)*data->n);
  } else {
    assert(data->n == fit->nQ);
    /* FIXME --- with no resolution, need to copy/interpolate raw data
       values at data->Q from the computed values at fit->fitQ.
    */
  }
  /* FIXME sumsq is now based on data Q values rather than
   * theory Q values, so we have grounding problems. */
  assert(fit->work != NULL);
}
// Copy constructor with all the parameter and copy constructor for constructor with request and mimetype as parameter.
void tst_QMediaResource::copyConstructor()
{
    // Initialise all the parameters.
    const QUrl url(QString::fromLatin1("http://test.com/test.mp4"));
    const QString mimeType(QLatin1String("video/mp4"));
    const QString amrCodec(QLatin1String("amr"));
    const QString h264Codec(QLatin1String("h264"));

    const qint64 dataSize(23600);
    int audioBitRate = 1, sampleRate = 2, channelCount = 3, videoBitRate = 4;
    QSize resolution(QSize(640, 480));
    QString language("eng");

    // Create the instance with url and mimetype.
    QMediaResource original(url, mimeType);

    // Set all the parameters.
    original.setAudioCodec(amrCodec);
    original.setLanguage(QString("eng"));
    original.setVideoCodec(h264Codec);
    original.setDataSize(dataSize);
    original.setAudioBitRate(audioBitRate);
    original.setSampleRate(sampleRate);
    original.setChannelCount(channelCount);
    original.setVideoBitRate(videoBitRate);
    original.setResolution(resolution);

    // Copy the instance to new object.
    QMediaResource copy(original);

    // Verify all the parameters of the copied object.
    QCOMPARE(copy.url(), url);
    QCOMPARE(copy.mimeType(), mimeType);
    QCOMPARE(copy.audioCodec(), amrCodec);
    QCOMPARE(copy.language(), language );
    QCOMPARE(copy.videoCodec(), h264Codec);
    QCOMPARE(copy.dataSize(), dataSize);
    QCOMPARE(copy.audioBitRate(), audioBitRate);
    QCOMPARE(copy.sampleRate(), sampleRate);
    QCOMPARE(copy.channelCount(), channelCount);
    QCOMPARE(copy.videoBitRate(), videoBitRate);
    QCOMPARE(copy.resolution(), resolution);

    // Compare both the objects are equal.
    QCOMPARE(original == copy, true);
    QCOMPARE(original != copy, false);

    // Initialise the request parameter.
    QNetworkRequest request1(QUrl(QString::fromLatin1("http://test.com/test.mp4")));

    // Constructor with rerquest and mimetype.
    QMediaResource original1(request1, mimeType);

    // Copy the object and verify if both are eqaul or not.
    QMediaResource copy1(original1);
    QCOMPARE(copy1.url(), url);
    QCOMPARE(copy1.mimeType(), mimeType);
    QCOMPARE(copy1.request(), request1);
    QCOMPARE(original1 == copy1, true);
}
Ejemplo n.º 12
0
void ZebraPaintEngine::drawText ( const QPointF &p, const QString & text, const QFont &font )
{
  QTransform transform = painter()->worldTransform();

  int xInDots = (int)(transform.dx());
  int yInDots = (int)(transform.dy());

  int carHeight = (font.pointSize() * resolution()) / 72;
  const int minSize = 10;
  if(carHeight < minSize) {
    carHeight = minSize;
  }
  int carWidth = qRound((carHeight * 15.0) / 28.0); // fixed width/height ratio for the scalable A0 font

  QString rotation = transformRotationCmd();
  if(rotation == rotation90Cmd()) {
    xInDots -= carHeight;
  }
  else if(rotation == rotation180Cmd()) {
    yInDots -= carHeight;
    xInDots -= (carWidth * text.length());
  }
  else if(rotation == rotation270Cmd()) {
    yInDots -= (carWidth * text.length());
  }

  QString output = QString(m_CmdPrefix + "FO%1,%2" + m_CmdPrefix + "FW%3").arg(xInDots).arg(yInDots).arg(rotation);
  output += QString(m_CmdPrefix + "A0,%1,0" + m_CmdPrefix + "FD" + text + m_CmdPrefix + "FS\n").arg(carHeight);

  QTextCodec *codec = QTextCodec::codecForName("IBM 850");
  m_printBuffer.append(codec->fromUnicode(output));
}
Ejemplo n.º 13
0
void VolumeSeriesSource::openSeries() {
    if(volumeHandle_)
        delete volumeHandle_;
    volumeHandle_ = 0;

    try {
        TextFileReader reader(filename_.get());
        if (!reader)
            throw tgt::FileNotFoundException("Reading sdat file failed", filename_.get());

        std::string type;
        std::istringstream args;
        std::string format, model;
        tgt::ivec3 resolution(0);
        tgt::vec3 sliceThickness(1.f);
        spreadMin_ = 0.f;
        spreadMax_ = 0.f;

        files_.clear();
        std::string blockfile;

        while (reader.getNextLine(type, args, false)) {
            if (type == "ObjectFileName:") {
                std::string s;
                args >> s;
                LDEBUG(type << " " << s);
                files_.push_back(tgt::FileSystem::dirName(filename_.get()) + "/" + s);
            } else if (type == "Resolution:") {
                args >> resolution[0];
                args >> resolution[1];
                args >> resolution[2];
                LDEBUG(type << " " << resolution[0] << " x " <<
                       resolution[1] << " x " << resolution[2]);
            } else if (type == "SliceThickness:") {
Ejemplo n.º 14
0
void	move(int keycode, t_init *st)
{
	if (keycode == 123)
	{
		st->x1 += 0.1 / (0.01 * st->zoom);
		st->x2 -= 0.1 / (0.01 * st->zoom);
	}
	if (keycode == 124)
	{
		st->x1 -= 0.1 / (0.01 * st->zoom);
		st->x2 += 0.1 / (0.01 * st->zoom);;
	}
	if (keycode == 125)
	{
		st->y1 -= 0.1 / (0.01 * st->zoom);
		st->y2 += 0.1 / (0.01 * st->zoom);
	}
	if (keycode == 126)
	{
		st->y1 += 0.1 / (0.01 * st->zoom);
		st->y2 -= 0.1 / (0.01 * st->zoom);
	}
	mlx_clear_window(st->mlx, st->win);
	resolution(*st);
	mlx_put_image_to_window(st->mlx, st->win, st->link,
			st->pos_x_image, st->pos_y_image);
}
Ejemplo n.º 15
0
int Step::createCsi(
  QString const     &addLine,
  QStringList const &csiParts,  // the partially assembles model
  QPixmap           *pixmap,
  Meta              &meta)
{
  qreal       modelScale = meta.LPub.assem.modelScale.value();
  int         sn = stepNumber.number;
  
  // 1 color x y z a b c d e f g h i foo.dat
  // 0 1     2 3 4 5 6 7 8 9 0 1 2 3 4
  QStringList tokens;
  split(addLine,tokens);
  QString orient;
  if (tokens.size() == 15) {
    for (int i = 5; i < 14; i++) {
      orient += "_" + tokens[i];
    }
  }
  QString key = QString("%1_%2_%3_%4_%5_%6")
                        .arg(csiName()+orient)
                        .arg(sn)
                        .arg(meta.LPub.page.size.valuePixels(0))
                        .arg(resolution())
                        .arg(resolutionType() == DPI ? "DPI" : "DPCM")
                        .arg(modelScale);
  QString fileName = QDir::currentPath() + "/" +
                      Paths::assemDir + "/" + key + ".png";
  QFile csi(fileName);

  bool outOfDate = false;
  
  if (csi.exists()) {
    QDateTime lastModified = QFileInfo(fileName).lastModified();    
    QStringList stack = submodelStack();
    stack << parent->modelName();
    if ( ! isOlder(stack,lastModified)) {
      outOfDate = true;
    }
  }

  if ( ! csi.exists() || outOfDate) {

    int        rc;

    // render the partially assembled model

    rc = renderer->renderCsi(addLine,csiParts, fileName, meta);

    if (rc < 0) {
      return rc;
    }
  } 
  pixmap->load(fileName);
  csiPlacement.size[0] = pixmap->width();
  csiPlacement.size[1] = pixmap->height();

  return 0;
}
Ejemplo n.º 16
0
void QSFMLCanvas::resizeGL(int width, int height)
{
  Vector3 resolution(width,height,32);
  
  setResolution(resolution);
  
  glViewport(0,0,width,height);
}
void GeospatialBoundingBox::load(int index, std::string *base_file_name)	{

	if (base_file_name)	{
		file_name = (*base_file_name);
	}
	else	{
		file_name = _format("geo_bbox_%d.xyz.info",index);
	}

	FILE *file_ptr = fopen(file_name.c_str(), "r");
	fscanf(file_ptr,"centroid: %f %f %f\n",&centroid(0), &centroid(1), &centroid(2));
	fscanf(file_ptr,"resolution: %f %f %f\n",&resolution(0), &resolution(1), &resolution(2));
	fscanf(file_ptr,"min_pt: %f %f %f\n",&min_pt(0), &min_pt(1), &min_pt(2));
	fscanf(file_ptr,"max_pt: %f %f %f\n",&max_pt(0), &max_pt(1), &max_pt(2));
	fscanf(file_ptr,"points: %d\n", &number_of_points);
	fclose(file_ptr);
	return;
}
Ejemplo n.º 18
0
bool 	ZebraPaintEngine::begin ( QPaintDevice * pdev )
{
  QString init = m_CmdPrefix + "XA" + m_CmdPrefix + "LRY";

  if(!customInitString().isEmpty()) {
    init += customInitString();
  }
  else {
    int height = m_parentPrinter->paperRect().height() * (resolution()/72.0); // ?? doc says that paperRect() is in device coordinates, but we get it in PS points
    int width = m_parentPrinter->paperRect().width() * (resolution()/72.0);
    init += QString(m_CmdPrefix + "LL%1" + m_CmdPrefix + "PW%2" + m_CmdPrefix + "CI8").arg(height).arg(width);
  }

  init += "\n";

  m_printBuffer.append(init);
  return true;
}
Ejemplo n.º 19
0
int main ()
{
   char vertex_shader[512];
   char fragment_shader[512];
   char geometry_shader[512];

   
   
   int terminate = 0;
   GLfloat cx, cy;
   bcm_host_init();

   // Clear application state
   memset( state, 0, sizeof( *state ) );
      
   // Start OGLES
   init_ogl(state);


   glm::vec3 resolution((float)state->screen_width,(float)state->screen_height,0.0f);


   cx = state->screen_width/2;
   cy = state->screen_height/2;
   state->verbose=1;

   Shader shader(vertex_shader, fragment_shader,geometry_shader);
   init_shaders(state);
   
   //glBindAttribLocation (shader.Program, 0 , "position");
   shader.linkProg();
   shader.Use();
   state->program=shader.Program;

   GLint resLoc = glGetUniformLocation(shader.Program, "iResolution");
   glUniform3f(resLoc,resolution.x,resolution.y,resolution.z);
   GLfloat currentTime = 0.0f;

   GLint timeLoc = glGetUniformLocation(shader.Program, "time");
   glUniform1f(timeLoc,currentTime);
   
   //draw_mandelbrot_to_texture(state, cx, cy, 0.003);
   while (!terminate)
   {
      int x, y, b;
      currentTime=currentTime+0.02;
      
      timeLoc = glGetUniformLocation(shader.Program, "time");
      glUniform1f(timeLoc,currentTime);
      
      b = get_mouse(state, &x, &y);
      if (b) break;
      draw_triangles(state, cx, cy, 0.003, x, y);
   }
   return 0;
}
Ejemplo n.º 20
0
scalar KasmiMassonHill::height(scalar dist) const{

	// simple cases:
	if(dist >= a_) return 0.;
	if(dist < resolution()) return maxHeight_;

	// chop to resolution():
	label hi     = dist / resolution();
	scalar hdist = hi * resolution();

	// check if already calculated, calc otherwise:
	word k = hkey(hdist);
	if(!heightTable_.found(k)){
		heightTable_.set(k,calcHeight(hdist, 0., a_));
	}

	return heightTable_[k];

}
Ejemplo n.º 21
0
void		han_shot_first(t_init st, char *str)
{
	st = init_all(st, str);
	resolution(st);
	mlx_hook(st.win, 2, 1, key_hook, &st);
	if (ft_strcmp(str, "Julia") == 0)
		mlx_hook(st.win, 6, (1L << 6), motion_hook, &st);
	mlx_mouse_hook(st.win, mouse_hook, &st);
	mlx_put_image_to_window(st.mlx, st.win, st.link,
			st.pos_x_image, st.pos_y_image);
	mlx_loop(st.mlx);
}
Ejemplo n.º 22
0
int main(int argc, char** argv) {
  Eigen::Matrix<double, 2, 1> minimum(-2, -2);
  Eigen::Matrix<double, 2, 1> maximum(2, 2);
  Eigen::Matrix<double, 2, 1> resolution(0.05, 0.05);
  QApplication app(argc, argv);
  FunctionPlot<NormalDistribution<2>, 2> plot("NormalDistribution2v",
    NormalDistribution<2>(Eigen::Matrix<double, 2, 1>(1.0, 1.0),
    (Eigen::Matrix<double, 2, 2>() << 2, 0, 0, 2).finished()), minimum, maximum,
    resolution);
  plot.show();
  return app.exec();
}
	void AmbientOcclusionManager::onResize(unsigned int width, unsigned int height)
	{
		sceneWidth = width;
		sceneHeight = height;
		
		createOrUpdateAOTexture();
		createOrUpdateAOShader();

		ShaderManager::instance()->bind(ambientOcclusionShader);
        Vector2<float> resolution(sceneWidth, sceneHeight);
        glUniform2fv(resolutionLoc, 1, (const float *)resolution);
	}
Ejemplo n.º 24
0
void	change_color(t_init *st)
{
	static int k;
	if (k == 0)
		k = 2;
	st->cols = init_color(*st, k);
	k += 1;
	mlx_clear_window(st->mlx, st->win);
	resolution(*st);
	mlx_put_image_to_window(st->mlx, st->win, st->link,
			st->pos_x_image, st->pos_y_image);
}
Ejemplo n.º 25
0
	void UILabel::repaint(EngineInternals &internals, const UILayer &ui)
	{
		_elements.clear();
		_elementPointers.clear();
		_textures.clear();

		float x = 0;
		float y = 0;

		std::wstring_convert<std::codecvt_utf8_utf16<wchar_t>> convert;
		std::wstring result = convert.from_bytes(_text);

		Vector2 resolution(size.x * ui.getRatio(), size.y * ui.getRatio());
		for (std::wstring::const_iterator i = result.begin(); i != result.end(); i++)
		{
			auto &g = _typeEngine.getGlyph(*i, (unsigned int)resolution.y);

			float x2 = x + (float)g.bitmap.left;
			float y2 = y + (resolution.y - (float)g.bitmap.top);

			Texture2D *tex;
			if (_textures.find(*i) != _textures.end())
			{
				tex = _textures[*i].get();
			}
			else
			{
				_textures[*i] = std::make_shared<Texture2D>(g.bitmap.buffer, Pixmap::Information(Metric2(g.bitmap.width, g.bitmap.height), Pixmap::Information::Format::ALPHA, 8));
				tex = _textures[*i].get();
			}

			UIElement glyph = UIElement(Vector2((float)g.bitmap.width / ui.getRatio(), (float)g.bitmap.height / ui.getRatio()), Alignment::TOP_LEFT, Vector2(x2 / ui.getRatio(), y2 / ui.getRatio()), tex);
			glyph.uvs[0] = Vector2(0, 0);
			glyph.uvs[1] = Vector2(1, 0);
			glyph.uvs[2] = Vector2(1, 1);
			glyph.uvs[3] = Vector2(0, 1);

			x += g.advance.x;
			y += g.advance.y;

			_elements.push_back(glyph);
		}
		for (auto &element : _elements)
		{
			_elementPointers.push_back(&element);
		}

		if (!_fixed)
		{
			size.x = x / ui.getRatio();
		}
	}
bool
AsyncCompositionManager::TransformShadowTree(TimeStamp aCurrentFrame)
{
  Layer* root = mLayerManager->GetRoot();
  if (!root) {
    return false;
  }

  // NB: we must sample animations *before* sampling pan/zoom
  // transforms.
  bool wantNextFrame = SampleAnimations(root, aCurrentFrame);

  // FIXME/bug 775437: unify this interface with the ~native-fennec
  // derived code
  //
  // Attempt to apply an async content transform to any layer that has
  // an async pan zoom controller (which means that it is rendered
  // async using Gecko). If this fails, fall back to transforming the
  // primary scrollable layer.  "Failing" here means that we don't
  // find a frame that is async scrollable.  Note that the fallback
  // code also includes Fennec which is rendered async.  Fennec uses
  // its own platform-specific async rendering that is done partially
  // in Gecko and partially in Java.
  if (!ApplyAsyncContentTransformToTree(aCurrentFrame, root, &wantNextFrame)) {
    nsAutoTArray<Layer*,1> scrollableLayers;
#ifdef MOZ_WIDGET_ANDROID
    scrollableLayers.AppendElement(mLayerManager->GetPrimaryScrollableLayer());
#else
    mLayerManager->GetScrollableLayers(scrollableLayers);
#endif

    for (uint32_t i = 0; i < scrollableLayers.Length(); i++) {
      if (scrollableLayers[i]) {
#ifdef MOZ_WIDGET_ANDROID
        // XXX We use rootTransform instead of the resolution on the individual layer's
        // FrameMetrics on Fennec because the resolution is set on the root layer rather
        // than the scrollable layer. See bug 732971. On non-Fennec we do the right thing.
        const gfx3DMatrix& rootTransform = root->GetTransform();
        LayoutDeviceToLayerScale resolution(1.0 / rootTransform.GetXScale(),
                                            1.0 / rootTransform.GetYScale());
#else
        LayoutDeviceToLayerScale resolution =
            scrollableLayers[i]->AsContainerLayer()->GetFrameMetrics().mResolution;
#endif
        TransformScrollableLayer(scrollableLayers[i], resolution);
      }
    }
  }

  return wantNextFrame;
}
UStatus
ua_sensors_orientation_get_resolution(
    UASensorsOrientation* sensor,
    float* value)
{
    if (sensor == NULL || value == NULL)
        return U_STATUS_ERROR;

    ALOGI("%s():%d", __PRETTY_FUNCTION__, __LINE__);
    auto s = static_cast<ubuntu::application::sensors::Sensor*>(sensor);
    *value = s->resolution();

    return U_STATUS_SUCCESS;
}
Ejemplo n.º 28
0
void Timestamp::update()
{
#if defined(POCO_OS_FAMILY_WINDOWS)

	FILETIME ft;
#if defined(_WIN32_WCE) && defined(POCO_WINCE_TIMESTAMP_HACK)
	GetSystemTimeAsFileTimeWithMillisecondResolution(&ft);
#else
	GetSystemTimeAsFileTime(&ft);
#endif

	ULARGE_INTEGER epoch; // UNIX epoch (1970-01-01 00:00:00) expressed in Windows NT FILETIME
	epoch.LowPart  = 0xD53E8000;
	epoch.HighPart = 0x019DB1DE;

	ULARGE_INTEGER ts;
	ts.LowPart  = ft.dwLowDateTime;
	ts.HighPart = ft.dwHighDateTime;
	ts.QuadPart -= epoch.QuadPart;
	_ts = ts.QuadPart/10;

#elif defined(POCO_HAVE_CLOCK_GETTIME)

	struct timespec ts;
	if (clock_gettime(CLOCK_REALTIME, &ts))
		throw SystemException("cannot get time of day");
	_ts = TimeVal(ts.tv_sec)*resolution() + ts.tv_nsec/1000;

#else

	struct timeval tv;
	if (gettimeofday(&tv, NULL))
		throw SystemException("cannot get time of day");
	_ts = TimeVal(tv.tv_sec)*resolution() + tv.tv_usec;

#endif
}
Ejemplo n.º 29
0
widget_settings_dialog* button::settings_dialog(int x, int y, int w, int h)
{
	widget_settings_dialog* d = widget::settings_dialog(x,y,w,h);

	grid_ptr g(new grid(2));
	g->add_col(new label("H Pad:", d->text_size(), d->font()));
	g->add_col(new slider(120, [&](double f){this->set_dim(0,0); this->set_hpadding(int(f*100.0));}, hpadding_/100.0, 1));
	g->add_col(new label("V Pad:", d->text_size(), d->font()));
	g->add_col(new slider(120, [&](double f){this->set_dim(0,0); this->set_vpadding(int(f*100.0));}, vpadding_/100.0, 1));

	std::vector<std::string> v;
	v.push_back("normal");
	v.push_back("double");
	dropdown_widget_ptr resolution(new dropdown_widget(v, 150, 28, dropdown_widget::DROPDOWN_LIST));
	resolution->set_font_size(14);
	resolution->set_dropdown_height(h);
	resolution->set_selection(button_resolution_ == BUTTON_SIZE_NORMAL_RESOLUTION ? 0 : 1);
	resolution->set_on_select_handler([&](int n, const std::string& s){
		this->button_resolution_ = s == "normal" ? BUTTON_SIZE_NORMAL_RESOLUTION : BUTTON_SIZE_DOUBLE_RESOLUTION;
		this->setup();
	});
	resolution->set_zorder(11);
	g->add_col(new label("Resolution:", d->text_size(), d->font()));
	g->add_col(resolution);

	v.clear();
	v.push_back("default");
	v.push_back("normal");
	dropdown_widget_ptr style(new dropdown_widget(v, 150, 28, dropdown_widget::DROPDOWN_LIST));
	style->set_font_size(14);
	style->set_dropdown_height(h);
	style->set_selection(button_style_ == BUTTON_STYLE_DEFAULT ? 0 : 1);
	style->set_on_select_handler([&](int n, const std::string& s){
		this->button_style_ = s == "normal" ? BUTTON_STYLE_NORMAL : BUTTON_STYLE_DEFAULT;
		this->setup();
	});
	style->set_zorder(10);
	g->add_col(new label("Style:", d->text_size(), d->font()));
	g->add_col(style);

	// label: widget
	// on_click: function
	// *** resolution: string/dropdown (normal/double)
	// *** style: string/dropdown (default/formal)
	// *** hpad: int
	// *** vpad: int
	d->add_widget(g);
	return d;
}
Ejemplo n.º 30
0
 Image* ImageDeserializer::convertFipImage(fipImage& fimg, std::string filename)
 {
     // need to create tmp fimg because of an bug in FreeImage
     fipImage tmp(fimg);
     tmp.convertToFloat();
     Vec2ui resolution(tmp.getWidth(), tmp.getHeight());
     Image* image = new Image(resolution);
     for(unsigned int y = 0; y < resolution.y; y++)
     {
         // freeImage reads the images flipped vertically, so flip them back
         float* tgtPtr = image->getScanLineData(resolution.y - y - 1);
         memcpy(tgtPtr, tmp.getScanLine(y), resolution.x * sizeof(float));
     }
     return image;
 }