Loading libs/renderengine/Android.bp +4 −0 Original line number Diff line number Diff line Loading @@ -81,6 +81,9 @@ filegroup { "skia/AutoBackendTexture.cpp", "skia/SkiaRenderEngine.cpp", "skia/SkiaGLRenderEngine.cpp", "skia/debug/CaptureTimer.cpp", "skia/debug/CommonPool.cpp", "skia/debug/SkiaCapture.cpp", "skia/filters/BlurFilter.cpp", "skia/filters/LinearEffect.cpp", ], Loading @@ -94,6 +97,7 @@ cc_library_static { cflags: [ "-fvisibility=hidden", "-Werror=format", "-Wno-unused-parameter", ], srcs: [ ":librenderengine_sources", Loading libs/renderengine/include/renderengine/RenderEngine.h +8 −1 Original line number Diff line number Diff line Loading @@ -31,10 +31,17 @@ #include <ui/Transform.h> /** * Allows to set RenderEngine backend to GLES (default) or Vulkan (NOT yet supported). * Allows to set RenderEngine backend to GLES (default) or SkiaGL (NOT yet supported). */ #define PROPERTY_DEBUG_RENDERENGINE_BACKEND "debug.renderengine.backend" /** * Turns on recording of skia commands in SkiaGL version of the RE. This property * defines number of milliseconds for the recording to take place. A non zero value * turns on the recording. */ #define PROPERTY_DEBUG_RENDERENGINE_CAPTURE_SKIA_MS "debug.renderengine.capture_skia_ms" struct ANativeWindowBuffer; namespace android { Loading libs/renderengine/skia/SkiaGLRenderEngine.cpp +9 −14 Original line number Diff line number Diff line Loading @@ -15,19 +15,19 @@ */ //#define LOG_NDEBUG 0 #undef LOG_TAG #define LOG_TAG "RenderEngine" #define ATRACE_TAG ATRACE_TAG_GRAPHICS #include <cstdint> #include <memory> #include "SkImageInfo.h" #include "log/log_main.h" #include "system/graphics-base-v1.0.h" #undef LOG_TAG #define LOG_TAG "RenderEngine" #define ATRACE_TAG ATRACE_TAG_GRAPHICS #include <EGL/egl.h> #include <EGL/eglext.h> #include <GLES2/gl2.h> #include <sync/sync.h> #include <ui/BlurRegion.h> #include <ui/GraphicBuffer.h> Loading @@ -35,6 +35,8 @@ #include "../gl/GLExtensions.h" #include "SkiaGLRenderEngine.h" #include "filters/BlurFilter.h" #include "filters/LinearEffect.h" #include "skia/debug/SkiaCapture.h" #include <GrContextOptions.h> #include <SkCanvas.h> Loading @@ -46,17 +48,9 @@ #include <SkShadowUtils.h> #include <SkSurface.h> #include <gl/GrGLInterface.h> #include <sync/sync.h> #include <ui/GraphicBuffer.h> #include <utils/Trace.h> #include <cmath> #include "../gl/GLExtensions.h" #include "SkiaGLRenderEngine.h" #include "filters/BlurFilter.h" #include "filters/LinearEffect.h" bool checkGlError(const char* op, int lineNumber); namespace android { Loading Loading @@ -482,7 +476,7 @@ status_t SkiaGLRenderEngine::drawLayers(const DisplaySettings& display, : ui::Dataspace::SRGB, mGrContext.get()); auto canvas = surface->getCanvas(); SkCanvas* canvas = mCapture.tryCapture(surface.get()); // Clear the entire canvas with a transparent black to prevent ghost images. canvas->clear(SK_ColorTRANSPARENT); canvas->save(); Loading Loading @@ -663,11 +657,12 @@ status_t SkiaGLRenderEngine::drawLayers(const DisplaySettings& display, canvas->restore(); } canvas->restore(); mCapture.endCapture(); { ATRACE_NAME("flush surface"); surface->flush(); } canvas->restore(); if (drawFence != nullptr) { *drawFence = flush(); Loading libs/renderengine/skia/SkiaGLRenderEngine.h +3 −0 Original line number Diff line number Diff line Loading @@ -35,6 +35,7 @@ #include "SkiaRenderEngine.h" #include "android-base/macros.h" #include "filters/BlurFilter.h" #include "skia/debug/SkiaCapture.h" #include "skia/filters/LinearEffect.h" namespace android { Loading Loading @@ -116,6 +117,8 @@ private: sk_sp<GrDirectContext> mProtectedGrContext; bool mInProtectedContext = false; // Object to capture commands send to Skia. SkiaCapture mCapture; }; } // namespace skia Loading libs/renderengine/skia/debug/CaptureTimer.cpp 0 → 100644 +47 −0 Original line number Diff line number Diff line /* * Copyright 2020 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. */ #include "CaptureTimer.h" #undef LOG_TAG #define LOG_TAG "RenderEngine" #define ATRACE_TAG ATRACE_TAG_GRAPHICS #include "CommonPool.h" #include <thread> namespace android { namespace renderengine { namespace skia { void CaptureTimer::setTimeout(TimeoutCallback function, std::chrono::milliseconds delay) { this->clear = false; CommonPool::post([=]() { if (this->clear) return; std::this_thread::sleep_for(delay); if (this->clear) return; function(); }); } void CaptureTimer::stop() { this->clear = true; } } // namespace skia } // namespace renderengine } // namespace android No newline at end of file Loading
libs/renderengine/Android.bp +4 −0 Original line number Diff line number Diff line Loading @@ -81,6 +81,9 @@ filegroup { "skia/AutoBackendTexture.cpp", "skia/SkiaRenderEngine.cpp", "skia/SkiaGLRenderEngine.cpp", "skia/debug/CaptureTimer.cpp", "skia/debug/CommonPool.cpp", "skia/debug/SkiaCapture.cpp", "skia/filters/BlurFilter.cpp", "skia/filters/LinearEffect.cpp", ], Loading @@ -94,6 +97,7 @@ cc_library_static { cflags: [ "-fvisibility=hidden", "-Werror=format", "-Wno-unused-parameter", ], srcs: [ ":librenderengine_sources", Loading
libs/renderengine/include/renderengine/RenderEngine.h +8 −1 Original line number Diff line number Diff line Loading @@ -31,10 +31,17 @@ #include <ui/Transform.h> /** * Allows to set RenderEngine backend to GLES (default) or Vulkan (NOT yet supported). * Allows to set RenderEngine backend to GLES (default) or SkiaGL (NOT yet supported). */ #define PROPERTY_DEBUG_RENDERENGINE_BACKEND "debug.renderengine.backend" /** * Turns on recording of skia commands in SkiaGL version of the RE. This property * defines number of milliseconds for the recording to take place. A non zero value * turns on the recording. */ #define PROPERTY_DEBUG_RENDERENGINE_CAPTURE_SKIA_MS "debug.renderengine.capture_skia_ms" struct ANativeWindowBuffer; namespace android { Loading
libs/renderengine/skia/SkiaGLRenderEngine.cpp +9 −14 Original line number Diff line number Diff line Loading @@ -15,19 +15,19 @@ */ //#define LOG_NDEBUG 0 #undef LOG_TAG #define LOG_TAG "RenderEngine" #define ATRACE_TAG ATRACE_TAG_GRAPHICS #include <cstdint> #include <memory> #include "SkImageInfo.h" #include "log/log_main.h" #include "system/graphics-base-v1.0.h" #undef LOG_TAG #define LOG_TAG "RenderEngine" #define ATRACE_TAG ATRACE_TAG_GRAPHICS #include <EGL/egl.h> #include <EGL/eglext.h> #include <GLES2/gl2.h> #include <sync/sync.h> #include <ui/BlurRegion.h> #include <ui/GraphicBuffer.h> Loading @@ -35,6 +35,8 @@ #include "../gl/GLExtensions.h" #include "SkiaGLRenderEngine.h" #include "filters/BlurFilter.h" #include "filters/LinearEffect.h" #include "skia/debug/SkiaCapture.h" #include <GrContextOptions.h> #include <SkCanvas.h> Loading @@ -46,17 +48,9 @@ #include <SkShadowUtils.h> #include <SkSurface.h> #include <gl/GrGLInterface.h> #include <sync/sync.h> #include <ui/GraphicBuffer.h> #include <utils/Trace.h> #include <cmath> #include "../gl/GLExtensions.h" #include "SkiaGLRenderEngine.h" #include "filters/BlurFilter.h" #include "filters/LinearEffect.h" bool checkGlError(const char* op, int lineNumber); namespace android { Loading Loading @@ -482,7 +476,7 @@ status_t SkiaGLRenderEngine::drawLayers(const DisplaySettings& display, : ui::Dataspace::SRGB, mGrContext.get()); auto canvas = surface->getCanvas(); SkCanvas* canvas = mCapture.tryCapture(surface.get()); // Clear the entire canvas with a transparent black to prevent ghost images. canvas->clear(SK_ColorTRANSPARENT); canvas->save(); Loading Loading @@ -663,11 +657,12 @@ status_t SkiaGLRenderEngine::drawLayers(const DisplaySettings& display, canvas->restore(); } canvas->restore(); mCapture.endCapture(); { ATRACE_NAME("flush surface"); surface->flush(); } canvas->restore(); if (drawFence != nullptr) { *drawFence = flush(); Loading
libs/renderengine/skia/SkiaGLRenderEngine.h +3 −0 Original line number Diff line number Diff line Loading @@ -35,6 +35,7 @@ #include "SkiaRenderEngine.h" #include "android-base/macros.h" #include "filters/BlurFilter.h" #include "skia/debug/SkiaCapture.h" #include "skia/filters/LinearEffect.h" namespace android { Loading Loading @@ -116,6 +117,8 @@ private: sk_sp<GrDirectContext> mProtectedGrContext; bool mInProtectedContext = false; // Object to capture commands send to Skia. SkiaCapture mCapture; }; } // namespace skia Loading
libs/renderengine/skia/debug/CaptureTimer.cpp 0 → 100644 +47 −0 Original line number Diff line number Diff line /* * Copyright 2020 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. */ #include "CaptureTimer.h" #undef LOG_TAG #define LOG_TAG "RenderEngine" #define ATRACE_TAG ATRACE_TAG_GRAPHICS #include "CommonPool.h" #include <thread> namespace android { namespace renderengine { namespace skia { void CaptureTimer::setTimeout(TimeoutCallback function, std::chrono::milliseconds delay) { this->clear = false; CommonPool::post([=]() { if (this->clear) return; std::this_thread::sleep_for(delay); if (this->clear) return; function(); }); } void CaptureTimer::stop() { this->clear = true; } } // namespace skia } // namespace renderengine } // namespace android No newline at end of file