Example #1
0
void UnicodeTest::TestBidiPairedBracketType() {
    // BidiBrackets-6.3.0.txt says:
    //
    // The set of code points listed in this file was originally derived
    // using the character properties General_Category (gc), Bidi_Class (bc),
    // Bidi_Mirrored (Bidi_M), and Bidi_Mirroring_Glyph (bmg), as follows:
    // two characters, A and B, form a pair if A has gc=Ps and B has gc=Pe,
    // both have bc=ON and Bidi_M=Y, and bmg of A is B. Bidi_Paired_Bracket
    // maps A to B and vice versa, and their Bidi_Paired_Bracket_Type
    // property values are Open and Close, respectively.
    IcuTestErrorCode errorCode(*this, "TestBidiPairedBracketType()");
    UnicodeSet bpt("[:^bpt=n:]", errorCode);
    assertTrue("bpt!=None is not empty", !bpt.isEmpty());
    // The following should always be true.
    UnicodeSet mirrored("[:Bidi_M:]", errorCode);
    UnicodeSet other_neutral("[:bc=ON:]", errorCode);
    assertTrue("bpt!=None is a subset of Bidi_M", mirrored.containsAll(bpt));
    assertTrue("bpt!=None is a subset of bc=ON", other_neutral.containsAll(bpt));
    // The following are true at least initially in Unicode 6.3.
    UnicodeSet bpt_open("[:bpt=o:]", errorCode);
    UnicodeSet bpt_close("[:bpt=c:]", errorCode);
    UnicodeSet ps("[:Ps:]", errorCode);
    UnicodeSet pe("[:Pe:]", errorCode);
    assertTrue("bpt=Open is a subset of Ps", ps.containsAll(bpt_open));
    assertTrue("bpt=Close is a subset of Pe", pe.containsAll(bpt_close));
}
Example #2
0
	TextureRegion TextureRegion::mirrored(const bool doMirror) const
	{
		if (doMirror)
		{
			return mirrored();
		}
		else
		{
			return *this;
		}
	}
Example #3
0
uint64_t reverse_board50(uint64_t image)
{
	int bit;
	uint64_t rev;

	rev = 0;
	while (image) {
		bit = LSB64(image);
		image = clear_lsb(image);
		rev |= ((uint64_t)1 << mirrored(bit));
	}
	return(rev);
}
Example #4
0
File: F.c Project: jpbat/lpa2014
int main(int argc, char **argv)
{
	char s[MAX_STRING];

	memset(mirrors, 0, MAX_SYMBOLS * sizeof(char));
	
	mirrors[(int)'A'] = 'A';
	mirrors[(int)'E'] = '3';
	mirrors[(int)'H'] = 'H';
	mirrors[(int)'I'] = 'I';
	mirrors[(int)'J'] = 'L';
	mirrors[(int)'L'] = 'J';
	mirrors[(int)'M'] = 'M';
	mirrors[(int)'O'] = 'O';
	mirrors[(int)'S'] = '2';
	mirrors[(int)'T'] = 'T';
	mirrors[(int)'U'] = 'U';
	mirrors[(int)'V'] = 'V';
	mirrors[(int)'W'] = 'W';
	mirrors[(int)'X'] = 'X';
	mirrors[(int)'Y'] = 'Y';
	mirrors[(int)'Z'] = '5';
	mirrors[(int)'1'] = '1';
	mirrors[(int)'2'] = 'S';
	mirrors[(int)'3'] = 'E';
	mirrors[(int)'5'] = 'Z';
	mirrors[(int)'8'] = '8';
	
	while(scanf("%s", s) != EOF)
	{
		int mirror = mirrored(s);
		int palindrome = palind(s);
		if (mirror && palindrome)
			printf("%s -- is a mirrored palindrome.\n", s);
		else if (mirror && !palindrome)
			printf("%s -- is a mirrored string.\n", s);
		else if (!mirror && palindrome)
			printf("%s -- is a regular palindrome.\n", s);
		else
			printf("%s -- is not a palindrome.\n", s);
		printf("\n");
	}

	return 0;
}
Example #5
0
void DeviceInstance::setIsMirrored(bool mirror) noexcept
{
    mIsMirrored = mirror;
    emit mirrored(mIsMirrored);
}
Example #6
0
void SSGQuickLayer::grab()
{
    if (!m_item || m_size.isNull()) {
        delete m_fbo;
        delete m_secondaryFbo;
        m_fbo = m_secondaryFbo = 0;
        m_depthStencilBuffer.clear();
        m_dirtyTexture = false;
        return;
    }
    QSGNode *root = m_item;
    while (root->firstChild() && root->type() != QSGNode::RootNodeType)
        root = root->firstChild();
    if (root->type() != QSGNode::RootNodeType)
        return;

    if (!m_renderer) {
        m_renderer = m_context->createRenderer();
        connect(m_renderer, SIGNAL(sceneGraphChanged()), this, SLOT(markDirtyTexture()));
    }
    m_renderer->setDevicePixelRatio(m_device_pixel_ratio);
    m_renderer->setRootNode(static_cast<QSGRootNode *>(root));

    QOpenGLFunctions *funcs = QOpenGLContext::currentContext()->functions();
    bool deleteFboLater = false;
    if (!m_fbo || m_fbo->size() != m_size || m_fbo->format().internalTextureFormat() != m_format
        || (!m_fbo->format().mipmap() && m_mipmap))
    {
        if (!m_multisamplingChecked) {
            if (m_context->openglContext()->format().samples() <= 1) {
                m_multisampling = false;
            } else {
                const QSet<QByteArray> extensions = m_context->openglContext()->extensions();
                m_multisampling = extensions.contains(QByteArrayLiteral("GL_EXT_framebuffer_multisample"))
                    && extensions.contains(QByteArrayLiteral("GL_EXT_framebuffer_blit"));
            }
            m_multisamplingChecked = true;
        }
        if (m_multisampling) {
            // Don't delete the FBO right away in case it is used recursively.
            deleteFboLater = true;
            delete m_secondaryFbo;
            QOpenGLFramebufferObjectFormat format;

            format.setInternalTextureFormat(m_format);
            format.setSamples(m_context->openglContext()->format().samples());
            m_secondaryFbo = new QOpenGLFramebufferObject(m_size, format);
            m_depthStencilBuffer = m_context->depthStencilBufferForFbo(m_secondaryFbo);
        } else {
            QOpenGLFramebufferObjectFormat format;
            format.setInternalTextureFormat(m_format);
            format.setMipmap(m_mipmap);
            if (m_recursive) {
                deleteFboLater = true;
                delete m_secondaryFbo;
                m_secondaryFbo = new QOpenGLFramebufferObject(m_size, format);
                funcs->glBindTexture(GL_TEXTURE_2D, m_secondaryFbo->texture());
                updateBindOptions(true);
                m_depthStencilBuffer = m_context->depthStencilBufferForFbo(m_secondaryFbo);
            } else {
                delete m_fbo;
                delete m_secondaryFbo;
                m_fbo = new QOpenGLFramebufferObject(m_size, format);
                m_secondaryFbo = 0;
                funcs->glBindTexture(GL_TEXTURE_2D, m_fbo->texture());
                updateBindOptions(true);
                m_depthStencilBuffer = m_context->depthStencilBufferForFbo(m_fbo);
            }
        }
    }

    if (m_recursive && !m_secondaryFbo) {
        // m_fbo already created, m_recursive was just set.
        Q_ASSERT(m_fbo);
        Q_ASSERT(!m_multisampling);

        m_secondaryFbo = new QOpenGLFramebufferObject(m_size, m_fbo->format());
        funcs->glBindTexture(GL_TEXTURE_2D, m_secondaryFbo->texture());
        updateBindOptions(true);
    }

    // Render texture.
    root->markDirty(QSGNode::DirtyForceUpdate); // Force matrix, clip and opacity update.
    m_renderer->nodeChanged(root, QSGNode::DirtyForceUpdate); // Force render list update.

#ifdef QSG_DEBUG_FBO_OVERLAY
    if (qmlFboOverlay()) {
        if (!m_debugOverlay)
            m_debugOverlay = new QSGSimpleRectNode();
        m_debugOverlay->setRect(QRectF(0, 0, m_size.width(), m_size.height()));
        m_debugOverlay->setColor(QColor(0xff, 0x00, 0x80, 0x40));
        root->appendChildNode(m_debugOverlay);
    }
#endif

    m_dirtyTexture = false;

    m_renderer->setDeviceRect(m_size);
    m_renderer->setViewportRect(m_size);
    QRectF mirrored(m_mirrorHorizontal ? m_rect.right() : m_rect.left(),
                    m_mirrorVertical ? m_rect.bottom() : m_rect.top(),
                    m_mirrorHorizontal ? -m_rect.width() : m_rect.width(),
                    m_mirrorVertical ? -m_rect.height() : m_rect.height());
    m_renderer->setProjectionMatrixToRect(mirrored);
    m_renderer->setClearColor(Qt::transparent);

    if (m_multisampling) {
        m_renderer->renderScene(BindableFbo(m_secondaryFbo, m_depthStencilBuffer.data()));

        if (deleteFboLater) {
            delete m_fbo;
            QOpenGLFramebufferObjectFormat format;
            format.setInternalTextureFormat(m_format);
            format.setAttachment(QOpenGLFramebufferObject::NoAttachment);
            format.setMipmap(m_mipmap);
            format.setSamples(0);
            m_fbo = new QOpenGLFramebufferObject(m_size, format);
            funcs->glBindTexture(GL_TEXTURE_2D, m_fbo->texture());
            updateBindOptions(true);
        }

        QRect r(QPoint(), m_size);
        QOpenGLFramebufferObject::blitFramebuffer(m_fbo, r, m_secondaryFbo, r);
    } else {
        if (m_recursive) {
            m_renderer->renderScene(BindableFbo(m_secondaryFbo, m_depthStencilBuffer.data()));

            if (deleteFboLater) {
                delete m_fbo;
                QOpenGLFramebufferObjectFormat format;
                format.setAttachment(QOpenGLFramebufferObject::CombinedDepthStencil);
                format.setInternalTextureFormat(m_format);
                format.setMipmap(m_mipmap);
                m_fbo = new QOpenGLFramebufferObject(m_size, format);
                funcs->glBindTexture(GL_TEXTURE_2D, m_fbo->texture());
                updateBindOptions(true);
            }
            qSwap(m_fbo, m_secondaryFbo);
        } else {
            m_renderer->renderScene(BindableFbo(m_fbo, m_depthStencilBuffer.data()));
        }
    }

    if (m_mipmap) {
        funcs->glBindTexture(GL_TEXTURE_2D, textureId());
        funcs->glGenerateMipmap(GL_TEXTURE_2D);
    }

    root->markDirty(QSGNode::DirtyForceUpdate); // Force matrix, clip, opacity and render list update.

#ifdef QSG_DEBUG_FBO_OVERLAY
    if (qmlFboOverlay())
        root->removeChildNode(m_debugOverlay);
#endif
    if (m_recursive)
        markDirtyTexture(); // Continuously update if 'live' and 'recursive'.
}
Example #7
0
  fontPainter.setRenderHint(QPainter::TextAntialiasing, true);
  fontPainter.setRenderHint(QPainter::SmoothPixmapTransform, true);
  fontPainter.setFont(QFont("Ubuntu", 24));
  fontPainter.setLayoutDirection(Qt::RightToLeft);
  fontPainter.setPen(Qt::white);

  string text = "";
  foreach(string line, textLines) {
    text += line + "\n";
  }

  fontPainter.drawText(drawBox, Qt::AlignLeft, QString::fromStdString(text));
  fontPainter.end();

  //TODO: Qt loads image with wrong pixel order
  image = image.mirrored(false, true);

}

void FontOverlay::addText(string id, string value){
  textLines.insert(id, value);
}
void FontOverlay::updateText(string id, string value) {
  textLines[id] = value;
}

void FontOverlay::draw() {
  glError;
  glEnable(GL_BLEND);
  shader->use();
  shader->setUniform("MVPMatrix",QMatrix4x4());
Example #8
0
void AbstractContent::toXml(QDomElement & contentElement, const QDir & /*baseDir*/) const
{
    // Save general item properties
    contentElement.setTagName("abstract");
    QDomDocument doc = contentElement.ownerDocument();
    QDomElement domElement;
    QDomText text;
    QString valueStr;

    // Save item position and size
    QDomElement rectParent = doc.createElement("rect");
    QDomElement xElement = doc.createElement("x");
    rectParent.appendChild(xElement);
    QDomElement yElement = doc.createElement("y");
    rectParent.appendChild(yElement);
    QDomElement wElement = doc.createElement("w");
    rectParent.appendChild(wElement);
    QDomElement hElement = doc.createElement("h");
    rectParent.appendChild(hElement);

    QRectF rect = m_contentRect;
    xElement.appendChild(doc.createTextNode(QString::number(rect.left())));
    yElement.appendChild(doc.createTextNode(QString::number(rect.top())));
    wElement.appendChild(doc.createTextNode(QString::number(rect.width())));
    hElement.appendChild(doc.createTextNode(QString::number(rect.height())));
    contentElement.appendChild(rectParent);

    // Save the position
    domElement = doc.createElement("pos");
    xElement = doc.createElement("x");
    yElement = doc.createElement("y");
    valueStr.setNum(pos().x());
    xElement.appendChild(doc.createTextNode(valueStr));
    valueStr.setNum(pos().y());
    yElement.appendChild(doc.createTextNode(valueStr));
    domElement.appendChild(xElement);
    domElement.appendChild(yElement);
    contentElement.appendChild(domElement);

    // Save the stacking position
    domElement= doc.createElement("zvalue");
    contentElement.appendChild(domElement);
    valueStr.setNum(zValue());
    text = doc.createTextNode(valueStr);
    domElement.appendChild(text);

    // Save the visible state
    domElement= doc.createElement("visible");
    contentElement.appendChild(domElement);
    valueStr.setNum(isVisible());
    text = doc.createTextNode(valueStr);
    domElement.appendChild(text);

    // Save the opacity
    if (contentOpacity() < 1.0) {
        domElement= doc.createElement("opacity");
        contentElement.appendChild(domElement);
        domElement.appendChild(doc.createTextNode(QString::number(contentOpacity())));
    }

    // Save the Fx Index
    if (fxIndex() > 0) {
        domElement = doc.createElement("fxindex");
        contentElement.appendChild(domElement);
        domElement.appendChild(doc.createTextNode(QString::number(fxIndex())));
    }

    // Save the frame class
    valueStr.setNum(frameClass());
    domElement= doc.createElement("frame-class");
    contentElement.appendChild(domElement);
    text = doc.createTextNode(valueStr);
    domElement.appendChild(text);

    domElement= doc.createElement("frame-text-enabled");
    contentElement.appendChild(domElement);
    valueStr.setNum(frameTextEnabled());
    text = doc.createTextNode(valueStr);
    domElement.appendChild(text);

    if(frameTextEnabled()) {
        domElement= doc.createElement("frame-text");
        contentElement.appendChild(domElement);
        text = doc.createTextNode(frameText());
        domElement.appendChild(text);
    }

    // save transformation
    const QTransform t = transform();
    if (!t.isIdentity() || rotation() != 0) {
        domElement = doc.createElement("transformation");
        domElement.setAttribute("xRot", m_perspectiveAngles.x());
        domElement.setAttribute("yRot", m_perspectiveAngles.y());
#if QT_VERSION < 0x040600
        domElement.setAttribute("zRot", m_rotationAngle);
#else
        domElement.setAttribute("zRot", rotation());
#endif
        contentElement.appendChild(domElement);
    }
    domElement = doc.createElement("mirror");
    domElement.setAttribute("state", mirrored());
    contentElement.appendChild(domElement);
}
Example #9
0
File: rom.cpp Project: crust/nes
uint8_t const &ROM::mirrored_prg(uint16_t addr, uint16_t mod) const
{
    return mirrored(_prg, _prg_bank, addr, mod);
}
Example #10
0
File: rom.cpp Project: crust/nes
uint8_t const &ROM::mirrored_chr(uint16_t addr, uint16_t mod) const
{
    return mirrored(_chr, _chr_bank, addr, mod);
}
Example #11
0
    static void apply( const std::string &pathFile, bool mirror_h = false, bool mirror_v = false )
    {
        if( !pathFile.size() )
            return;

        std::cout << "Registering texture: " << pathFile << std::endl;

        // decode
        int imageWidth = 0, imageHeight = 0, imageBpp;
        std::vector<stbi_uc> image;

        {
            moon9::strings pathFileExt = moon9::string( pathFile ).tokenize("|");
            int subframe = ( pathFileExt.size() > 1 ? pathFileExt[1].as<int>() : 0 );

            stbi_gif_subframe_selector = subframe;
            stbi_uc *imageuc = stbi_load( pathFileExt[0].c_str(), &imageWidth, &imageHeight, &imageBpp, 4 );

            if( !imageuc )
            {
                // failed
                std::cerr << moon9::string( "Cant find texture '\1'\n", pathFile );
                // assert( false );
                // yellow/black texture instead?
                return;
            }

            bool is_power_of_two_w = imageWidth && !(imageWidth & (imageWidth - 1));
            bool is_power_of_two_h = imageHeight && !(imageHeight & (imageHeight - 1));

            if( is_power_of_two_w && is_power_of_two_h )
            {
                image.resize( imageWidth * imageHeight * 4 );

                //memcpy( image.data(), imageuc, imageWidth * imageHeight * 4 );
                memcpy( &image[0], imageuc, imageWidth * imageHeight * 4 );
            }
            else
            {
                int nw = 1, nh = 1, atx, aty;
                while( nw < imageWidth ) nw <<= 1;
                while( nh < imageHeight ) nh <<= 1;

                // squared as well, cos we want them pixel perfect
                if( nh > nw ) nw = nh;
                else nh = nw;

                image.resize( nw * nh * 4, 0 );
                atx = (nw - imageWidth) / 2;
                aty = (nh - imageHeight) / 2;

                //std::cout << moon9::string( "\1x\2 -> \3x\4 @(\5,\6)\n", imageWidth, imageHeight, nw, nh, atx, aty);

                for( int y = 0; y < imageHeight; ++y )
//                            memcpy( &((stbi_uc*)image.data())[ ((atx)+(aty+y)*nw)*4 ], &imageuc[ (y*imageWidth) * 4 ], imageWidth * 4 );
                    memcpy( &((stbi_uc*)&image[0])[ ((atx)+(aty+y)*nw)*4 ], &imageuc[ (y*imageWidth) * 4 ], imageWidth * 4 );

                imageWidth = nw;
                imageHeight = nh;
            }

            stbi_image_free( imageuc );
        }

        if( mirror_h && !mirror_v )
        {
            std::vector<stbi_uc> mirrored( image.size() );

            for( int c = 0, y = 0; y < imageHeight; ++y )
                for( int x = imageWidth - 1; x >= 0; --x )
                    mirrored[ c++ ] = image[ ( x + y * imageWidth ) * 4 + 0 ],
                                      mirrored[ c++ ] = image[ ( x + y * imageWidth ) * 4 + 1 ],
                                                        mirrored[ c++ ] = image[ ( x + y * imageWidth ) * 4 + 2 ],
                                                                mirrored[ c++ ] = image[ ( x + y * imageWidth ) * 4 + 3 ];

            image = mirrored;
        }
        else if( mirror_v && !mirror_h )
        {
            std::vector<stbi_uc> mirrored( image.size() );

            for( int c = 0, y = imageHeight - 1; y >= 0; --y )
                for( int x = 0; x < imageWidth; ++x )
                    mirrored[ c++ ] = image[ ( x + y * imageWidth ) * 4 + 0 ],
                                      mirrored[ c++ ] = image[ ( x + y * imageWidth ) * 4 + 1 ],
                                                        mirrored[ c++ ] = image[ ( x + y * imageWidth ) * 4 + 2 ],
                                                                mirrored[ c++ ] = image[ ( x + y * imageWidth ) * 4 + 3 ];

            image = mirrored;
        }
        else if( mirror_h && mirror_v )
        {
            std::vector<stbi_uc> mirrored( image.size() );

            for( int c = 0, y = imageHeight - 1; y >= 0; --y )
                for( int x = imageWidth - 1; x >= 0; --x )
                    mirrored[ c++ ] = image[ ( x + y * imageWidth ) * 4 + 0 ],
                                      mirrored[ c++ ] = image[ ( x + y * imageWidth ) * 4 + 1 ],
                                                        mirrored[ c++ ] = image[ ( x + y * imageWidth ) * 4 + 2 ],
                                                                mirrored[ c++ ] = image[ ( x + y * imageWidth ) * 4 + 3 ];

            image = mirrored;

            std::swap( imageWidth, imageHeight );
        }

        // submit decoded data to texture

        GLint   UnpackAlignment;

        // Here we bind the texture and set up the filtering.
        //glBindTexture(GL_TEXTURE_2D, id);

        // Set unpack alignment to one byte
        glGetIntegerv( GL_UNPACK_ALIGNMENT, &UnpackAlignment );
        glPixelStorei( GL_UNPACK_ALIGNMENT, 1 );

        GLenum type = GL_RGBA; //GL_ALPHA, GL_LUMINANCE, GL_RGBA

#if 1 //if buildmipmaps

        GLint ret = gluBuild2DMipmaps(GL_TEXTURE_2D, GL_RGBA, imageWidth, imageHeight,
//                                                type, GL_UNSIGNED_BYTE, image.data());
                                      type, GL_UNSIGNED_BYTE, &image[0]);

#else // else...

        glTexImage2D(GL_TEXTURE_2D, 0 /*LOD*/, GL_RGBA, imageWidth, imageHeight,
                     0 /*border*/, type, GL_UNSIGNED_BYTE, image.data());

#endif

        // Restore old unpack alignment
        glPixelStorei( GL_UNPACK_ALIGNMENT, UnpackAlignment );
    }