Example #1
0
HRESULT exceptionToHResult() noexcept {
  try {
    throw;
  } catch (const std::system_error& ex) {
    auto code = ex.code();
    XLOG(ERR) << ex.what() << " : " << ex.code();
    if (code.category() == HResultErrorCategory::get()) {
      return code.value();
    }
    if (code.category() == Win32ErrorCategory::get()) {
      return HRESULT_FROM_WIN32(code.value());
    }
    return ERROR_ERRORS_ENCOUNTERED;

  } catch (std::bad_alloc const&) {
    return E_OUTOFMEMORY;

  } catch (const std::exception& ex) {
    XLOG(ERR) << ex.what();
    return ERROR_ERRORS_ENCOUNTERED;

  } catch (...) {
    // Make sure not to leak any exception out of here. I don't think we will
    // hit this though. Break in debug build if we do.
#ifndef NDEBUG
    DebugBreak();
#endif
    return ERROR_ERRORS_ENCOUNTERED;
  }
}
Example #2
0
void PaintedSurface::prepare(GLWebViewState* state)
{
    XLOG("PS %p has PL %p, DL %p", this, m_paintingLayer, m_drawingLayer);
    LayerAndroid* paintingLayer = m_paintingLayer;
    if (!paintingLayer)
        paintingLayer = m_drawingLayer;

    if (!paintingLayer)
        return;

    bool startFastSwap = false;
    if (state->isScrolling()) {
        // when scrolling, block updates and swap tiles as soon as they're ready
        startFastSwap = true;
    }

    XLOG("prepare layer %d %x at scale %.2f",
         paintingLayer->uniqueId(), paintingLayer,
         paintingLayer->getScale());

    IntRect visibleArea = computeVisibleArea(paintingLayer);
    IntRect prepareArea = computePrepareArea(paintingLayer); // SAMSUNG CHANGE

    m_scale = state->scale();

    // If we do not have text, we may as well limit ourselves to
    // a scale factor of one... this saves up textures.
    if (m_scale > 1 && !paintingLayer->hasText())
        m_scale = 1;

    m_tiledTexture->prepare(state, m_scale, m_pictureUsed != paintingLayer->pictureUsed(),
                            startFastSwap, visibleArea, prepareArea); // SAMSUNG CHANGE
}
bool WebGLProgram::cacheActiveAttribLocations()
{
    if (!object())
    {
    	XLOG("!object()");
        return false;
    }
    GraphicsContext3D* context3d = context()->graphicsContext3D();

    // Assume link status has already been cached.
    if (!m_linkStatus)
    {
       	XLOG("!m_linkStatus");
        return false;
    }
	
    m_activeAttribLocations.clear();

    GC3Dint numAttribs = 0;
    context3d->getProgramiv(object(), GraphicsContext3D::ACTIVE_ATTRIBUTES, &numAttribs);
    m_activeAttribLocations.resize(static_cast<size_t>(numAttribs));
    for (int i = 0; i < numAttribs; ++i) {
        ActiveInfo info;
        context3d->getActiveAttrib(object(), i, info);
        m_activeAttribLocations[i] = context3d->getAttribLocation(object(), info.name.charactersWithNullTermination());
    }

    return true;
}
// This is called on the webcore thread, save the GL texture for recycle in
// the retired queue. They will be deleted in deleteUnusedTextures() in the UI
// thread.
// Return true when we found one texture to retire.
bool VideoLayerManager::recycleTextureMem()
{
    // Find the oldest texture int the m_videoLayerInfoMap, put it in m_retiredTextures
    int oldestTimeStamp = m_currentTimeStamp;
    int oldestLayerId = -1;

    InfoIterator end = m_videoLayerInfoMap.end();
#ifdef DEBUG
    XLOG("VideoLayerManager::recycleTextureMem m_videoLayerInfoMap contains");
    for (InfoIterator it = m_videoLayerInfoMap.begin(); it != end; ++it)
        XLOG("  layerId %d, textureId %d, videoSize %d, timeStamp %d ",
             it->first, it->second->textureId, it->second->videoSize, it->second->timeStamp);
#endif
    for (InfoIterator it = m_videoLayerInfoMap.begin(); it != end; ++it) {
        if (it->second->timeStamp < oldestTimeStamp) {
            oldestTimeStamp = it->second->timeStamp;
            oldestLayerId = it->first;
        }
    }

    bool foundTextureToRetire = (oldestLayerId != -1);
    if (foundTextureToRetire)
        removeLayerInternal(oldestLayerId);

    return foundTextureToRetire;
}
Example #5
0
int wait_for_signal(pid_t tid, int* total_sleep_time_usec) {
    for (;;) {
        int status;
        pid_t n = waitpid(tid, &status, __WALL | WNOHANG);
        if (n < 0) {
            if(errno == EAGAIN) continue;
            LOG("waitpid failed: %s\n", strerror(errno));
            return -1;
        } else if (n > 0) {
            XLOG("waitpid: n=%d status=%08x\n", n, status);
            if (WIFSTOPPED(status)) {
                return WSTOPSIG(status);
            } else {
                LOG("unexpected waitpid response: n=%d, status=%08x\n", n, status);
                return -1;
            }
        }

        if (*total_sleep_time_usec > max_total_sleep_usec) {
            LOG("timed out waiting for tid=%d to die\n", tid);
            return -1;
        }

        /* not ready yet */
        XLOG("not ready yet\n");
        usleep(sleep_time_usec);
        *total_sleep_time_usec += sleep_time_usec;
    }
}
Example #6
0
//
//		LoadBone
//
int		CModelObject::LoadBone( LPCTSTR szFileName )
{
#ifdef __XDEBUG
	if( m_pBone )
		XLOG( "CModelObject::LoadBone ; 이미 본이 로딩되어 있다. 0x%08x", (int)m_pBone );
#endif
	// Bone 관리자를 통해 본을 로딩한후 그 포인터를 받아온다.
	m_pBone = g_BonesMng.LoadBone( szFileName );

	// 본을 못읽었다.
	if( m_pBone == NULL )
	{
		XERROR( "%s : 찾을 수 없음", szFileName );
		return FAIL;
	}

	m_bSkin = TRUE;		// 스키닝 오브젝트라는 플래그
#ifdef _DEBUG
	if( m_mUpdateBone )
		XLOG( "CModelObject::LoadBone : %s 이미 읽었는데 또 읽은것 같다.", szFileName );
#endif

	// 오브젝트의 계층구조가 애니메이션되면서 실시간으로 변환되는 매트릭스 배열
//	if( m_mUpdateBone == NULL )		// 모션을 재로딩을 할 수 있으므로 이미 할당 받았으면 다시 받지 않음.
	m_mUpdateBone = new MATRIX[ m_pBone->m_nMaxBone * 2 ];	// Inv랑 같이 쓰려고 * 2로 잡는다,.
	m_pBaseBoneInv = m_mUpdateBone + m_pBone->m_nMaxBone;
	
	int		i;
	for( i = 0; i < m_pBone->m_nMaxBone; i ++ )
	{
		m_mUpdateBone[i] = m_pBone->m_pBones[i].m_mTM;		// 기본셋은 미리 카피해둠.
		m_pBaseBoneInv[i] = m_pBone->m_pBones[i].m_mInverseTM;	// Inv도 미리 받아둠.
	}
	return SUCCESS;
}
Example #7
0
// When bliting, if the item from the transfer queue is mismatching b/t the
// BaseTile and the content, then the item is considered as obsolete, and
// the content is discarded.
bool TransferQueue::checkObsolete(int index)
{
    BaseTile* baseTilePtr = m_transferQueue[index].savedBaseTilePtr;
    if (!baseTilePtr) {
        XLOG("Invalid savedBaseTilePtr , such that the tile is obsolete");
        return true;
    }

    BaseTileTexture* baseTileTexture = baseTilePtr->backTexture();
    if (!baseTileTexture) {
        XLOG("Invalid baseTileTexture , such that the tile is obsolete");
        return true;
    }

    const TextureTileInfo* tileInfo = &m_transferQueue[index].tileInfo;

    if (tileInfo->m_x != baseTilePtr->x()
        || tileInfo->m_y != baseTilePtr->y()
        || tileInfo->m_scale != baseTilePtr->scale()
        || tileInfo->m_painter != baseTilePtr->painter()) {
        XLOG("Mismatching x, y, scale or painter , such that the tile is obsolete");
        return true;
    }

    return false;
}
// the painting tree has finished painting:
//   discard the drawing tree
//   swap the painting tree in place of the drawing tree
//   and start painting the queued tree
void TreeManager::swap()
{
    // swap can't be called unless painting just finished
    ASSERT(m_paintingTree);

    android::Mutex::Autolock lock(m_paintSwapLock);

    XLOG("SWAPPING, D %p, P %p, Q %p", m_drawingTree, m_paintingTree, m_queuedTree);

    // if we have a drawing tree, discard it since the painting tree is done
    if (m_drawingTree) {
        XLOG("destroying drawing tree %p", m_drawingTree);
        m_drawingTree->setIsDrawing(false);
        SkSafeUnref(m_drawingTree);
    }

    // painting tree becomes the drawing tree
    XLOG("drawing tree %p", m_paintingTree);
    m_paintingTree->setIsDrawing(true);
    if (m_paintingTree->countChildren())
        static_cast<LayerAndroid*>(m_paintingTree->getChild(0))->initAnimations();

    if (m_queuedTree) {
        // start painting with the queued tree
        XLOG("now painting tree %p", m_queuedTree);
        m_queuedTree->setIsPainting(m_paintingTree);
    }
    m_drawingTree = m_paintingTree;
    m_paintingTree = m_queuedTree;
    m_queuedTree = 0;

    TilesManager::instance()->paintedSurfacesCleanup();

    XLOG("SWAPPING COMPLETE, D %p, P %p, Q %p", m_drawingTree, m_paintingTree, m_queuedTree);
}
void GLExtras::drawFindOnPage(SkRect& viewport)
{
    WTF::Vector<MatchInfo>* matches = m_findOnPage->matches();
    XLOG("drawFindOnPage, matches: %p", matches);
    if (!matches || !m_findOnPage->isCurrentLocationValid())
        return;
    int count = matches->size();
    int current = m_findOnPage->currentMatchIndex();
    XLOG("match count: %d", count);
    if (count < MAX_NUMBER_OF_MATCHES_TO_DRAW)
        for (int i = 0; i < count; i++) {
            MatchInfo& info = matches->at(i);
            const SkRegion& region = info.getLocation();
            SkIRect rect = region.getBounds();
            if (rect.intersect(viewport.fLeft, viewport.fTop,
                               viewport.fRight, viewport.fBottom))
                drawRegion(region, i == current, false, true);
#ifdef DEBUG
            else
                XLOG("Quick rejecting [%dx%d, %d, %d", rect.fLeft, rect.fTop,
                     rect.width(), rect.height());
#endif // DEBUG
        }
    else {
        MatchInfo& info = matches->at(current);
        drawRegion(info.getLocation(), true, false, true);
    }
}
static int do_server() {
    int s;
    struct sigaction act;
    int logsocket = -1;

    /*
     * debuggerd crashes can't be reported to debuggerd.  Reset all of the
     * crash handlers.
     */
    signal(SIGILL, SIG_DFL);
    signal(SIGABRT, SIG_DFL);
    signal(SIGBUS, SIG_DFL);
    signal(SIGFPE, SIG_DFL);
    signal(SIGSEGV, SIG_DFL);
    signal(SIGPIPE, SIG_DFL);
#ifdef SIGSTKFLT
    signal(SIGSTKFLT, SIG_DFL);
#endif

    logsocket = socket_local_client("logd",
            ANDROID_SOCKET_NAMESPACE_ABSTRACT, SOCK_DGRAM);
    if(logsocket < 0) {
        logsocket = -1;
    } else {
        fcntl(logsocket, F_SETFD, FD_CLOEXEC);
    }

    act.sa_handler = SIG_DFL;
    sigemptyset(&act.sa_mask);
    sigaddset(&act.sa_mask,SIGCHLD);
    act.sa_flags = SA_NOCLDWAIT;
    sigaction(SIGCHLD, &act, 0);

    s = socket_local_server(DEBUGGER_SOCKET_NAME,
            ANDROID_SOCKET_NAMESPACE_ABSTRACT, SOCK_STREAM);
    if(s < 0) return 1;
    fcntl(s, F_SETFD, FD_CLOEXEC);

    LOG("debuggerd: " __DATE__ " " __TIME__ "\n");

    for(;;) {
        struct sockaddr addr;
        socklen_t alen;
        int fd;

        alen = sizeof(addr);
        XLOG("waiting for connection\n");
        fd = accept(s, &addr, &alen);
        if(fd < 0) {
            XLOG("accept failed: %s\n", strerror(errno));
            continue;
        }

        fcntl(fd, F_SETFD, FD_CLOEXEC);

        handle_request(fd);
    }
    return 0;
}
Example #11
0
bool TransferQueue::tryUpdateQueueWithBitmap(const TileRenderInfo* renderInfo,
                                          int x, int y, const SkBitmap& bitmap)
{
    m_transferQueueItemLocks.lock();
    bool ready = readyForUpdate();
    TextureUploadType currentUploadType = m_currentUploadType;
    m_transferQueueItemLocks.unlock();
    if (!ready) {
        XLOG("Quit bitmap update: not ready! for tile x y %d %d",
             renderInfo->x, renderInfo->y);
        return false;
    }
    if (currentUploadType == GpuUpload) {
        // a) Dequeue the Surface Texture and write into the buffer
        if (!m_ANW.get()) {
            XLOG("ERROR: ANW is null");
            return false;
        }

        ANativeWindow_Buffer buffer;
        if (ANativeWindow_lock(m_ANW.get(), &buffer, 0))
            return false;

        uint8_t* img = (uint8_t*)buffer.bits;
        int row, col;
        int bpp = 4; // Now we only deal with RGBA8888 format.
        int width = TilesManager::instance()->tileWidth();
        int height = TilesManager::instance()->tileHeight();
        if (!x && !y && bitmap.width() == width && bitmap.height() == height) {
            bitmap.lockPixels();
            uint8_t* bitmapOrigin = static_cast<uint8_t*>(bitmap.getPixels());
            if (buffer.stride != bitmap.width())
                // Copied line by line since we need to handle the offsets and stride.
                for (row = 0 ; row < bitmap.height(); row ++) {
                    uint8_t* dst = &(img[buffer.stride * row * bpp]);
                    uint8_t* src = &(bitmapOrigin[bitmap.width() * row * bpp]);
                    memcpy(dst, src, bpp * bitmap.width());
                }
            else
                memcpy(img, bitmapOrigin, bpp * bitmap.width() * bitmap.height());

            bitmap.unlockPixels();
        } else {
            // TODO: implement the partial invalidate here!
            XLOG("ERROR: don't expect to get here yet before we support partial inval");
        }

        ANativeWindow_unlockAndPost(m_ANW.get());
    }

    m_transferQueueItemLocks.lock();
    // b) After update the Surface Texture, now udpate the transfer queue info.
    addItemInTransferQueue(renderInfo, currentUploadType, &bitmap);

    m_transferQueueItemLocks.unlock();
    XLOG("Bitmap updated x, y %d %d, baseTile %p",
         renderInfo->x, renderInfo->y, renderInfo->baseTile);
    return true;
}
Example #12
0
 /* 增加syllable的发音及特征
  *   <syllable accent="*" ph="H W aH nnH" pinyin="huan1" stress="1" zhtone="1">
  *   <ph p="H"/>
  *   <ph p="W"/>
  *   <ph p="aH"/>
  *   <ph p="nnH"/>
  *   </syllable>
  */
 std::string Pronunciation::process(const std::string& input) {
     XLOG(DEBUG) << "Pronunciation input: " << input;
     pugi::xml_document doc;
     pugi::xml_parse_result result = doc.load_string(input.c_str());
     token_punc_walker tw;
     doc.traverse(tw);
     std::vector<pugi::xml_node> nodes = tw.nodes_;
     const int tobiaccentNum = 18;
     const std::string tobiAccents[tobiaccentNum] = { "0", "*", "H*",  "L*", "!H*", "^H*","L+H*", "L*+H", "L+!H*", "L*+!H",
                                                       "L+^H*", "L*+^H",  "H+!H*","H+L*", "H+^H*", "!H+!H*", "^H+!H*", "^H+^H*"};
     for (int tokenIndex = 0; tokenIndex < nodes.size(); tokenIndex++) {
         pugi::xml_node token = nodes[tokenIndex];
         std::string toneStr = token.attribute("toneseq").as_string();
         std::string pinyinStr = token.attribute("pinyinseq").as_string();
         std::string phoneStr = token.attribute("ph").as_string();
         if (toneStr.empty() || pinyinStr.empty() || phoneStr.empty()) {
             continue;
         }
         std::vector<std::string> tones = splitAndTrim(toneStr, '-');
         std::vector<std::string> pinyins = splitAndTrim(pinyinStr, '-');
         std::vector<std::string> phones = splitAndTrim(phoneStr, '-');
         assert(tones.size() == pinyins.size());
         assert(tones.size() == phones.size());
         std::string punc = "";
         int tokenPosition = MaryXml::getTokenPositionType(nodes, tokenIndex, punc);
         for (int syllableIndex = 0; syllableIndex < pinyins.size(); syllableIndex++) {
             std::string phone = phones[syllableIndex];
             std::string pinyin = pinyins[syllableIndex];
             std::string tone = tones[syllableIndex];
             std::vector<std::string> sylPhones = splitAndTrim(phone, ' ');
             pugi::xml_node syllable =  token.append_child("syllable");
             //add accent for test; TODO: use the true accent instead
             //setLabixxAccent();
             int syllablePosition = MaryXml::getSyllablePositionType(pinyins.size(), syllableIndex);
             int toneValue = std::stod(tone);
             int accentType = 0;
             if (toneValue > 0 && toneValue <= 5) {
                 accentType = getLabixxAccent(tokenPosition, syllablePosition, toneValue, punc);
             }
             std::string accentValue = tobiAccents[accentType];
             XLOG(DEBUG) << "toneConvert: " << pinyin << " " <<  toneValue << " -> accent:  " << accentType << " " << accentValue;
             syllable.append_attribute("accent") = accentValue.c_str();
             syllable.append_attribute("ph") = phone.c_str();
             syllable.append_attribute("zhtone") = tone.c_str();
             syllable.append_attribute("pinyin") = pinyin.c_str();
             for (int phoneIndex = 0; phoneIndex < sylPhones.size(); phoneIndex++) {
                 std::string sylPhone = sylPhones[phoneIndex];
                 if (sylPhone.empty()) {
                     continue;
                 }
                 syllable.append_child("ph").append_attribute("p") = sylPhone.c_str();
             }
         }
     }
     doc.save_file("data/punc.xml");
     std::string pronunStr = MaryXml::saveDoc2String(doc);
     XLOG(DEBUG) << "Pronunciation output: " << pronunStr;
     return pronunStr;
 }
Example #13
0
AbstractFile* createAbstractFileFromComp(AbstractFile* file) {
    InfoComp* info;
    AbstractFile* toReturn;
    uint8_t *compressed;

    if(!file) {
        return NULL;
    }

    info = (InfoComp*) malloc(sizeof(InfoComp));
    info->file = file;
    file->seek(file, 0);
    file->read(file, &(info->header), sizeof(info->header));
    flipCompHeader(&(info->header));
    if(info->header.signature != COMP_SIGNATURE) {
        free(info);
        return NULL;
    }

    if(info->header.compression_type != LZSS_SIGNATURE) {
        free(info);
        return NULL;
    }

    info->buffer = malloc(info->header.length_uncompressed);
    compressed = malloc(info->header.length_compressed);
    file->read(file, compressed, info->header.length_compressed);

    uint32_t real_uncompressed = decompress_lzss(info->buffer, compressed, info->header.length_compressed);
    real_uncompressed = info->header.length_uncompressed;
    if(real_uncompressed != info->header.length_uncompressed) {
        XLOG(5, "mismatch: %d %d %d %x %x\n", info->header.length_compressed, real_uncompressed, info->header.length_uncompressed, compressed[info->header.length_compressed - 2], compressed[info->header.length_compressed - 1]);
        free(compressed);
        free(info);
        return NULL;
    }

    XLOG(5, "match: %d %d %d %x %x\n", info->header.length_compressed, real_uncompressed, info->header.length_uncompressed, compressed[info->header.length_compressed - 2], compressed[info->header.length_compressed - 1]);

    free(compressed);

    info->dirty = FALSE;

    info->offset = 0;

    toReturn = (AbstractFile*) malloc(sizeof(AbstractFile));
    toReturn->data = info;
    toReturn->read = readComp;
    toReturn->write = writeComp;
    toReturn->seek = seekComp;
    toReturn->tell = tellComp;
    toReturn->getLength = getLengthComp;
    toReturn->close = closeComp;
    toReturn->type = AbstractFileTypeLZSS;

    return toReturn;
}
Example #14
0
void PrintLockFree( LPCTSTR type, int lockFree )
{
	if( lockFree != 2 )
	{
		if( lockFree == 0 )
			XLOG( "%s: lock-free 아님.", type );
		else
			XLOG( "%s: lock-free일수도 있음.", type );
	}
}
Example #15
0
/**
 * Overwrites the contents of the disk image managed by this device with the
 * contents as they were at the point the snapshot was made.
 */
static int  nand_dev_load_disk_state(QEMUFile *f, nand_dev *dev)
{
#ifndef ANDROID_QCOW
    int buf_size = NAND_DEV_SAVE_DISK_BUF_SIZE;
    uint8_t buffer[NAND_DEV_SAVE_DISK_BUF_SIZE] = {0};
    int ret;

    /* File size for restore and truncate */
    uint64_t total_size = qemu_get_be64(f);
    if (total_size > dev->max_size) {
        XLOG("%s, restore failed: size required (%lld) exceeds device limit (%lld)\n",
             __FUNCTION__, total_size, dev->max_size);
        return -EIO;
    }

    /* overwrite disk contents with snapshot contents */
    uint64_t next_offset = 0;
    ret = do_lseek(dev->fd, 0, SEEK_SET);
    if (ret < 0) {
        XLOG("%s seek failed: %s\n", __FUNCTION__, strerror(errno));
        return -EIO;
    }
    while (next_offset < total_size) {
        /* snapshot buffer may not be an exact multiple of buf_size
         * if necessary, adjust buffer size for last copy operation */
        if (total_size - next_offset < buf_size) {
            buf_size = total_size - next_offset;
        }

        ret = qemu_get_buffer(f, buffer, buf_size);
        if (ret != buf_size) {
            XLOG("%s read failed: expected %d bytes but got %d\n",
                 __FUNCTION__, buf_size, ret);
            return -EIO;
        }
        ret = do_write(dev->fd, buffer, buf_size);
        if (ret != buf_size) {
            XLOG("%s, write failed: %s\n", __FUNCTION__, strerror(errno));
            return -EIO;
        }

        next_offset += buf_size;
    }

    ret = do_ftruncate(dev->fd, total_size);
    if (ret < 0) {
        XLOG("%s ftruncate failed: %s\n", __FUNCTION__, strerror(errno));
        return -EIO;
    }
#endif

    return 0;
}
TilesManager* TilesManager::instance()
{
    if (!gInstance) {
        gInstance = new TilesManager();
        XLOG("instance(), new gInstance is %x", gInstance);
        XLOG("Waiting for the generator...");
        /***RK_ID:RK_WEBKIT. DEP_RK_ID:NULL. AUT:[email protected]. DATE:2012-07-23. START***/
        /*** fix ANR bug. when in TilesManager::TilesManager, TexturesGenerator::readyToRun is executed maybe create TilesManager second ***/
        //gInstance->waitForGenerator();
        /***RK_ID:RK_WEBKIT. DEP_RK_ID:NULL. AUT:[email protected]. DATE:2012-07-23. END***/
        XLOG("Generator ready!");
    }
    return gInstance;
}
TilesManager* TilesManager::instance()
{
    android::Mutex::Autolock lock(gGeneratorLock);
    if (!gInstance) {
        webkit_logcat("TilesManager instance new obj");
        gInstance = new TilesManager();
        webkit_logcat("TilesManager instance new obj done");
        XLOG("instance(), new gInstance is %x", gInstance);
        XLOG("Waiting for the generator...");
        webkit_logcat("TilesManager instance call wait");
        gInstance->waitForGenerator();
        XLOG("Generator ready!");
    }
    return gInstance;
}
Example #18
0
// =============================================================================
xbool Xen::CException::HandleError(xstring sMessage, xstring sCondition, xstring sFunction, xstring sFile, xint iLine)
{
	xstring sExceptionMessage;

#if !XRETAIL
	sExceptionMessage = XFORMAT
	(
		"Failed Condition: %s" XENDL "Function: %s" XENDL "Line: %d" XENDL XENDL "%s" XENDL XENDL "Would you like to debug?", 
		sCondition.c_str(), sFunction.c_str(), iLine, sMessage.c_str()
	);
#else
	sExceptionMessage = sMessage;
#endif

XLOG(sExceptionMessage.c_str());

#if XWINDOWS
	#if !XRETAIL
		xint iDialogResult = MessageBox(NULL, sExceptionMessage.c_str(), "Application Error", MB_YESNO | MB_ICONERROR | MB_APPLMODAL | MB_SETFOREGROUND | MB_DEFBUTTON1);

		if (iDialogResult == IDYES)
			return true;
	#endif
#endif
	
	throw CException(sExceptionMessage);
	return false;
}
GLuint ShaderProgram::loadShader(GLenum shaderType, const char* pSource)
{
    GLuint shader = glCreateShader(shaderType);
    if (shader) {
        glShaderSource(shader, 1, &pSource, 0);
        glCompileShader(shader);
        GLint compiled = 0;
        glGetShaderiv(shader, GL_COMPILE_STATUS, &compiled);
        if (!compiled) {
            GLint infoLen = 0;
            glGetShaderiv(shader, GL_INFO_LOG_LENGTH, &infoLen);
            if (infoLen) {
                char* buf = (char*) malloc(infoLen);
                if (buf) {
                glGetShaderInfoLog(shader, infoLen, 0, buf);
                XLOG("could not compile shader %d:\n%s\n", shaderType, buf);
                free(buf);
            }
            glDeleteShader(shader);
            shader = 0;
            }
        }
    }
    return shader;
}
Example #20
0
/* Return true if some thread is not detached cleanly */
static bool dump_sibling_thread_report(int tfd, unsigned pid, unsigned tid)
{
    char task_path[1024];

    sprintf(task_path, "/proc/%d/task", pid);
    DIR *d;
    struct dirent *de;
    int need_cleanup = 0;

    d = opendir(task_path);
    /* Bail early if cannot open the task directory */
    if (d == NULL) {
        XLOG("Cannot open /proc/%d/task\n", pid);
        return false;
    }
    while ((de = readdir(d)) != NULL) {
        unsigned new_tid;
        /* Ignore "." and ".." */
        if (!strcmp(de->d_name, ".") || !strcmp(de->d_name, "..")) 
            continue;
        new_tid = atoi(de->d_name);
        /* The main thread at fault has been handled individually */
        if (new_tid == tid)
            continue;

        /* Skip this thread if cannot ptrace it */
        if (ptrace(PTRACE_ATTACH, new_tid, 0, 0) < 0)
            continue;

        dump_crash_report(tfd, pid, new_tid, false);
        need_cleanup |= ptrace(PTRACE_DETACH, new_tid, 0, 0);
    }
    closedir(d);
    return need_cleanup != 0;
}
Example #21
0
static uint32_t nand_dev_erase_file(nand_dev *dev, uint64_t addr, uint32_t total_len)
{
    uint32_t len = total_len;
    size_t write_len = dev->erase_size;
    int ret;

#if !defined(ANDROID_QCOW)
    do_lseek(dev->fd, addr, SEEK_SET);
#endif

    memset(dev->data, 0xff, dev->erase_size);
    while(len > 0) {
        if(len < write_len)
            write_len = len;
#if defined(ANDROID_QCOW)
        ret = bdrv_pwrite(dev->bdrv, addr, dev->data, write_len);
#else
        ret = do_write(dev->fd, dev->data, write_len);
#endif
        if(ret < write_len) {
            XLOG( "nand_dev_write_file, write failed: %s\n", strerror(errno));
            break;
        }
        len -= write_len;
        addr += write_len;
    }
    return total_len - len;
}
Example #22
0
SET
setXIntersect(SET A,SET B)
{
    SET set;
    void *e;

    if (! (A->cmp && B->cmp) )
	return NULL;		/* Both need a compare function */

    /* Create new set */
    if (! (set = setNew(A->cmp,A->ed,A->ord)))
	{ XLOG(set); return NULL; }

    /* Add elements of A only */
    for (e = setFirst(A); e; e = setNext(A))
	if (!setContains(B,e))
	    setAdd(set,e);

    /* Add elements of B only */
    for (e = setFirst(B); e; e = setNext(B))
	if (!setContains(A,e))
	    setAdd(set,e);

    return set;
}
Example #23
0
// Note: this need to be called within th lock.
// Only called by updateDirtyBaseTiles() for now
void TransferQueue::cleanupTransportQueue()
{
    int index = getNextTransferQueueIndex();

    for (int i = 0 ; i < ST_BUFFER_NUMBER; i++) {
        if (m_transferQueue[index].status == pendingDiscard) {
            // No matter what the current upload type is, as long as there has
            // been a Surf Tex enqueue operation, this updateTexImage need to
            // be called to keep things in sync.
            if (m_transferQueue[index].uploadType == GpuUpload) {
                status_t result = m_sharedSurfaceTexture->updateTexImage();
                if (result != OK)
                    XLOGC("unexpected error: updateTexImage return %d", result);
            }

            // since tiles in the queue may be from another webview, remove
            // their textures so that they will be repainted / retransferred
            BaseTile* tile = m_transferQueue[index].savedBaseTilePtr;
            BaseTileTexture* texture = m_transferQueue[index].savedBaseTileTexturePtr;
            if (tile && texture && texture->owner() == tile) {
                // since tile destruction removes textures on the UI thread, the
                // texture->owner ptr guarantees the tile is valid
                tile->discardBackTexture();
                XLOG("transfer queue discarded tile %p, removed texture", tile);
            }

            m_transferQueue[index].savedBaseTilePtr = 0;
            m_transferQueue[index].savedBaseTileTexturePtr = 0;
            m_transferQueue[index].status = emptyItem;
        }
        index = (index + 1) % ST_BUFFER_NUMBER;
    }
}
Example #24
0
//
// Constant.h를 읽어 #define name value들을 모두 메모리에 적재
// Load()를 연속적으로 읽는다면 m_nMaxDef부터 추가로 읽게 된다.
// ex)  Load( "constant1.h" );	0 ~ 300 인덱스
//      Load( "constant2.h" );	301 ~ 600 인덱스
XE::xRESULT CDefine::Load( LPCTSTR strFileName )
{
	CToken	Token;
	TCHAR szName[256];

	if( Token.LoadFile( strFileName, TXT_EUCKR ) == XE::xFAIL )
		return XE::xFAIL;
	while(1)
	{
		if( Token.GetToken() == NULL )	break;
		if( Token == _T("define") )
		{
			Token.GetToken();
			// ex) #define OBJECT_DAO	1
			if( Token.m_Token[0] != '_' )		// #define _HUHU같이 첫자가밑줄 붙은건 읽지 않음
			{
				_tcscpy_s( szName, Token.m_Token );
				int		nVal = Token.GetNumber();
				// 읽어 메모리로 올릴때는 주석을 읽지 않는다.  
				// Object.inc에 있는 NAME부분을 가지고 저장할때만 기록한다.
				if( XE::xFAIL == AddDefine( szName, nVal, Token.GetRemark() ) )			// define 추가
				{
					XERROR( "%s 읽던중 CDefine의 최대 버퍼%d를 넘었다", strFileName, MAX_DEFINE );
					break;
				}
			} else
				XLOG( "define %s skip", Token.m_Token );
		}
	}
	return XE::xSUCCESS;
}
RocksHandles::RocksHandles(
    StringPiece dbPath,
    const Options& options,
    const std::vector<ColumnFamilyDescriptor>& columnDescriptors) {
  auto dbPathStr = dbPath.str();
  DB* dbRaw;
  std::vector<ColumnFamilyHandle*> columnHandles;

  // This will create any newly defined column families automatically,
  // so we needn't make any special migration steps here; just define
  // a new family and start to use it.
  // If we remove column families in the future this call will fail
  // and shout at us for not opening up the database with them defined.
  // We will need to do "something smarter" if we ever decide to perform
  // that kind of a migration.
  auto status =
      DB::Open(options, dbPathStr, columnDescriptors, &columnHandles, &dbRaw);
  if (!status.ok()) {
    XLOG(ERR) << "Error opening RocksDB storage at " << dbPathStr << ": "
              << status.ToString();
    throw RocksException::build(
        status, "error opening RocksDB storage at", dbPathStr);
  }

  db.reset(dbRaw);
  columns.reserve(columnHandles.size());
  for (auto h : columnHandles) {
    columns.emplace_back(h);
  }
}
void CheckoutAction::error(
    folly::StringPiece msg,
    const folly::exception_wrapper& ew) {
  XLOG(ERR) << "error performing checkout action: " << msg << ": "
            << folly::exceptionStr(ew);
  errors_.push_back(ew);
}
static bool nativeSerializeViewState(JNIEnv* env, jobject, jint jbaseLayer,
                                     jobject jstream, jbyteArray jstorage)
{
    BaseLayerAndroid* baseLayer = (BaseLayerAndroid*) jbaseLayer;
    if (!baseLayer)
        return false;

    SkWStream *stream = CreateJavaOutputStreamAdaptor(env, jstream, jstorage);
#if USE(ACCELERATED_COMPOSITING)
// SAMSUNG CHANGE >> White flickering issue.
// WAS:stream->write32(baseLayer->getBackgroundColor().rgb());
    stream->write32(baseLayer->getBackgroundColor());
// SAMSUNG CHANGE <<
#else
    stream->write32(0);
#endif
    SkPicture picture;
    PictureSet* content = baseLayer->content();
    baseLayer->drawCanvas(picture.beginRecording(content->width(), content->height(),
            SkPicture::kUsePathBoundsForClip_RecordingFlag));
    picture.endRecording();
    if (!stream)
        return false;
    picture.serialize(stream);
    int childCount = baseLayer->countChildren();
    XLOG("BaseLayer has %d child(ren)", childCount);
    stream->write32(childCount);
    for (int i = 0; i < childCount; i++) {
        LayerAndroid* layer = static_cast<LayerAndroid*>(baseLayer->getChild(i));
        serializeLayer(layer, stream);
    }
    delete stream;
    return true;
}
Example #28
0
static uint32_t nand_dev_write_file(nand_dev *dev, uint32_t data, uint64_t addr, uint32_t total_len)
{
    uint32_t len = total_len;
    size_t write_len = dev->erase_size;
    int ret;

    NAND_UPDATE_WRITE_THRESHOLD(total_len);

    do_lseek(dev->fd, addr, SEEK_SET);
    while(len > 0) {
        if(len < write_len)
            write_len = len;
#ifdef TARGET_I386
        if (kvm_enabled())
                cpu_synchronize_state(cpu_single_env, 0);
#endif
        cpu_memory_rw_debug(cpu_single_env, data, dev->data, write_len, 0);
        ret = do_write(dev->fd, dev->data, write_len);
        if(ret < write_len) {
            XLOG("nand_dev_write_file, write failed: %s\n", strerror(errno));
            break;
        }
        data += write_len;
        len -= write_len;
    }
    return total_len - len;
}
Example #29
0
// src서피스를 this로 카피.
void XSurfaceOpenGL::CopySurface( XSurface *src )
{
    XSurfaceOpenGL *pSrc = (XSurfaceOpenGL *)src;
    // src를 FBO에 연결
    // glCopyTexImage를 이용해 src에서 this로 옮김.
    GLuint fbo;
    glGenFramebuffersOES(1, &fbo);
    glBindFramebufferOES(GL_FRAMEBUFFER_OES, fbo);
    glFramebufferTexture2DOES(GL_FRAMEBUFFER_OES, GL_COLOR_ATTACHMENT0_OES, GL_TEXTURE_2D, pSrc->GetTextureID(), 0);

    GLenum status = glCheckFramebufferStatusOES(GL_FRAMEBUFFER_OES);
    if( status != GL_FRAMEBUFFER_COMPLETE_OES )
    {
        XLOG( "status=%d", status );
        return;
    }

    // copy texture from framebuffer
    glBindTexture(GL_TEXTURE_2D, m_textureID);
    glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, pSrc->GetMemWidth(), pSrc->GetMemHeight());

    // FBO해제
    GRAPHICS_GL->RestoreFrameBuffer();
    glDeleteFramebuffersOES(1, &fbo);
}
void TilesManager::setMaxLayerTextureCount(int max)
{
    XLOG("setMaxLayerTextureCount: %d (current: %d, total:%d)",
         max, m_maxLayerTextureCount, MAX_TEXTURE_ALLOCATION);
    if (!max && m_hasLayerTextures) {
        double secondsSinceLayersUsed = WTF::currentTime() - m_lastTimeLayersUsed;
        if (secondsSinceLayersUsed > LAYER_TEXTURES_DESTROY_TIMEOUT) {
            unsigned long long sparedDrawCount = ~0; // by default, spare no textures
            deallocateTexturesVector(sparedDrawCount, m_tilesTextures);
            m_hasLayerTextures = false;
        }
        return;
    }
    m_lastTimeLayersUsed = WTF::currentTime();
    if (m_maxLayerTextureCount == MAX_TEXTURE_ALLOCATION ||
         max <= m_maxLayerTextureCount)
        return;

    android::Mutex::Autolock lock(m_texturesLock);

    if (max < MAX_TEXTURE_ALLOCATION)
        m_maxLayerTextureCount = max;
    else
        m_maxLayerTextureCount = MAX_TEXTURE_ALLOCATION;

    allocateTiles();
    m_hasLayerTextures = true;
}