void GLPixelBuffer::unlockImpl(void)
	{
		if (mCurrentLockOptions != GBL_READ_ONLY)
		{
			// From buffer to card, only upload if was locked for writing
			upload(mCurrentLock, mLockedBox);
		}
	
		freeBuffer();
	}
Beispiel #2
0
	/** Uploads a filename, and if necessary, uploads the data as well.
	 *
	 * @param name         The named file to be uploaded (of the form "meerkat:///somefile.texture")
	 * @param hashContext  The location to upload the data to (usually "mhash:")
	 * @param toUpload     Data to be uploaded. Will only be uploaded if necessary.
	 * @param listener     An EventListener to receive a UploadEventPtr with the retrieved data.
	 * @param forceIfExists Upload the data even if the file already exists on all known CDN services.
	 */
	inline void upload(const URI &name,
			const URIContext &hashContext,
			const DenseDataPtr &toUpload,
			const EventListener &listener,
			bool forceIfExists) {
		RemoteFileId rfid(
			Fingerprint::computeDigest(toUpload->data(), toUpload->length()),
			hashContext);
		upload(name, rfid, toUpload, listener, forceIfExists);
	}
Beispiel #3
0
static int put(void)
{
    res = ne_concat(i_path, "lockme", NULL);
    res2 = ne_concat(i_path, "notlocked", NULL);
    //res3 = ne_concat(i_path,"not-existing",NULL);

    CALL(upload_foo("lockme"));
    CALL(upload("notlocked", "./htdocs/bar"));    

    return OK;
}
IndexBufferImpl::IndexBufferImpl(uint length, uint fmt, const void* data, LPDIRECT3DDEVICE9 device) {
	D3DFORMAT table[] = {D3DFMT_INDEX16, D3DFMT_INDEX32};

	assert(("Unknown format", fmt <= 1));

	if (FAILED(device->CreateIndexBuffer(length, 0, table[fmt], D3DPOOL_DEFAULT, &ib, 0)))
		throw Exception("Failed to allocate VertexBuffer");

	if (data != nullptr)
		upload(data, 0, length);
}
Beispiel #5
0
void Uploader::onUploadButton()
{
  QFileInfo fi(browseEdit->text());
  if(!fi.exists())
    return mainWindow->message( tr("%1 can't be found.").arg(fi.fileName()), MsgType::Error, tr("Uploader") );

  if( uploader.state() != QProcess::NotRunning )
    return mainWindow->message( tr("Uploader is currently busy...give it a second, then try again"), MsgType::Error, tr("Uploader") );

  upload(fi.filePath());
}
    void GL3PlusHardwarePixelBuffer::unlockImpl(void)
    {
        if (mCurrentLockOptions != HardwareBuffer::HBL_READ_ONLY)
        {
            // From buffer to card, only upload if was locked for writing.
            upload(mCurrentLock, mLockedBox);
        }
        freeBuffer();

        mBuffer = PixelBox( mWidth, mHeight, mDepth, mFormat, mBuffer.data );
    }
Beispiel #7
0
void Quad::draw() const {
  // upload to GPU if neccessary
  if (!verts_) {
    upload();
  }

  rectangle_->Bind();
  ogl::Context::DrawArrays(oglplus::PrimitiveType::TriangleStrip, 0, 4);

  oglplus::NoVertexArray().Bind();
}
Beispiel #8
0
void Quad::draw(unsigned instance_count) const {

  // upload to GPU if neccessary
  if (!verts_) {
    upload();
  }

  rectangle_->Bind();
  ogl::Context::DrawArraysInstanced(oglplus::PrimitiveType::TriangleStrip, 0, 4, instance_count);

  oglplus::NoVertexArray().Bind();
}
Beispiel #9
0
MainWindow::MainWindow() {
    int row = 0;
    qRegisterMetaType<Buttons>("Buttons");
    connect(&worker, SIGNAL(status(QString)), this, SLOT(status(QString)));
    connect(&worker, SIGNAL(progress(int)), this, SLOT(progress(int)));
    connect(&worker, SIGNAL(buttons(Buttons)), this, SLOT(buttons(Buttons)));

    refreshButton.setText("Refresh");
    grid.addWidget(&refreshButton, row++, 0);
    
    fileListBox.setSizeConstraint(QLayout::SetFixedSize);
    fileListWidget.setLayout(&fileListBox);
    fileListArea.setWidgetResizable(true);
    fileListArea.setWidget(&fileListWidget);
    fileListAreaBox.setContentsMargins(1, 0, 1, 3);
    fileListAreaBox.addWidget(&fileListArea);
    fileListAreaWidget.setFixedHeight(192);
    fileListAreaWidget.setLayout(&fileListAreaBox);
    grid.addWidget(&fileListAreaWidget, row++, 0);

    progressBar.setMinimum(0);
    progressBar.setMaximum(10000);
    progressBarBox.setContentsMargins(1, 0, 0, 0);
    progressBarBox.addWidget(&progressBar, 0);
    progressBarWidget.setLayout(&progressBarBox);
    grid.addWidget(&progressBarWidget, row++, 0);

    uploadButton.setText("Upload");
    grid.addWidget(&uploadButton, row++, 0);

    verifyButton.setText("Verify");
    grid.addWidget(&verifyButton, row++, 0);

    widget.setParent(this);
    widget.setLayout(&grid);
    setCentralWidget(&widget);

    setWindowTitle("WAV uploader");
    statusBar()->setSizeGripEnabled(false);
    setFixedSize(384, minimumSizeHint().height());
    setWindowFlags(Qt::MSWindowsFixedSizeDialogHint);

    connect(&refreshButton, SIGNAL(clicked()), this, SLOT(refresh()));
    connect(&uploadButton, SIGNAL(clicked()), this, SLOT(upload()));
    connect(&verifyButton, SIGNAL(clicked()), this, SLOT(verify()));
    
    buttons(Buttons::Step1);
    progress();
    status();

    refresh();
    show();
}
Beispiel #10
0
eIndexBufferDx9::eIndexBufferDx9(IDirect3DDevice9 *d3dDev, eU32 count, eBool dynamic) :
    m_d3dDev(d3dDev),
    m_count(count),
    m_locked(eFALSE),
    m_dynamic(dynamic),
    m_d3dIb(eNULL)
{
    eASSERT(d3dDev != eNULL);
    eASSERT(count > 0);

    upload();
}
Beispiel #11
0
	// custom drawing
	void VAO::begin(GLuint vertexSize, GLsizei vertices, const GLvoid* data, GLenum usage)
	{
		this->isCreating = true;

		// create VAO & VBO
		if (vao == 0)
		{
			glGenVertexArrays(1, &vao);
			glGenBuffers(1, &vbo);
		}
		upload(vertexSize, vertices, data, usage);
	}
Beispiel #12
0
bool qt_dempak::init(QString file) {
	int inlen = 0;
	int stage = 0;
	char inbuf[16384],outbuf[16384];
	z_stream stream;
	FILE *fp;
	if (!(fp = fopen(file.toAscii(),"rb"))) {
		errorString=QString("Error opening file %1").arg(file);
		return(false);
	}
	// read and check header
	fseek(fp, 0, SEEK_SET);
	fread (inbuf,1,4,fp);
	inbuf[4]='\0';
	if ( strcmp("MPAK",inbuf) ) {
		errorString=QString("%1 not valid MPAK file").arg(file);
		return(false);	
	}
	// zstream start
	fseek(fp, 21, SEEK_SET);
	
	memset(&stream,0,sizeof(z_stream));

	inflateInit(&stream); 
	while (!feof(fp) || inlen > 0) {
		int rc=0;
		inlen += fread(inbuf + inlen, 1, sizeof(inbuf) - inlen, fp);
		stream.next_in = (unsigned char *)inbuf;
		stream.avail_in = inlen;
		stream.next_out = (unsigned char *)outbuf;
		stream.avail_out = sizeof(outbuf);
		rc = inflate(&stream, 0);
		if (rc != Z_STREAM_END && rc != Z_OK) {
			errorString=QString("inflate returned %d").arg(rc);
			return(false);
		}
        if ((char*)stream.next_out > outbuf)
			upload(stage, outbuf, (char*)stream.next_out - outbuf);

		if ((char*)stream.next_in > inbuf) {
			memmove(inbuf, stream.next_in, stream.avail_in);
			inlen = stream.avail_in;
		}
		if (rc == Z_STREAM_END) {
			++stage;
			inflateEnd(&stream);
			inflateInit(&stream);
		}
    }
	inflateEnd(&stream);
	fclose(fp);
	return(true);
}
Beispiel #13
0
	void GLPixelBuffer::unlock()
	{
		assert(mIsLocked && "Cannot unlock this buffer, it is not locked!");

		if (mCurrentLockOptions != GBL_READ_ONLY)
		{
			// From buffer to card, only upload if was locked for writing
			upload(mCurrentLock, mLockedBox);
		}

		freeBuffer();
		mIsLocked = false;
	}
Beispiel #14
0
int main(int c, char **argv) {
	CURL *curlhandle = NULL;

	curl_global_init(CURL_GLOBAL_ALL);
	curlhandle = curl_easy_init();

	upload(curlhandle, "ftp://*****:*****@host/path/file", "C:\\file", 0, 3);

	curl_easy_cleanup(curlhandle);
	curl_global_cleanup();

	return 0;
}
Beispiel #15
0
static void
generate_data(const struct fmt_test *test)
{
	unsigned pixels = piglit_width * piglit_height;
	void *data = malloc(pixels * test->bpp);

	char *p = data;
	for (unsigned i = 0; i < pixels; i++, p += test->bpp)
		value_for_format(test, p);

	upload(test, data);
	free(data);
}
Beispiel #16
0
QString takeScreenshot(QRect area) {
    QPixmap shot = grabEntireScreen();

    if (area.isValid())
        shot = shot.copy(area);

    PuushFile file = compressImage("ss", shot);

    if (settings.onPuushActions & Settings::SaveToDisk)
        writeFileToDisk(file);

    return upload(file);
}
    void GLES2HardwarePixelBuffer::blitFromMemory(const PixelBox &src, const Image::Box &dstBox)
    {
        if (!mBuffer.contains(dstBox))
        {
            OGRE_EXCEPT(Exception::ERR_INVALIDPARAMS,
                        "Destination box out of range",
                        "GLES2HardwarePixelBuffer::blitFromMemory");
        }

        PixelBox scaled;

        if (src.getWidth() != dstBox.getWidth() ||
            src.getHeight() != dstBox.getHeight() ||
            src.getDepth() != dstBox.getDepth())
        {
            // Scale to destination size.
            // This also does pixel format conversion if needed
            allocateBuffer();
            scaled = mBuffer.getSubVolume(dstBox);
            Image::scale(src, scaled, Image::FILTER_BILINEAR);
        }
        else if ((src.format != mFormat) ||
                 ((GLES2PixelUtil::getGLOriginFormat(src.format) == 0) && (src.format != PF_R8G8B8)))
        {
            // Extents match, but format is not accepted as valid source format for GL
            // do conversion in temporary buffer
            allocateBuffer();
            scaled = mBuffer.getSubVolume(dstBox);
            PixelUtil::bulkPixelConversion(src, scaled);
            
            if(mFormat == PF_A4R4G4B4)
            {
                // ARGB->BGRA
                GLES2PixelUtil::convertToGLformat(scaled, scaled);
            }
        }
        else
        {
            allocateBuffer();
            scaled = src;

            if (src.format == PF_R8G8B8)
            {
                scaled.format = PF_B8G8R8;
                PixelUtil::bulkPixelConversion(src, scaled);
            }
        }

        upload(scaled, dstBox);
        freeBuffer();
    }
bool LKTracker::trackf2f(const GpuMat& gImg1, const GpuMat& gImg2, GpuMat &gPoints1, GpuMat &gPoints2) {
	//计算正反光流
	gFlow->sparse(gImg1, gImg2, gPoints1, gPoints2, gStatus); // compute gPoints2
	gFlow->sparse(gImg2, gImg1, gPoints2, gPointsFB, gFBStatus); //compute gPointsFB

	vector<Point2f> points1, points2;
	download(gPoints1, points1);
	download(gPoints2, points2);

	//Compute the real FB-error
	FB_error.clear();
	for (int i = 0; i < points1.size(); ++i)
	{
		FB_error.push_back(norm(pointsFB[i] - points1[i]));
	}
	//Filter out points with FB_error[i] > mean(FB_error) && points with sim_error[i] > mean(sim_error)
	normCrossCorrelation(gImg1, gImg2, gPoints1, gPoints2, points1, points2);
	bool retVal = filterPts(points1, points2);
	//更新gpu数据
	upload(points1, gPoints1);
	upload(points2, gPoints2);
	return retVal;
}
Beispiel #19
0
eVertexBufferDx9::eVertexBufferDx9(IDirect3DDevice9 *d3dDev, IDirect3DVertexDeclaration9 * const d3dVDecls[], eU32 byteSize, eBool dynamic) :
    m_d3dVb(eNULL),
    m_d3dDev(d3dDev),
    m_d3dVDecls(d3dVDecls),
    m_byteSize(byteSize),
    m_dynamic(dynamic),
    m_locked(eFALSE)
{
    eASSERT(d3dDev != eNULL);
    eASSERT(d3dVDecls != eNULL);
    eASSERT(byteSize > 0);

    upload();
}
int main(int argc, char** argv) {
	xdl::IPXdevLCore core = xdl::createCore();
	core->plug(xdl::XdevLPluginName("XdevLComputeDeviceCL"), xdl::XdevLVersion(0,1,0));

	auto computeDevice = xdl::createModule<xdl::IPXdevLComputeDevice>(core, xdl::XdevLModuleName("XdevLComputeDevice"), xdl::XdevLID("MyComputeDevice"));

	// We need a context.
	auto context = computeDevice->createContext();

	// We need a command queue to run commands.
	auto commandQueue = context->createCommandQueue();


	auto program = context->createProgram();
	auto inBuffer = context->createBuffer(xdl::XDEVL_COMPUTE_BUFFER_READ_ONLY, sizeof(float) * 10);
	auto outBuffer = context->createBuffer(xdl::XDEVL_COMPUTE_BUFFER_WRITE_ONLY, sizeof(float) * 10);

	//
	// Load and build the kernel.
	//
	auto kernel = program->compileFromFile(xdl::XdevLFileName("compute_device_demo.cl"), xdl::XdevLString("calculate_sqrt"));


	for(int a = 0; a < 100; a++) {
		kernel->setArgumentBuffer(0, inBuffer);
		kernel->setArgumentBuffer(1, outBuffer);
		kernel->setArgumentFloat(2, 2);

		inBuffer->upload(commandQueue.get(), sizeof(float) * 10, (xdl::xdl_uint8*)data);

		xdl::XdevLComputeExecuteParameter para(commandQueue.get(), kernel.get(), {32});
		program->execute(para);


//		std::cout << "Before: " << std::endl;
//		for(auto item : data) {
//			std::cout << item << " : ";
//		}
//		std::cout << std::endl;

		outBuffer->download(commandQueue.get(), sizeof(float) * 10, (xdl::xdl_uint8*)data);

		std::cout << "After: " << std::endl;
		for(auto item : data) {
			std::cout << item << " : ";
		}
		std::cout << std::endl;
	}
	xdl::destroyCore(core);
}
Beispiel #21
0
int main(int c,char *argv[])
{
  char *hostname="sinastorage.com";
  char *project="sandbox";
  char *remotepath="/ty/test1.c";
  char *localpath="new1.c";
  char *kid="SYS0000000000SANDBOX";
  char *secretkey="1111111111111111111111111111111111111111";
  int timeout=1800;
  int connecttimeout=2;

  upload(hostname,project,remotepath,localpath,kid,secretkey,timeout,connecttimeout);
  return 0;
}
 void FontTexture::reload()
 {
     if (!id)
     {
         FontData *data;
         FontAtlas *atlas;
         tie(data, atlas) = FontManager::fetchFontDataAndAtlas(inputSource); // CAN THROW
         
         delete data; // WE'RE ONLY INTERESTED IN THE FontAtlas
         
         upload(atlas);
         delete atlas;
     }
 }
Beispiel #23
0
bool nTexture::TextureInternal::makeValid(bool force, uint slot) const {
	if(!handle) {
		handle = new TextureHandle();
		modified = true;
	}
	if(modified) {
		if(force || !data) {
			upload(slot);
		} else {
			uploadASync();
		}
	}
	return handle && !modified;
}
Beispiel #24
0
int FTPsUPLOAD(BYTE * id,BYTE *pw,BYTE *ip,BYTE * file ,BYTE *RemoName)
{
   CURL *curlhandle = NULL;
   BYTE str[128];
  curl_global_init(CURL_GLOBAL_ALL);
  curlhandle = curl_easy_init();
  sprintf(str,"ftp://%s:%s@%s/%s",id,pw,ip,RemoName);
  upload(curlhandle,str, file, 0, 3);

  curl_easy_cleanup(curlhandle);
  curl_global_cleanup();



}
Beispiel #25
0
void Upload::processQueue()
{
    if (m_queue.isEmpty()) {
        return;
    }

    Package const package = m_queue.takeFirst();

    if (upload(package)) {
        QString const message = QString("File %1 (%2) successfully created and uploaded").arg(package.file.fileName()).arg(Region::fileSize(package.file));
        Logger::instance().setStatus(package.region.id(), package.region.name(), "finished", message);
    }
    deleteFile(package.file);
    processQueue();
}
Beispiel #26
0
Texture::Texture(const Texture &other)
{
    // Copy data
    m_width = other.m_width;
    m_height = other.m_height;
    m_pixels = new unsigned char[3 * m_width * m_height];
    m_texIndex = other.m_texIndex;
    for(int i = 0; i < 3 * m_width * m_height; i++)
    {
        m_pixels[i] = other.m_pixels[i];
    }

    // Upload texture
    upload();
}
Beispiel #27
0
static GLuint
create_and_bind_fbo(const struct fmt_test *test, GLuint *tex)
{
	GLuint fbo;
	GLuint fbo_tex = create_and_bind_empty_texture(test);
	upload(test, NULL);

	*tex = fbo_tex;

	glGenFramebuffers(1, &fbo);
	glBindFramebuffer(GL_FRAMEBUFFER, fbo);
	glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
			       GL_TEXTURE_2D, fbo_tex, 0);
	return fbo;
}
Beispiel #28
0
void Camera::change_look_at_pos(int xrel, int y, int width, int height)
{
    if(y==0) {
        y = 1;
    }
    x += xrel;
    float fi = ((float)x)/width*2*M_PI;
    float theta = ((float)y)/height*M_PI;

    look_at_pos.x = -sin(theta)*sin(fi) + position.x;
    look_at_pos.y = cos(theta) + position.y;
    look_at_pos.z = sin(theta)*cos(fi) + position.z;
    *matrix = glm::lookAt(position, look_at_pos, up);
    upload();
}
Beispiel #29
0
void SshKeyController::upload_key(std::map<int, EnvsSelectState> key_with_selected_envs) {
  std::vector<SshKey> tmp = m_keys;
  int total = static_cast<int>(key_with_selected_envs.size());
  int count = 1;

  for (auto state : key_with_selected_envs) {
    SshKey key;
    size_t index = static_cast<size_t>(state.first);

    if (tmp.size() > index)
      key = tmp.at(index);

    QStringList env_ids;

    // get selected environment
    for (auto st : state.second.states) {
      if (st.second && !key.env_ids.contains(st.first))
        env_ids << st.first;
    }

    qDebug() << "SSH UPLOAD ENV ids:"
             << key.file_name
             << env_ids;

    emit progress_ssh_key_rest(count++, total);

    if (!env_ids.empty()) {

      QThread* thread = new QThread;
      Worker* worker = new Worker(key.file_name,
                                  key.content,
                                  env_ids);
      worker->moveToThread(thread);
      connect(thread, SIGNAL (started()), worker, SLOT (upload()));
      connect(worker, &Worker::finished, [env_ids, this]() {
        // clean up m_envs
        this->clean_environment_list(env_ids);
      });
      connect(worker, SIGNAL (finished()), thread, SLOT (quit()));
      connect(worker, SIGNAL (finished()), worker, SLOT (deleteLater()));
      connect(thread, SIGNAL (finished()), thread, SLOT (deleteLater()));
      thread->start();
    }
  }

  emit ssh_key_send_finished();
  check_key_with_envs();
}
Beispiel #30
0
void Camera::rotate(char direction, float angle)
{
    switch (direction) {
    case 'x':
        look_at_pos = glm::rotate(look_at_pos, angle, glm::vec3(1,0,0));
        break;
    case 'y':
        look_at_pos = glm::rotate(look_at_pos, angle, glm::vec3(0,1,0));
        break;
    case 'z':
        look_at_pos = glm::rotate(look_at_pos, angle, glm::vec3(0,0,1));
        break;
    }
    *matrix = glm::lookAt(position, look_at_pos, up);
    upload();
}