void PluginLayerWebKitThread::setPluginView(PluginView* pluginView) { m_pluginView = pluginView; setNeedsTexture(isDrawable() && pluginView); setLayerProgram(LayerProgramRGBA); if (m_pluginView) setNeedsDisplay(); else { // We can't afford to wait until the next commit // to set the m_pluginView to 0 in the impl, because it is // about to be destroyed. layerCompositingThread()->setPluginView(0); setNeedsCommit(); } }
void VideoLayerWebKitThread::setMediaPlayer(MediaPlayer* mediaPlayer) { m_mediaPlayer = mediaPlayer; // This is a bit of a misnomer, since we don't need an actual GL texture. // However, the LayerRenderer will only process layers that "need textures" setNeedsTexture(isDrawable() && (contents() || drawsContent() || this->mediaPlayer())); if (!m_mediaPlayer) { // We can't afford to wait until the next commit to set the m_mediaPlayer // to 0 in the impl, because it is about to be destroyed. layerCompositingThread()->setMediaPlayer(0); // Clear hole punch rect. setHolePunchRect(IntRect()); } setNeedsCommit(); }
QRegion TilePainter::computeFillRegion(const QPoint &fillOrigin) const { //create that region that will hold the fill QRegion fillRegion; //silently quit if parameters are unsatisfactory if (!isDrawable(fillOrigin.x(), fillOrigin.y())) return fillRegion; //cache cell that we will match other cells against const Cell matchCell = cellAt(fillOrigin.x(), fillOrigin.y()); //grab map dimensions for later use. const int mapWidth = mMapEditor->map()->width(); const int mapHeight = mMapEditor->map()->height(); const int mapSize = mapWidth * mapHeight; //create a queue to hold cells that need filling QList<QPoint> fillPositions; fillPositions.append(fillOrigin); qDebug() << "fix " << fillPositions.at(0).x(); qDebug() << "fiy " << fillPositions.at(0).y(); //create an array that will store which cells have been processed //this is faster than checking if a given cell is in the region/list QVector<quint8> processedCellsVec(mapSize); quint8 *processedCells = processedCellsVec.data(); //loop through queued positions and fill them, while at the same time //checking adjacent positions to see if they should be added while (!fillPositions.isEmpty()) { for (int i = 0; i < fillPositions.size(); ++i) { qDebug() << "fx " << fillPositions.at(i).x(); qDebug() << "fy " << fillPositions.at(i).y(); } const QPoint currentPoint = fillPositions.takeFirst(); //qDebug() << "cpx" << currentPoint.x(); //qDebug() << "cpy" << currentPoint.y(); const int startOfLine = currentPoint.y() * mapWidth; //seek as far left as we can int left = currentPoint.x(); while (cellAt(left - 1, currentPoint.y()) == matchCell && isDrawable(left - 1, currentPoint.y())) --left; //seek as far right as we can int right = currentPoint.x(); while (cellAt(right + 1, currentPoint.y()) == matchCell && isDrawable(right + 1, currentPoint.y())) ++right; qDebug() << left; //add cells between left and right to the region fillRegion += QRegion(left, currentPoint.y(), right - left + 1, 1); //add cell strip to processed cells memset(&processedCells[startOfLine + left], 1, right - left); //these variables cache whether the last cell was added to the queue //or not as an optimization, since adjacent cells on the x axis //do not need to be added to the queue. bool lastAboveCell = false; bool lastBelowCell = false; //loop between left and right and check if cells above or //below need to be added to the queue for (int x = left; x <= right; ++x) { const QPoint fillPoint(x, currentPoint.y()); //check cell above if (fillPoint.y() > 0) { QPoint aboveCell(fillPoint.x(), fillPoint.y() - 1); if (!processedCells[aboveCell.y() * mapWidth + aboveCell.x()] && cellAt(aboveCell.x(), aboveCell.y()) == matchCell && isDrawable(aboveCell.x(), aboveCell.y())) { //do not add the above cell to the queue if its //x-adjacent cell was added. if (!lastAboveCell) fillPositions.append(aboveCell); lastAboveCell = true; } else lastAboveCell = false; processedCells[aboveCell.y() * mapWidth + aboveCell.x()] = 1; } //check cell below if (fillPoint.y() + 1 < mapHeight) { QPoint belowCell(fillPoint.x(), fillPoint.y() + 1); if (!processedCells[belowCell.y()*mapWidth + belowCell.x()] && cellAt(belowCell.x(), belowCell.y()) == matchCell && isDrawable(belowCell.x(), belowCell.y())) { //do not add the below cell to the queue if its //x-adjacent cell was added. if (!lastBelowCell) fillPositions.append(belowCell); lastBelowCell = true; } else lastBelowCell = false; processedCells[belowCell.y() * mapWidth + belowCell.x()] = 1; } } } return fillRegion; }