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

Commit e2d345ea authored by Romain Guy's avatar Romain Guy
Browse files

Add debug mode to measure performance.

Change-Id: I9d4c84034dc200b99c8266165942a7cdbcb5c0c5
parent 9a40babc
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -30,6 +30,7 @@
#include <SkTemplates.h>
#include <SkXfermode.h>

#include <OpenGLDebugRenderer.h>
#include <OpenGLRenderer.h>
#include <SkiaShader.h>
#include <SkiaColorFilter.h>
@@ -48,6 +49,8 @@ using namespace uirenderer;
 */
#ifdef USE_OPENGL_RENDERER

#define DEBUG_RENDERER 0

// ----------------------------------------------------------------------------
// Java APIs
// ----------------------------------------------------------------------------
@@ -62,7 +65,11 @@ static struct {
// ----------------------------------------------------------------------------

static OpenGLRenderer* android_view_GLES20Canvas_createRenderer(JNIEnv* env, jobject canvas) {
#if DEBUG_RENDERER
    return new OpenGLDebugRenderer;
#else
    return new OpenGLRenderer;
#endif
}

static void android_view_GLES20Canvas_destroyRenderer(JNIEnv* env, jobject canvas,
+2 −0
Original line number Diff line number Diff line
@@ -5,11 +5,13 @@ include $(CLEAR_VARS)
# defined in the current device/board configuration
ifeq ($(USE_OPENGL_RENDERER),true)
	LOCAL_SRC_FILES:= \
		FboCache.cpp \
		FontRenderer.cpp \
		GammaFontRenderer.cpp \
		GradientCache.cpp \
		LayerCache.cpp \
		Matrix.cpp \
		OpenGLDebugRenderer.cpp \
		OpenGLRenderer.cpp \
		Patch.cpp \
		PatchCache.cpp \
+2 −0
Original line number Diff line number Diff line
@@ -31,6 +31,7 @@
#include "ProgramCache.h"
#include "PathCache.h"
#include "TextDropShadowCache.h"
#include "FboCache.h"
#include "Line.h"

namespace android {
@@ -65,6 +66,7 @@ public:
    PatchCache patchCache;
    TextDropShadowCache dropShadowCache;
    GammaFontRenderer fontRenderer;
    FboCache fboCache;

    Line line;
}; // class Caches

libs/hwui/FboCache.cpp

0 → 100644
+72 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2010 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#define LOG_TAG "OpenGLRenderer"

#include "FboCache.h"
#include "Properties.h"

namespace android {
namespace uirenderer {

///////////////////////////////////////////////////////////////////////////////
// Constructors/destructor
///////////////////////////////////////////////////////////////////////////////

FboCache::FboCache(): mMaxSize(DEFAULT_FBO_CACHE_SIZE) {
    char property[PROPERTY_VALUE_MAX];
    if (property_get(PROPERTY_FBO_CACHE_SIZE, property, NULL) > 0) {
        LOGD("  Setting fbo cache size to %s", property);
        mMaxSize = atoi(property);
    } else {
        LOGD("  Using default fbo cache size of %d", DEFAULT_FBO_CACHE_SIZE);
    }
}

FboCache::~FboCache() {
    clear();
}

///////////////////////////////////////////////////////////////////////////////
// Size management
///////////////////////////////////////////////////////////////////////////////

uint32_t FboCache::getSize() {
    return mCache.size();
}

uint32_t FboCache::getMaxSize() {
    return mMaxSize;
}

///////////////////////////////////////////////////////////////////////////////
// Caching
///////////////////////////////////////////////////////////////////////////////

void FboCache::clear() {

}

GLuint FboCache::get() {
    return 0;
}

bool FboCache::put(GLuint fbo) {
    return false;
}

}; // namespace uirenderer
}; // namespace android

libs/hwui/FboCache.h

0 → 100644
+81 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2010 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#ifndef ANDROID_UI_FBO_CACHE_H
#define ANDROID_UI_FBO_CACHE_H

#include <GLES2/gl2.h>

#include <utils/SortedVector.h>

#include "GenerationCache.h"

namespace android {
namespace uirenderer {

///////////////////////////////////////////////////////////////////////////////
// Cache
///////////////////////////////////////////////////////////////////////////////

class FboCache {
public:
    FboCache();
    ~FboCache();

    /**
     * Returns an FBO from the cache. If no FBO is available, a new one
     * is created. If creating a new FBO fails, 0 is returned.
     *
     * When an FBO is obtained from the cache, it is removed and the
     * total number of FBOs available in the cache decreases.
     *
     * @return The name of the FBO, or 0 if no FBO can be obtained.
     */
    GLuint get();

    /**
     * Adds the specified FBO to the cache.
     *
     * @param fbo The FBO to add to the cache.
     *
     * @return True if the FBO was added, false otherwise.
     */
    bool put(GLuint fbo);

    /**
     * Clears the cache. This causes all FBOs to be deleted.
     */
    void clear();

    /**
     * Returns the current size of the cache.
     */
    uint32_t getSize();

    /**
     * Returns the maximum number of FBOs that the cache can hold.
     */
    uint32_t getMaxSize();

private:
    SortedVector<GLuint> mCache;
    uint32_t mMaxSize;
}; // class FboCache

}; // namespace uirenderer
}; // namespace android

#endif // ANDROID_UI_FBO_CACHE_H
Loading