Exemplo n.º 1
0
void SkGLDrawProcs::drawQuads() {
    SkASSERT(SK_ARRAY_COUNT(gQuadIndices) == MAX_QUADS * 6);

    glBindTexture(GL_TEXTURE_2D, fCurrTexture);

#if 0
    static bool gOnce;
    if (!gOnce) {
        generateQuadIndices(MAX_QUADS);
        gOnce = true;
    }
#endif

    // convert from quad vertex count to triangle vertex count
    // 6/4 * n == n + (n >> 1) since n is always a multiple of 4
    SkASSERT((fCurrQuad & 3) == 0);
    int count = fCurrQuad + (fCurrQuad >> 1);

    if (fClip->isComplex()) {
        SkGLClipIter iter(fViewportHeight);
        iter.reset(*fClip);
        while (!iter.done()) {
            iter.scissor();
            glDrawElements(GL_TRIANGLES, count, GL_UNSIGNED_BYTE, gQuadIndices);
            iter.next();
        }
    } else {
        glDrawElements(GL_TRIANGLES, count, GL_UNSIGNED_BYTE, gQuadIndices);
    }
}
Exemplo n.º 2
0
static void toString(const SkRegion& rgn, SkString* str) {
    str->append("Region:[");
    toString(rgn.getBounds(), str);
    str->append("]");
    if (rgn.isComplex()) {
        str->append(".complex");
    }
}
static void Surface_setTransparentRegion(
        JNIEnv* env, jobject clazz, jobject argRegion)
{
    const sp<SurfaceControl>& surface(getSurfaceControl(env, clazz));
    if (surface == 0) return;
    SkRegion* nativeRegion = (SkRegion*)env->GetIntField(argRegion, no.native_region);

    const SkIRect& b(nativeRegion->getBounds());
    Region reg(Rect(b.fLeft, b.fTop, b.fRight, b.fBottom));
    if (nativeRegion->isComplex()) {
        SkRegion::Iterator it(*nativeRegion);
        while (!it.done()) {
            const SkIRect& r(it.rect());
            reg.addRectUnchecked(r.fLeft, r.fTop, r.fRight, r.fBottom);
            it.next();
        }
    }

    status_t err = surface->setTransparentRegionHint(reg);
    if (err<0 && err!=NO_INIT) {
        doThrowIAE(env);
    }
}
static void nativeSetTransparentRegionHint(JNIEnv* env, jclass clazz, jlong nativeObject, jobject regionObj) {
    SurfaceControl* const ctrl = reinterpret_cast<SurfaceControl *>(nativeObject);
    SkRegion* region = android_graphics_Region_getSkRegion(env, regionObj);
    if (!region) {
        doThrowIAE(env);
        return;
    }

    const SkIRect& b(region->getBounds());
    Region reg(Rect(b.fLeft, b.fTop, b.fRight, b.fBottom));
    if (region->isComplex()) {
        SkRegion::Iterator it(*region);
        while (!it.done()) {
            const SkIRect& r(it.rect());
            reg.addRectUnchecked(r.fLeft, r.fTop, r.fRight, r.fBottom);
            it.next();
        }
    }

    status_t err = ctrl->setTransparentRegionHint(reg);
    if (err < 0 && err != NO_INIT) {
        doThrowIAE(env);
    }
}