Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b458942b authored by Chris Craik's avatar Chris Craik
Browse files

Create abstract base class for OpenGLRenderer

This will eventually serve as a base class to allow
DisplayListRenderer to split off from OpenGLRenderer, and could
eventually support other rendering approaches, such as an
SkCanvas/SkPicture.

This will also be the main source of (implementation-independent)
documentation of the canvas/renderer methods.

Change-Id: I52047f338f5cf86a3b0b3002af7154bff5c3c227
parent 6debfb90
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -443,7 +443,7 @@ static void android_view_GLES20Canvas_drawBitmapData(JNIEnv* env, jobject clazz,
    renderer->drawBitmapData(bitmap, left, top, paint);

    // If the renderer is a deferred renderer it will own the bitmap
    if (!renderer->isDeferred()) {
    if (!renderer->isRecording()) {
        delete bitmap;
    }
}
+1 −2
Original line number Diff line number Diff line
@@ -417,8 +417,7 @@ void DisplayList::setViewProperties(OpenGLRenderer& renderer, T& handler,
    }
    if (mMatrixFlags != 0) {
        if (mMatrixFlags == TRANSLATION) {
            renderer.translate(mTranslationX, mTranslationY);
            renderer.translateZ(mTranslationZ);
            renderer.translate(mTranslationX, mTranslationY, mTranslationZ);
        } else {
            if (Caches::getInstance().propertyEnable3d) {
                renderer.concatMatrix(mTransform);
+3 −6
Original line number Diff line number Diff line
@@ -116,10 +116,6 @@ DisplayList* DisplayListRenderer::getDisplayList(DisplayList* displayList) {
    return displayList;
}

bool DisplayListRenderer::isDeferred() {
    return true;
}

void DisplayListRenderer::setViewport(int width, int height) {
    // TODO: DisplayListRenderer shouldn't have a projection matrix, as it should never be used
    mViewProjMatrix.loadOrtho(0, width, height, 0, -1, 1);
@@ -188,12 +184,13 @@ int DisplayListRenderer::saveLayer(float left, float top, float right, float bot
    return OpenGLRenderer::save(flags);
}

void DisplayListRenderer::translate(float dx, float dy) {
void DisplayListRenderer::translate(float dx, float dy, float dz) {
    // ignore dz, not used at defer time
    mHasTranslate = true;
    mTranslateX += dx;
    mTranslateY += dy;
    insertRestoreToCount();
    OpenGLRenderer::translate(dx, dy);
    OpenGLRenderer::translate(dx, dy, dz);
}

void DisplayListRenderer::rotate(float degrees) {
+2 −2
Original line number Diff line number Diff line
@@ -63,7 +63,7 @@ public:

    ANDROID_API DisplayList* getDisplayList(DisplayList* displayList);

    virtual bool isDeferred();
    virtual bool isRecording() { return true; }

    virtual void setViewport(int width, int height);
    virtual status_t prepareDirty(float left, float top, float right, float bottom, bool opaque);
@@ -81,7 +81,7 @@ public:
    virtual int saveLayer(float left, float top, float right, float bottom,
            int alpha, SkXfermode::Mode mode, int flags);

    virtual void translate(float dx, float dy);
    virtual void translate(float dx, float dy, float dz);
    virtual void rotate(float degrees);
    virtual void scale(float sx, float sy);
    virtual void skew(float sx, float sy);
+6 −22
Original line number Diff line number Diff line
@@ -156,22 +156,6 @@ void OpenGLRenderer::initProperties() {
// Setup
///////////////////////////////////////////////////////////////////////////////

void OpenGLRenderer::setName(const char* name) {
    if (name) {
        mName.setTo(name);
    } else {
        mName.clear();
    }
}

const char* OpenGLRenderer::getName() const {
    return mName.string();
}

bool OpenGLRenderer::isDeferred() {
    return false;
}

void OpenGLRenderer::setViewport(int width, int height) {
    initViewport(width, height);

@@ -1524,8 +1508,8 @@ void OpenGLRenderer::setupMergedMultiDraw(const Rect* clipRect) {
// Transforms
///////////////////////////////////////////////////////////////////////////////

void OpenGLRenderer::translate(float dx, float dy) {
    currentTransform().translate(dx, dy);
void OpenGLRenderer::translate(float dx, float dy, float dz) {
    currentTransform().translate(dx, dy, dz);
}

void OpenGLRenderer::rotate(float degrees) {
@@ -1552,7 +1536,7 @@ bool OpenGLRenderer::hasRectToRectTransform() {
    return CC_LIKELY(currentTransform().rectToRect());
}

void OpenGLRenderer::getMatrix(SkMatrix* matrix) {
void OpenGLRenderer::getMatrix(SkMatrix* matrix) const {
    currentTransform().copyTo(*matrix);
}

@@ -1642,7 +1626,7 @@ void OpenGLRenderer::setStencilFromClip() {
    }
}

const Rect& OpenGLRenderer::getClipBounds() {
const Rect& OpenGLRenderer::getClipBounds() const {
    return mSnapshot->getLocalClip();
}

@@ -1728,7 +1712,7 @@ bool OpenGLRenderer::quickRejectSetupScissor(float left, float top, float right,
        return true;
    }

    if (!isDeferred()) {
    if (!isRecording()) {
        // not quick rejected, so enable the scissor if clipRequired
        mCaches.setScissorEnabled(mScissorOptimizationDisabled || clipRequired);
    }
@@ -1737,7 +1721,7 @@ bool OpenGLRenderer::quickRejectSetupScissor(float left, float top, float right,

void OpenGLRenderer::debugClip() {
#if DEBUG_CLIP_REGIONS
    if (!isDeferred() && !mSnapshot->clipRegion->isEmpty()) {
    if (!isRecording() && !mSnapshot->clipRegion->isEmpty()) {
        drawRegionRects(*mSnapshot->clipRegion, 0x7f00ff00, SkXfermode::kSrcOver_Mode);
    }
#endif
Loading