void gs_vertex_buffer::BuildBuffers() { InitBuffer(sizeof(vec3), vbd.data->num, vbd.data->points, &vertexBuffer); if (vbd.data->normals) InitBuffer(sizeof(vec3), vbd.data->num, vbd.data->normals, &normalBuffer); if (vbd.data->tangents) InitBuffer(sizeof(vec3), vbd.data->num, vbd.data->tangents, &tangentBuffer); if (vbd.data->colors) InitBuffer(sizeof(uint32_t), vbd.data->num, vbd.data->colors, &colorBuffer); for (size_t i = 0; i < vbd.data->num_tex; i++) { struct gs_tvertarray *tverts = vbd.data->tvarray+i; if (tverts->width != 2 && tverts->width != 4) throw "Invalid texture vertex size specified"; if (!tverts->array) throw "No texture vertices specified"; ComPtr<ID3D11Buffer> buffer; InitBuffer(tverts->width * sizeof(float), vbd.data->num, tverts->array, &buffer); uvBuffers.push_back(buffer); uvSizes.push_back(tverts->width * sizeof(float)); } }
State() : buffVert(InitBuffer()) , buffIndx(InitBuffer()) , buffNorm(InitBuffer()) , buffText(InitBuffer()) , drawMode(UNDEFINED_DRAW_MODE) , textureId(UNDEFINED_TEXTURE_ID) , indxCnt(0) {}
/** * @param pszStrData - data source. * @param nLength - string length. */ void CStrStream::InitData(PCTSTR pszStrData, size_t nLength) { if (pszStrData && *pszStrData) { size_t nSize = nLength + 1; InitBuffer(nSize); _tcsncpy_s(m_pszData, nSize, pszStrData, nLength); m_nLength = nLength; } else InitBuffer(); }
/** * @param pszStrData - data source. */ void CStrStream::InitData(PCSTR pszStrData) { if (pszStrData && *pszStrData) { int nSize = MultiByteToWideChar(CP_ACP, 0, pszStrData, -1, NULL, 0); _ASSERTE(nSize > 0); InitBuffer(nSize); MultiByteToWideChar(CP_ACP, 0, pszStrData, -1, m_pszData, nSize); m_nLength = nSize - 1; } else InitBuffer(); }
/** * @param pszStrData - data source. */ void CStrStream::InitData(PCWSTR pszStrData) { if (pszStrData && *pszStrData) { size_t nSize = WideCharToMultiByte(CP_ACP, 0, pszStrData, -1, NULL, 0, NULL, NULL); _ASSERTE(nSize > 0); InitBuffer(nSize); WideCharToMultiByte(CP_ACP, 0, pszStrData, -1, m_pszData, (int)nSize, NULL, NULL); m_nLength = nSize - 1; } else InitBuffer(); }
/* Init most of all firms of client */ void InitUser (struct client * user, struct clientlist *clList, int fd) { //user->number = clList->cnt; It's not need.fn better GetUserId() user->next = NULL; user->contact = (struct settings*)malloc(sizeof(struct settings)); InitSettings (user->contact, fd, clList->cnt); user->f = (struct userFlags *) malloc (sizeof(struct userFlags)); InitFlags (user->f); user->sell = (struct auction *) malloc (sizeof(struct auction)); InitBuyOrSell (user->sell); user->buy = (struct auction *) malloc (sizeof(struct auction)); InitBuyOrSell (user->buy); user->data = (struct stuff *) malloc (sizeof(struct stuff)); InitStuff (user->data); user->buf = (struct buffer * ) malloc (sizeof(struct buffer)); InitBuffer (user->buf); user->cmd = (struct command * ) malloc (sizeof(struct command)); InitCommand (user->cmd); }
void TestApp::InitScene() { for (int i=0; i<_sceneData->getObjects().size(); i++) { SceneObject* obj = _sceneData->getObjects()[i]; switch (obj->getType()) { case SceneObjType::mesh: { ObjModelObject* mesh = (ObjModelObject*)obj; //GLMmodel* model = glmReadOBJ(mesh->getObjFileName().c_str()); IGLUOBJReader::Ptr objReader = new IGLUOBJReader( (char*)mesh->getObjFileName().c_str()); //IGLUOBJReader::Ptr objReader = new IGLUOBJReader( model,IGLU_OBJ_COMPACT_STORAGE); _objReaders.push_back(objReader); glm::mat4 trans = (mesh->getTransform()); _objTransforms.push_back(IGLUMatrix4x4(&trans[0][0])); break; } default: break; } } // We've loaded all our materials, so prepare to use them in rendering IGLUOBJMaterialReader::FinalizeMaterialsForRendering(IGLU_TEXTURE_REPEAT); InitBuffer(); }
/** * \param offset offset relative to StreamingBuffer::stream_offset */ int StreamingBufferInsertAt(StreamingBuffer *sb, StreamingBufferSegment *seg, const uint8_t *data, uint32_t data_len, uint64_t offset) { BUG_ON(seg == NULL); if (offset < sb->stream_offset) return -1; if (sb->buf == NULL) { if (InitBuffer(sb) == -1) return -1; } uint32_t rel_offset = offset - sb->stream_offset; if (!DATA_FITS_AT_OFFSET(sb, data_len, rel_offset)) { if (sb->cfg->flags & STREAMING_BUFFER_AUTOSLIDE) { AutoSlide(sb); rel_offset = offset - sb->stream_offset; } if (!DATA_FITS_AT_OFFSET(sb, data_len, rel_offset)) { if (GrowToSize(sb, (rel_offset + data_len)) != 0) return -1; } } BUG_ON(!DATA_FITS_AT_OFFSET(sb, data_len, rel_offset)); memcpy(sb->buf + rel_offset, data, data_len); seg->stream_offset = offset; seg->segment_len = data_len; if (rel_offset + data_len > sb->buf_offset) sb->buf_offset = rel_offset + data_len; return 0; }
/** * \brief add data w/o tracking a segment */ int StreamingBufferAppendNoTrack(StreamingBuffer *sb, const uint8_t *data, uint32_t data_len) { if (sb->buf == NULL) { if (InitBuffer(sb) == -1) return -1; } if (!DATA_FITS(sb, data_len)) { if (sb->cfg->flags & STREAMING_BUFFER_AUTOSLIDE) AutoSlide(sb); if (sb->buf_size == 0) { if (GrowToSize(sb, data_len) != 0) return -1; } else { while (!DATA_FITS(sb, data_len)) { if (Grow(sb) != 0) { return -1; } } } } if (!DATA_FITS(sb, data_len)) { return -1; } memcpy(sb->buf + sb->buf_offset, data, data_len); sb->buf_offset += data_len; return 0; }
StreamingBufferSegment *StreamingBufferAppendRaw(StreamingBuffer *sb, const uint8_t *data, uint32_t data_len) { if (sb->buf == NULL) { if (InitBuffer(sb) == -1) return NULL; } if (!DATA_FITS(sb, data_len)) { if (sb->cfg->flags & STREAMING_BUFFER_AUTOSLIDE) AutoSlide(sb); if (sb->buf_size == 0) { if (GrowToSize(sb, data_len) != 0) return NULL; } else { while (!DATA_FITS(sb, data_len)) { if (Grow(sb) != 0) { return NULL; } } } } if (!DATA_FITS(sb, data_len)) { return NULL; } StreamingBufferSegment *seg = CALLOC(sb->cfg, 1, sizeof(StreamingBufferSegment)); if (seg != NULL) { memcpy(sb->buf + sb->buf_offset, data, data_len); seg->stream_offset = sb->stream_offset + sb->buf_offset; seg->segment_len = data_len; sb->buf_offset += data_len; return seg; } return NULL; }
FastWHT<CPU, Dtype>::FastWHT(unsigned int _degree) : degree(_degree) { buf_len = 1 << _degree; wht_tree = wht_get_tree(_degree); InitBuffer(); }
MemoryTextureData* MemoryTextureData::Create(gfx::IntSize aSize, gfx::SurfaceFormat aFormat, gfx::BackendType aMoz2DBackend, LayersBackend aLayersBackend, TextureFlags aFlags, TextureAllocationFlags aAllocFlags, LayersIPCChannel* aAllocator) { // Should have used CreateForYCbCr. MOZ_ASSERT(aFormat != gfx::SurfaceFormat::YUV); if (aSize.width <= 0 || aSize.height <= 0) { gfxDebug() << "Asking for buffer of invalid size " << aSize.width << "x" << aSize.height; return nullptr; } uint32_t bufSize = ImageDataSerializer::ComputeRGBBufferSize(aSize, aFormat); if (!bufSize) { return nullptr; } uint8_t* buf = new (fallible) uint8_t[bufSize]; if (!InitBuffer(buf, bufSize, aFormat, aAllocFlags, false)) { return nullptr; } bool hasIntermediateBuffer = ComputeHasIntermediateBuffer(aFormat, aLayersBackend); GfxMemoryImageReporter::DidAlloc(buf); BufferDescriptor descriptor = RGBDescriptor(aSize, aFormat, hasIntermediateBuffer); return new MemoryTextureData(descriptor, aMoz2DBackend, buf, bufSize); }
//-----FileBatch---------------------------------------------------------------- CPFile_Info::CPFile_Info(const char *_szFileName) { m_bValid = true; m_nError = 0; char *pcNoPath = NULL; struct stat buf; // Remove any path from the filename if ( (pcNoPath = strrchr(_szFileName, '/')) != NULL) m_szFileName = strdup(pcNoPath + 1); else m_szFileName = strdup(_szFileName); if (stat(_szFileName, &buf) < 0) { m_bValid = false; m_nError = errno; return; } m_nFileSize = buf.st_size; m_nSize = strlen(m_szFileName) + 21; InitBuffer(); buffer->PackUnsignedShort(0x02); // Add all the file names buffer->PackString(m_szFileName); // Add the empty file name buffer->PackString(""); //Add the file length buffer->PackUnsignedLong(m_nFileSize); buffer->PackUnsignedLong(0x00); buffer->PackUnsignedLong(0x64); }
/* static */ wxIDirectFBEventBufferPtr wxGUIEventLoop::GetDirectFBEventBuffer() { if ( !ms_buffer ) InitBuffer(); return ms_buffer; }
MemoryTextureData* MemoryTextureData::Create(gfx::IntSize aSize, gfx::SurfaceFormat aFormat, gfx::BackendType aMoz2DBackend, TextureFlags aFlags, TextureAllocationFlags aAllocFlags, ClientIPCAllocator* aAllocator) { // Should have used CreateForYCbCr. MOZ_ASSERT(aFormat != gfx::SurfaceFormat::YUV); if (aSize.width <= 0 || aSize.height <= 0) { gfxDebug() << "Asking for buffer of invalid size " << aSize.width << "x" << aSize.height; return nullptr; } uint32_t bufSize = ImageDataSerializer::ComputeRGBBufferSize(aSize, aFormat); if (!bufSize) { return nullptr; } uint8_t* buf = new (fallible) uint8_t[bufSize]; if (!InitBuffer(buf, bufSize, aFormat, aAllocFlags)) { return nullptr; } auto fwd = aAllocator ? aAllocator->AsCompositableForwarder() : nullptr; bool hasIntermediateBuffer = fwd ? ComputeHasIntermediateBuffer(aFormat, fwd->GetCompositorBackendType()) : true; GfxMemoryImageReporter::DidAlloc(buf); BufferDescriptor descriptor = RGBDescriptor(aSize, aFormat, hasIntermediateBuffer); return new MemoryTextureData(descriptor, aMoz2DBackend, buf, bufSize); }
gs_vertex_buffer::gs_vertex_buffer(gs_device_t device, struct gs_vb_data *data, uint32_t flags) : device (device), vbd (data), numVerts (data->num), dynamic ((flags & GS_DYNAMIC) != 0) { if (!data->num) throw "Cannot initialize vertex buffer with 0 vertices"; if (!data->points) throw "No points specified for vertex buffer"; InitBuffer(sizeof(vec3), data->num, data->points, vertexBuffer.Assign()); if (data->normals) InitBuffer(sizeof(vec3), data->num, data->normals, normalBuffer.Assign()); if (data->tangents) InitBuffer(sizeof(vec3), data->num, data->tangents, tangentBuffer.Assign()); if (data->colors) InitBuffer(sizeof(uint32_t), data->num, data->colors, colorBuffer.Assign()); for (size_t i = 0; i < data->num_tex; i++) { struct gs_tvertarray *tverts = data->tvarray+i; if (tverts->width != 2 && tverts->width != 4) throw "Invalid texture vertex size specified"; if (!tverts->array) throw "No texture vertices specified"; ComPtr<ID3D11Buffer> buffer; InitBuffer(tverts->width * sizeof(float), data->num, tverts->array, buffer.Assign()); uvBuffers.push_back(buffer); uvSizes.push_back(tverts->width * sizeof(float)); } if (!dynamic) vbd.Clear(); }
//-----FileSpeed---------------------------------------------------------------- CPFile_SetSpeed::CPFile_SetSpeed(unsigned long nSpeed) { m_nSize = 5; InitBuffer(); buffer->PackChar(0x05); buffer->PackUnsignedLong(nSpeed); }
void CStrStream::Free(void) { if (m_pszData) { delete[] m_pszData; InitBuffer(); } }
explicit BufferReader(ReaderT const & reader, uint64_t offset = 0) { uint64_t const rSize = reader.Size(); ASSERT_LESS_OR_EQUAL(offset, rSize, (offset, rSize)); InitBuffer(static_cast<size_t>(rSize - offset)); reader.Read(offset, m_data.get(), m_size); }
//-----FileInitServer----------------------------------------------------------- CPFile_InitServer::CPFile_InitServer(char *_szLocalName) { m_nSize = 8 + strlen(_szLocalName); InitBuffer(); buffer->PackChar(0x01); buffer->PackUnsignedLong(0x64); buffer->PackString(_szLocalName); }
wxGUIEventLoop::wxGUIEventLoop() { // Note that this has to be done here so that the buffer is ready when // an event loop runs; GetDirectFBEventBuffer(), which also calls // InitBuffer(), may be called before or after the first wxGUIEventLoop // instance is created. if ( !ms_buffer ) InitBuffer(); }
/** * @param nBufferSize - buffer size. */ void CFileStream::SetBufferSize(int nBufferSize) { if (m_nBufferSize != nBufferSize) { if (! FlushBuffer()) return; delete[] m_pBuffer; InitBuffer(nBufferSize); } }
void AccordionPanel::SizeMove(const GG::Pt& ul, const GG::Pt& lr) { GG::Pt old_size = GG::Wnd::Size(); GG::Wnd::SizeMove(ul, lr); if (old_size != GG::Wnd::Size()) { DoLayout(); InitBuffer(); } }
void WriteBytes(WriteBuffer* buf, const char* s, int l) { if (!buf->buffer) InitBuffer(buf); GrowBuffer(buf, l); memcpy(buf->buffer+buf->len, s, l); buf->len += l; }
void WriteByte(WriteBuffer* buf, int v) { if (!buf->buffer) InitBuffer(buf); GrowBuffer(buf, 1); *(buf->buffer + buf->len) = v; buf->len++; }
void CopyBytes(WriteBuffer* buf, int pos, int nb, char* out) { if (!buf->buffer) InitBuffer(buf); assert(pos<=buf->len); assert(pos+nb<=buf->len); memcpy(buf->buffer+pos, out, nb); }
//-----FileStart---------------------------------------------------------------- CPFile_Start::CPFile_Start(unsigned long nFilePos, unsigned long nFile) { m_nSize = 17; InitBuffer(); buffer->PackChar(0x03); buffer->PackUnsignedLong(nFilePos); buffer->PackUnsignedLong(0x00); buffer->PackUnsignedLong(0x64); buffer->PackUnsignedLong(nFile); }
void SendPacketToGdb(void) { if (Buffer_OverrunDetected(&g_mri.buffer)) { InitBuffer(); Buffer_WriteString(&g_mri.buffer, MRI_ERROR_BUFFER_OVERRUN); } Buffer_SetEndOfBuffer(&g_mri.buffer); Packet_SendToGDB(&g_mri.packet, &g_mri.buffer); }
int InitDram(struct ftlInfo *ftl){ ftl->dram = (struct dramInfo *)malloc(sizeof(struct dramInfo)); AllocAssert(ftl->dram,"ftl->dram"); memset(ftl->dram,0,sizeof(struct dramInfo)); ftl->dram->dram_capacity = ftl->parameter->dram_capacity; InitBuffer(ftl->dram,ftl); InitMap(ftl->dram,ftl); return XST_SUCCESS; }
void DeleteBytes(WriteBuffer* buf, int pos, int nb) { if (!buf->buffer) InitBuffer(buf); int end = pos+nb; assert(pos<=buf->len); assert(end<=buf->len); memcpy(buf->buffer+pos, buf->buffer+end, buf->len-end); buf->len -= nb; }