static TACommandVerdict posix_memalign_cmd(TAThread thread,TAInputStream stream) { void *memptr; size_t alignment; size_t size; int res; // Prepare alignment = readSize(&stream); size = readSize(&stream); START_TARGET_OPERATION(thread); // Execute res = posix_memalign(&memptr, alignment, size); END_TARGET_OPERATION(thread); // Response if (res) { memptr = NULL; } writePointer(thread, memptr); writeInt(thread, res); sendResponse(thread); return taDefaultVerdict; }
static TACommandVerdict calloc_cmd(TAThread thread,TAInputStream stream) { size_t nelem; size_t elsize; void* res; // Prepare nelem = readSize(&stream); elsize = readSize(&stream); START_TARGET_OPERATION(thread); // Execute errno = 0; res = calloc(nelem, elsize); END_TARGET_OPERATION(thread); // Response writePointer(thread, res); writeInt(thread, errno); sendResponse(thread); return taDefaultVerdict; }
void free(int bytes) { totalSize -= bytes; Q_ASSERT(totalSize >= 0); forever { int nbs = readSize(); if (bytes < nbs) { head += bytes; if (head == tail && buffers.count() == 1) { buffers.first().resize(CHUNKSIZE); head = tail = 0; } break; } bytes -= nbs; if (buffers.count() == 1) { buffers.first().resize(CHUNKSIZE); head = tail = 0; break; } buffers.removeFirst(); head = 0; } }
static TACommandVerdict read_fifo_cmd(TAThread thread,TAInputStream stream) { int fildes; void* buf; size_t nbyte; ssize_t res; // Prepare fildes = readInt(&stream); buf = readPointer(&stream); nbyte = readSize(&stream); BEFORE_BLOCKED_TARGET_OPERATION(thread); writeString(thread,"Ok"); sendResponse(thread); errno = 0; START_TARGET_OPERATION(thread); res = read(fildes, buf, nbyte); END_TARGET_OPERATION(thread); writeDeferredReaction(thread, "read_fifo_return"); // Response writeSSize(thread, res); writeInt(thread, errno); sendResponse(thread); return taDefaultVerdict; }
static TACommandVerdict wcsncasecmp_cmd(TAThread thread,TAInputStream stream) { int res; wchar_t *s1; wchar_t *s2; size_t n; // Prepare s1 = ta_wcsalign(readWString(&stream)); //align on copy s2 = ta_wcsalign(readWString(&stream)); //align on copy n = readSize(&stream); START_TARGET_OPERATION(thread); res = wcsncasecmp(s1, s2, n); END_TARGET_OPERATION(thread); // Response writeInt(thread,res); sendResponse(thread); ta_dealloc_memory(s1); ta_dealloc_memory(s2); return taDefaultVerdict; }
static TACommandVerdict confstr_cmd(TAThread thread,TAInputStream stream) { int name; size_t res; char * buf; size_t len; /* Prepare */ name = readInt(&stream); buf = (char*)readPointer(&stream); len = readSize(&stream); /* [ Set errno ] */ errno = readInt(&stream); START_TARGET_OPERATION(thread); /* Execute */ res = confstr(name,buf,len); END_TARGET_OPERATION(thread); /* Response */ writeSize(thread, res); writeInt(thread, errno); sendResponse(thread); return taDefaultVerdict; }
static TACommandVerdict wcsncpy_cmd(TAThread thread, TAInputStream stream) { wchar_t* ws1; wchar_t* ws2; size_t n; wchar_t* res; // Prepare ws1 = (wchar_t*)readPointer(&stream); ws2 = (wchar_t*)readPointer(&stream); n = readSize(&stream); START_TARGET_OPERATION(thread); // Execute res = wcsncpy(ws1, ws2, n); END_TARGET_OPERATION(thread); // Response writePointer(thread, res); sendResponse(thread); return taDefaultVerdict; }
bool BasicStream::readDoubleSeq(std::vector<double>& v) { ULong sz; readSize(sz); if (sz > 0) { //checkFixedSeq(sz, static_cast<int> (sizeof(double))); Container::iterator begin = i; i += sz * static_cast<int> (sizeof(double)); v.resize(sz); #ifdef ACE_BIG_ENDIAN const Byte* src = &(*begin); Byte* dest = reinterpret_cast<Byte*>(&v[0]) + sizeof(double) - 1; for(int j = 0; j < sz; ++j) { *dest-- = *src++; *dest-- = *src++; *dest-- = *src++; *dest-- = *src++; *dest-- = *src++; *dest-- = *src++; *dest-- = *src++; *dest-- = *src++; dest += 2 * sizeof(double); } #else std::copy(begin, i, reinterpret_cast<Byte*> (&v[0])); #endif } else { v.clear(); } return true; }
static TACommandVerdict strncpy_cmd(TAThread thread, TAInputStream stream) { char* s1; char* s2; size_t n; char* res; // Prepare s1 = (char*)readPointer(&stream); s2 = (char*)readPointer(&stream); n = readSize(&stream); START_TARGET_OPERATION(thread); // Execute res = strncpy(s1, s2, n); END_TARGET_OPERATION(thread); // Response writePointer(thread, res); sendResponse(thread); return taDefaultVerdict; }
static TACommandVerdict strndup_cmd(TAThread thread, TAInputStream stream) { char* s; size_t n; char* res; // Prepare s = (char*)readPointer(&stream); n = readSize(&stream); START_TARGET_OPERATION(thread); // Execute errno = 0; res = strndup(s,n); END_TARGET_OPERATION(thread); // Execute // Response writePointer(thread, res); writeInt(thread, errno); sendResponse(thread); return taDefaultVerdict; }
static TACommandVerdict wcpncpy_cmd(TAThread thread,TAInputStream stream) { wchar_t* dest; wchar_t* src; size_t n; wchar_t* res; // Prepare dest = (wchar_t*)readPointer(&stream); src = (wchar_t*)readPointer(&stream); n = readSize(&stream); START_TARGET_OPERATION(thread); // Execute res = wcpncpy(dest, src, n); END_TARGET_OPERATION(thread); // Response writePointer(thread, res); sendResponse(thread); return taDefaultVerdict; }
offset_t CThorContiguousRowBuffer::beginNested() { size32_t len = readSize(); //Currently nested datasets are readahead by skipping the number of bytes in the datasets, rather than calling //beginNested(). If this function was ever called from readAhead() then it would need to call noteStartChild() //so that the self pointer is correct for the child rows return len+readOffset; }
//------------------------------------------------------------------------ bool PresetFile::readChunkList () { seekTo (0); entryCount = 0; char8 classString[kClassIDSize + 1] = {0}; // Read header int32 version = 0; TSize listOffset = 0; if (!(readEqualID (getChunkID (kHeader)) && readInt32 (version) && verify (stream->read (classString, kClassIDSize)) && readSize (listOffset) && listOffset > 0 && seekTo (listOffset))) return false; classID.fromString (classString); // Read list int32 count = 0; if (!readEqualID (getChunkID (kChunkList))) return false; if (!readInt32 (count)) return false; if (count > kMaxEntries) count = kMaxEntries; for (int32 i = 0; i < count; i++) { Entry& e = entries[i]; if (!(readID (e.id) && readSize (e.offset) && readSize (e.size))) break; entryCount++; } return entryCount > 0; }
int read(char *data, int maxLength) { int bytesToRead = qMin(size(), maxLength); int readSoFar = 0; while (readSoFar < bytesToRead) { const char *ptr = readPointer(); int bs = qMin(bytesToRead - readSoFar, readSize()); memcpy(data + readSoFar, ptr, bs); readSoFar += bs; free(bs); } return readSoFar; }
bool BasicStream::readByteSeq(std::vector<Byte>& v) { ULong sz; readSize(sz); if(sz > 0) { //vector<Byte> (i, i + sz).swap(v); i += sz; } else { v.clear(); } return true; }
static TACommandVerdict wcsxfrm_cmd(TAThread thread, TAInputStream stream) { wchar_t* ws1; wchar_t* ws2; wchar_t* xxx = L""; size_t n; size_t res; int save_errno; int overflow = 0; int i; // Prepare ws2 = ta_wcsalign(readWString(&stream)); //align on copy n = readSize(&stream); ws1 = ta_alloc_memory((n + BUFFER_TAIL) * sizeof(wchar_t)); for (i=0; i<BUFFER_TAIL; ++i) ws1[n + i] = (wchar_t)0xDDDDDDDD; START_TARGET_OPERATION(thread); // Execute errno = 0; res = wcsxfrm(ws1, ws2, n); save_errno = errno; END_TARGET_OPERATION(thread); for (i=0; i<BUFFER_TAIL; ++i) overflow |= (ws1[n + i] != (wchar_t)0xDDDDDDDD); if (overflow) { sendException(thread, "wcsxfrm.02 failed: writing outside of buffer limits occured!"); return taDefaultVerdict; } // Response if (res >= n) writeWString(thread, xxx); else writeWString(thread, ws1); writeSize(thread, res); writeInt(thread, save_errno); sendResponse(thread); ta_dealloc_memory(ws1); ta_dealloc_memory(ws2); return taDefaultVerdict; }
static TACommandVerdict iconv_cmd(TAThread thread, TAInputStream stream) { iconv_t cd; char* inbuf; char* outbuf; size_t inbytesleft; size_t outbytesleft; size_t res; int save_errno; // Prepare cd = (iconv_t)readPointer(&stream); inbuf = (char*)readPointer(&stream); inbytesleft = readSize(&stream); outbuf = (char*)readPointer(&stream); outbytesleft = readSize(&stream); errno = 0; START_TARGET_OPERATION(thread); // Execute res = iconv(cd, &inbuf, &inbytesleft, &outbuf, &outbytesleft); save_errno = errno; END_TARGET_OPERATION(thread); // Response writeSize(thread, res); writePointer(thread, inbuf); writeSize(thread, inbytesleft); writePointer(thread, outbuf); writeSize(thread, outbytesleft); writeInt(thread, save_errno); sendResponse(thread); return taDefaultVerdict; }
bool BasicStream::readBoolSeq(std::vector<bool> &v) { ULong sz; readSize(sz); if(sz > 0) { v.resize(sz); copy(i, i + sz, v.begin()); i += sz; } else { v.clear(); } return true; }
static TACommandVerdict getgrgid_r_cmd(TAThread thread,TAInputStream stream) { int res; gid_t gid; struct group *grp; char *buffer; size_t bufsize; struct group *result; int i=0; gid = readInt(&stream); grp = (struct group *)readPointer(&stream); bufsize = readSize(&stream); buffer=(char *) ta_alloc_memory(bufsize*sizeof(char)); errno = 0; START_TARGET_OPERATION_WHICH_MAY_CONTAIN_CANCELPOINT(thread); res = getgrgid_r(gid, grp, buffer, bufsize, &result); END_TARGET_OPERATION_WHICH_MAY_CONTAIN_CANCELPOINT(thread); writeInt(thread, res); writeInt(thread,errno); writePointer(thread,(void*)result); if(result) { writeString(thread, result->gr_name); writeInt(thread, result->gr_gid); while ((result->gr_mem)[i]!=NULL) { i++; } writeInt(thread, i); i=0; while ((result->gr_mem)[i]!=NULL) { writeString(thread, (result->gr_mem)[i]); i++; } } sendResponse(thread); ta_dealloc_memory(buffer); return taDefaultVerdict; }
static TACommandVerdict writev_fifo_cmd(TAThread thread,TAInputStream stream) { int fildes; int size; int i=0; void* curPointer; size_t curSize; struct iovec *iov; ssize_t res; // Prepare fildes = readInt(&stream); size = readInt(&stream); iov=(struct iovec *)ta_alloc_memory(size*sizeof(struct iovec)); for (i=0;i<size;i++) { curPointer=readPointer(&stream); curSize=readSize(&stream); iov[i].iov_base=curPointer; iov[i].iov_len=curSize; } BEFORE_BLOCKED_TARGET_OPERATION(thread); writeString(thread,"Ok"); sendResponse(thread); errno = 0; START_TARGET_OPERATION(thread); res = writev(fildes, iov, size); END_TARGET_OPERATION(thread); writeDeferredReaction(thread, "writev_fifo_return"); // Response writeSSize(thread,res); writeInt(thread,errno); sendResponse(thread); ta_dealloc_memory(iov); return taDefaultVerdict; }
long long int StreamWAVSoundBuffer::filler(ALBuffer& buf, size_t size, bool repeat) { std::streamsize readSize(0); /* Try to read 'size' bytes into temp. array */ if (file->eof()) { if (repeat) { file->seekg(dataStart); ASSERT(file->good() && !file->eof()); } else { return 0ll; } } file->read(pcmData, size); /* EOF? */ readSize = file->gcount(); if (readSize >= 0 && readSize < size && repeat) { /* Must repeat: continue loading from the beginning. */ file->seekg(dataStart); ASSERT(file->good() && !file->eof()); file->read(&pcmData[readSize], size-readSize); if (readSize + file->gcount() < size) { debug("Couldn't extract %zu bytes from file.\n", size); } if (file->gcount() < 0) { debugERROR("Problems reading data from file.%s", "\n"); return -1ll; } else { readSize += file->gcount(); } } else if (readSize < 0) { debugERROR("Problems reading data from file.%s", "\n"); return -1ll; } alBufferData(buf, format, pcmData, readSize, freq); if (alGetError() != AL_NO_ERROR) { return -1ll; } return ((long long int)readSize); }
bool BasicStream::readString(std::string& v) { ULong sz; readSize(sz); if (sz > 0) { if (b.end() - i < (int)sz) { //throw UnmarshalOutOfBoundsException(__FILE__, __LINE__); return false; } //string(reinterpret_cast<const char*> (&*i), reinterpret_cast<const char*> (&*i) + sz).swap(v); // v.assign(reinterpret_cast<const char*>(&(*i)), sz); i += sz; } else { v.clear(); } return true; }
bool BasicStream::readStringSeq(std::vector<std::string>& v) { ULong sz; readSize(sz); if (sz > 0) { //startSeq(sz, 1); v.resize(sz); for (ULong i = 0; i < sz; ++i) { readString(v[i]); //checkSeq(); //endElement(); } //endSeq(sz); } else { v.clear(); } return true; }
int main() { int *vector, size; readSize(&size); vector = (int *)malloc(size*sizeof(int)); if(vector==NULL){ exit(1); } readVector(vector, size); bubble_sort(vector, size); showVector(vector, size); free(vector); return 0; }
static TACommandVerdict wmemchr_cmd(TAThread thread,TAInputStream stream) { wchar_t* s; wchar_t c; size_t n; wchar_t* res; // Prepare s = readPointer(&stream); c = readWChar(&stream); n = readSize(&stream); // Execute START_TARGET_OPERATION(thread); res = wmemchr( s, c, n ); END_TARGET_OPERATION(thread); // Response writePointer(thread,res); sendResponse(thread); return taDefaultVerdict; }
void CopyableCanvasLayer::UpdateSurface(gfxASurface* aDestSurface, Layer* aMaskLayer) { if (!IsDirty()) return; Painted(); if (mDrawTarget) { mDrawTarget->Flush(); if (mDrawTarget->GetType() == BACKEND_COREGRAPHICS_ACCELERATED) { // We have an accelerated CG context which has changed, unlike a bitmap surface // where we can alias the bits on initializing the mDrawTarget, we need to readback // and copy the accelerated surface each frame. We want to support this for quick // thumbnail but if we're going to be doing this every frame it likely is better // to use a non accelerated (bitmap) canvas. mSurface = gfxPlatform::GetPlatform()->GetThebesSurfaceForDrawTarget(mDrawTarget); } } if (!mGLContext && aDestSurface) { nsRefPtr<gfxContext> tmpCtx = new gfxContext(aDestSurface); tmpCtx->SetOperator(gfxContext::OPERATOR_SOURCE); CopyableCanvasLayer::PaintWithOpacity(tmpCtx, 1.0f, aMaskLayer); return; } if (mGLContext) { if (aDestSurface && aDestSurface->GetType() != gfxASurface::SurfaceTypeImage) { MOZ_ASSERT(false, "Destination surface must be ImageSurface type."); return; } nsRefPtr<gfxImageSurface> readSurf; nsRefPtr<gfxImageSurface> resultSurf; SharedSurface* sharedSurf = mGLContext->RequestFrame(); if (!sharedSurf) { NS_WARNING("Null frame received."); return; } gfxIntSize readSize(sharedSurf->Size()); gfxImageFormat format = (GetContentFlags() & CONTENT_OPAQUE) ? gfxASurface::ImageFormatRGB24 : gfxASurface::ImageFormatARGB32; if (aDestSurface) { resultSurf = static_cast<gfxImageSurface*>(aDestSurface); } else { resultSurf = GetTempSurface(readSize, format); } MOZ_ASSERT(resultSurf); if (resultSurf->CairoStatus() != 0) { MOZ_ASSERT(false, "Bad resultSurf->CairoStatus()."); return; } MOZ_ASSERT(sharedSurf->APIType() == APITypeT::OpenGL); SharedSurface_GL* surfGL = SharedSurface_GL::Cast(sharedSurf); if (surfGL->Type() == SharedSurfaceType::Basic) { SharedSurface_Basic* sharedSurf_Basic = SharedSurface_Basic::Cast(surfGL); readSurf = sharedSurf_Basic->GetData(); } else { if (resultSurf->Format() == format && resultSurf->GetSize() == readSize) { readSurf = resultSurf; } else { readSurf = GetTempSurface(readSize, format); } // Readback handles Flush/MarkDirty. mGLContext->Screen()->Readback(surfGL, readSurf); } MOZ_ASSERT(readSurf); bool needsPremult = surfGL->HasAlpha() && !mIsGLAlphaPremult; if (needsPremult) { gfxImageSurface* sizedReadSurf = nullptr; if (readSurf->Format() == resultSurf->Format() && readSurf->GetSize() == resultSurf->GetSize()) { sizedReadSurf = readSurf; } else { readSurf->Flush(); nsRefPtr<gfxContext> ctx = new gfxContext(resultSurf); ctx->SetOperator(gfxContext::OPERATOR_SOURCE); ctx->SetSource(readSurf); ctx->Paint(); sizedReadSurf = resultSurf; } MOZ_ASSERT(sizedReadSurf); readSurf->Flush(); resultSurf->Flush(); gfxUtils::PremultiplyImageSurface(readSurf, resultSurf); resultSurf->MarkDirty(); } else if (resultSurf != readSurf) { // Didn't need premult, but we do need to blit to resultSurf readSurf->Flush(); nsRefPtr<gfxContext> ctx = new gfxContext(resultSurf); ctx->SetOperator(gfxContext::OPERATOR_SOURCE); ctx->SetSource(readSurf); ctx->Paint(); } // stick our surface into mSurface, so that the Paint() path is the same if (!aDestSurface) { mSurface = resultSurf; } } }
void RPIImageDecoder::decode(bool onlySize) { unsigned int width, height; if (failed()) return; // make sure we have all the data before doing anything if (!isAllDataReceived()) return; if (onlySize) { if (readSize(width, height)); { setSize(width, height); } return; } else { readSize(width, height); clock_t start = clock(); ImageFrame& buffer = m_frameBufferCache[0]; if (m_frameBufferCache.isEmpty()) { log("decode : frameBuffercache is empty"); setFailed(); return; } if (buffer.status() == ImageFrame::FrameEmpty) { if (!buffer.setSize(width, height)) { log("decode : could not define buffer size"); setFailed(); return; } // The buffer is transparent outside the decoded area while the image is // loading. The completed image will be marked fully opaque in jpegComplete(). buffer.setHasAlpha(false); } // lock the mutex so that we only process once at a time pthread_mutex_lock(&decode_mutex); // setup decoder request information BRCMIMAGE_REQUEST_T* dec_request = getDecoderRequest(); BRCMIMAGE_T *decoder = getDecoder(); memset(dec_request, 0, sizeof(BRCMIMAGE_REQUEST_T)); dec_request->input = (unsigned char*)m_data->data(); dec_request->input_size = m_data->size(); dec_request->output = (unsigned char*)buffer.getAddr(0, 0); dec_request->output_alloc_size = width * height * 4; dec_request->output_handle = 0; dec_request->pixel_format = PIXEL_FORMAT_RGBA; dec_request->buffer_width = 0; dec_request->buffer_height = 0; brcmimage_acquire(decoder); BRCMIMAGE_STATUS_T status = brcmimage_process(decoder, dec_request); if (status == BRCMIMAGE_SUCCESS) { clock_t copy = clock(); unsigned char *ptr = (unsigned char *)buffer.getAddr(0, 0); for (unsigned int i = 0; i < dec_request->height * dec_request->width; i++) { // we swap RGBA -> BGRA unsigned char tmp = *ptr; *ptr = ptr[2]; ptr[2] = tmp; ptr += 4; } brcmimage_release(decoder); buffer.setPixelsChanged(true); buffer.setStatus(ImageFrame::FrameComplete); buffer.setHasAlpha(m_hasAlpha); clock_t end = clock(); unsigned long millis = (end - start) * 1000 / CLOCKS_PER_SEC; unsigned long copymillis = (end - copy) * 1000 / CLOCKS_PER_SEC; log("decode : image (%d x %d)(Alpha=%d) decoded in %d ms (copy in %d ms), source size = %d bytes", width, height, m_hasAlpha, millis, copymillis, m_data->size()); } else { log("decode : Decoding failed with status %d", status); } pthread_mutex_unlock(&decode_mutex); } }
int asn_sequence::readAll(std::istream& istr){ if(!checkTag(istr)) return -1; if(!readSize(istr)) return -1; int readOctets = 2; int charleft = size; if(elements.empty()){ while (charleft > 0){ int tmptag = read(istr), x; if (tmptag < 0) { istr.clear(); istr.seekg(0); writeable = 0; return -1; } istr.unget(); istr.unget(); if(tmptag==2){ asn_int *tmpi = new asn_int; x = tmpi->readAll(istr); if(x <0) return -1; charleft = charleft-x; readOctets += x; addElement(tmpi); } else if(tmptag==19){ asn_string *tmps = new asn_string; x = tmps->readAll(istr); if(x <0) return -1; charleft = charleft-x; readOctets += x; addElement(tmps); } else if(tmptag==48){ asn_sequence *tmpss = new asn_sequence; x = tmpss->readAll(istr); if(x <0) return -1; charleft =charleft-x; readOctets += x; addElement(tmpss); } else{ istr.clear(); istr.seekg(0); writeable = 0; return -1; } } writeable = 1; return readOctets; } else{ for (std::vector<asn_object*>::iterator it = elements.begin() ; it != elements.end(); ++it){ int x = (*it)->readAll(istr); if (x<0){ istr.clear(); istr.seekg(0); /* for(int i = 0; i<readOctets; i++){ istr.unget(); istr.unget(); }*/ return -1; } readOctets += x; } writeable = 1; return readOctets; } }
bool ShareableCanvasRenderer::UpdateTarget(DrawTarget* aDestTarget) { MOZ_ASSERT(aDestTarget); if (!aDestTarget) { return false; } RefPtr<SourceSurface> surface; if (!mGLContext) { AutoReturnSnapshot autoReturn; if (mAsyncRenderer) { surface = mAsyncRenderer->GetSurface(); } else if (mBufferProvider) { surface = mBufferProvider->BorrowSnapshot(); autoReturn.mSnapshot = &surface; autoReturn.mBufferProvider = mBufferProvider; } MOZ_ASSERT(surface); if (!surface) { return false; } aDestTarget->CopySurface(surface, IntRect(0, 0, mSize.width, mSize.height), IntPoint(0, 0)); return true; } gl::SharedSurface* frontbuffer = nullptr; if (mGLFrontbuffer) { frontbuffer = mGLFrontbuffer.get(); } else { gl::GLScreenBuffer* screen = mGLContext->Screen(); const auto& front = screen->Front(); if (front) { frontbuffer = front->Surf(); } } if (!frontbuffer) { NS_WARNING("Null frame received."); return false; } IntSize readSize(frontbuffer->mSize); SurfaceFormat format = mOpaque ? SurfaceFormat::B8G8R8X8 : SurfaceFormat::B8G8R8A8; bool needsPremult = frontbuffer->mHasAlpha && !mIsAlphaPremultiplied; // Try to read back directly into aDestTarget's output buffer uint8_t* destData; IntSize destSize; int32_t destStride; SurfaceFormat destFormat; if (aDestTarget->LockBits(&destData, &destSize, &destStride, &destFormat)) { if (destSize == readSize && destFormat == format) { RefPtr<DataSourceSurface> data = Factory::CreateWrappingDataSourceSurface(destData, destStride, destSize, destFormat); if (!mGLContext->Readback(frontbuffer, data)) { aDestTarget->ReleaseBits(destData); return false; } if (needsPremult) { gfxUtils::PremultiplyDataSurface(data, data); } aDestTarget->ReleaseBits(destData); return true; } aDestTarget->ReleaseBits(destData); } RefPtr<DataSourceSurface> resultSurf = GetTempSurface(readSize, format); // There will already be a warning from inside of GetTempSurface, but // it doesn't hurt to complain: if (NS_WARN_IF(!resultSurf)) { return false; } // Readback handles Flush/MarkDirty. if (!mGLContext->Readback(frontbuffer, resultSurf)) { return false; } if (needsPremult) { gfxUtils::PremultiplyDataSurface(resultSurf, resultSurf); } aDestTarget->CopySurface(resultSurf, IntRect(0, 0, readSize.width, readSize.height), IntPoint(0, 0)); return true; }
QVariant getProperty(P_ID id, const QDomElement& e) { const QString& value(e.text()); switch(propertyType(id)) { case T_BOOL: return QVariant(bool(value.toInt())); case T_SUBTYPE: case T_INT: return QVariant(value.toInt()); case T_REAL: case T_SREAL: return QVariant(value.toDouble()); case T_FRACTION: return QVariant::fromValue(readFraction(e)); case T_COLOR: return QVariant(readColor(e)); case T_POINT: return QVariant(readPoint(e)); case T_SCALE: case T_SIZE: return QVariant(readSize(e)); case T_STRING: return QVariant(value); case T_DIRECTION: { if (value == "up") return QVariant(MScore::UP); else if (value == "down") return QVariant(MScore::DOWN); else if (value == "auto") return QVariant(MScore::AUTO); } break; case T_DIRECTION_H: { if (value == "left") return QVariant(MScore::DH_LEFT); else if (value == "right") return QVariant(MScore::DH_RIGHT); else if (value == "auto") return QVariant(MScore::DH_AUTO); } break; case T_LAYOUT_BREAK: if (value == "line") return QVariant(int(LAYOUT_BREAK_LINE)); if (value == "page") return QVariant(int(LAYOUT_BREAK_PAGE)); if (value == "section") return QVariant(int(LAYOUT_BREAK_SECTION)); qDebug("getProperty: invalid T_LAYOUT_BREAK: <%s>", qPrintable(value)); break; case T_VALUE_TYPE: if (value == "offset") return QVariant(int(MScore::OFFSET_VAL)); else if (value == "user") return QVariant(int(MScore::USER_VAL)); break; case T_BEAM_MODE: // TODO return QVariant(int(0)); } return QVariant(); }