#include <SkXfermode.h>
#include <DeferredLayerUpdater.h>
-#include <LayerRenderer.h>
#include <SkiaShader.h>
#include <Rect.h>
#include <RenderNode.h>
JankTracker.cpp \
Layer.cpp \
LayerBuilder.cpp \
- LayerRenderer.cpp \
LayerUpdateQueue.cpp \
Matrix.cpp \
OpDumper.cpp \
tests/unit/CanvasStateTests.cpp \
tests/unit/ClipAreaTests.cpp \
tests/unit/DamageAccumulatorTests.cpp \
+ tests/unit/DeferredLayerUpdaterTests.cpp \
tests/unit/DeviceInfoTests.cpp \
tests/unit/FatVectorTests.cpp \
tests/unit/FontRendererTests.cpp \
#include "Caches.h"
#include "GammaFontRenderer.h"
-#include "LayerRenderer.h"
+#include "Layer.h"
#include "Properties.h"
#include "renderstate/RenderState.h"
#include "ShadowTessellator.h"
*/
#include "DeferredLayerUpdater.h"
-#include "LayerRenderer.h"
#include "renderthread/EglManager.h"
#include "renderthread/RenderTask.h"
#include "utils/PaintUtils.h"
, mNeedsGLContextAttach(false)
, mUpdateTexImage(false)
, mLayer(layer) {
- mWidth = mLayer->layer.getWidth();
- mHeight = mLayer->layer.getHeight();
+ mWidth = mLayer->getWidth();
+ mHeight = mLayer->getHeight();
mBlend = mLayer->isBlend();
mColorFilter = SkSafeRef(mLayer->getColorFilter());
mAlpha = mLayer->getAlpha();
LOG_ALWAYS_FATAL_IF(renderTarget != GL_TEXTURE_2D && renderTarget != GL_TEXTURE_EXTERNAL_OES,
"doUpdateTexImage target %x, 2d %x, EXT %x",
renderTarget, GL_TEXTURE_2D, GL_TEXTURE_EXTERNAL_OES);
- LayerRenderer::updateTextureLayer(mLayer, mWidth, mHeight,
- !mBlend, forceFilter, renderTarget, transform);
+ updateLayer(forceFilter, renderTarget, transform);
+ }
+}
+
+void DeferredLayerUpdater::updateLayer(bool forceFilter, GLenum renderTarget,
+ const float* textureTransform) {
+ mLayer->setBlend(mBlend);
+ mLayer->setForceFilter(forceFilter);
+ mLayer->setSize(mWidth, mHeight);
+ mLayer->getTexTransform().load(textureTransform);
+
+ if (renderTarget != mLayer->getRenderTarget()) {
+ mLayer->setRenderTarget(renderTarget);
+ mLayer->bindTexture();
+ mLayer->setFilter(GL_NEAREST, false, true);
+ mLayer->setWrap(GL_CLAMP_TO_EDGE, false, true);
}
}
void detachSurfaceTexture();
+ void updateLayer(bool forceFilter, GLenum renderTarget, const float* textureTransform);
+
private:
// Generic properties
int mWidth;
// TODO: This is a violation of Android's typical ref counting, but it
// preserves the old inc/dec ref locations. This should be changed...
incStrong(nullptr);
- renderTarget = GL_TEXTURE_2D;
+ renderTarget = GL_NONE; // see DeferredLayerUpdater::updateLayer()
texture.mWidth = layerWidth;
texture.mHeight = layerHeight;
renderState.registerLayer(this);
*/
void onGlContextLost();
- /**
- * Bounds of the layer.
- */
- Rect layer;
- /**
- * Texture coordinates of the layer.
- */
- Rect texCoords;
- /**
- * Clipping rectangle.
- */
- Rect clipRect;
-
private:
Caches& caches;
+++ /dev/null
-/*
- * Copyright (C) 2011 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 "LayerRenderer.h"
-#include "Matrix.h"
-#include "Properties.h"
-#include "Rect.h"
-#include "renderstate/RenderState.h"
-#include "utils/GLUtils.h"
-#include "utils/TraceUtils.h"
-
-#include <ui/Rect.h>
-
-#include <private/hwui/DrawGlInfo.h>
-
-namespace android {
-namespace uirenderer {
-
-Layer* LayerRenderer::createTextureLayer(RenderState& renderState) {
- LAYER_RENDERER_LOGD("Creating new texture layer");
-
- Layer* layer = new Layer(renderState, 0, 0);
- layer->layer.set(0.0f, 0.0f, 0.0f, 0.0f);
- layer->texCoords.set(0.0f, 1.0f, 1.0f, 0.0f);
- layer->setRenderTarget(GL_NONE); // see ::updateTextureLayer()
-
- Caches::getInstance().textureState().activateTexture(0);
- layer->generateTexture();
-
- return layer;
-}
-
-void LayerRenderer::updateTextureLayer(Layer* layer, uint32_t width, uint32_t height,
- bool isOpaque, bool forceFilter, GLenum renderTarget, const float* textureTransform) {
- layer->setBlend(!isOpaque);
- layer->setForceFilter(forceFilter);
- layer->setSize(width, height);
- layer->layer.set(0.0f, 0.0f, width, height);
- layer->getTexTransform().load(textureTransform);
-
- if (renderTarget != layer->getRenderTarget()) {
- layer->setRenderTarget(renderTarget);
- layer->bindTexture();
- layer->setFilter(GL_NEAREST, false, true);
- layer->setWrap(GL_CLAMP_TO_EDGE, false, true);
- }
-}
-
-}; // namespace uirenderer
-}; // namespace android
+++ /dev/null
-/*
- * Copyright (C) 2011 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.
- */
-
-#pragma once
-
-#include <cutils/compiler.h>
-
-#include "Layer.h"
-
-#include <SkBitmap.h>
-
-namespace android {
-namespace uirenderer {
-
-class RenderState;
-
-///////////////////////////////////////////////////////////////////////////////
-// Defines
-///////////////////////////////////////////////////////////////////////////////
-
-// Debug
-#if DEBUG_LAYER_RENDERER
- #define LAYER_RENDERER_LOGD(...) ALOGD(__VA_ARGS__)
-#else
- #define LAYER_RENDERER_LOGD(...)
-#endif
-
-///////////////////////////////////////////////////////////////////////////////
-// Renderer
-///////////////////////////////////////////////////////////////////////////////
-
-class LayerRenderer {
-public:
- static Layer* createTextureLayer(RenderState& renderState);
- static void updateTextureLayer(Layer* layer, uint32_t width, uint32_t height,
- bool isOpaque, bool forceFilter, GLenum renderTarget, const float* textureTransform);
-}; // class LayerRenderer
-
-}; // namespace uirenderer
-}; // namespace android
#include "BakedOpRenderer.h"
#include "DamageAccumulator.h"
#include "Debug.h"
-#include "LayerRenderer.h"
#include "OpDumper.h"
#include "RecordedOp.h"
#include "TreeInfo.h"
#include "Caches.h"
#include "DeferredLayerUpdater.h"
#include "EglManager.h"
-#include "LayerRenderer.h"
#include "LayerUpdateQueue.h"
#include "Properties.h"
#include "Readback.h"
}
}
-Layer* CanvasContext::createTextureLayer() {
+DeferredLayerUpdater* CanvasContext::createTextureLayer() {
return mRenderPipeline->createTextureLayer();
}
static void invokeFunctor(RenderThread& thread, Functor* functor);
- Layer* createTextureLayer();
+ DeferredLayerUpdater* createTextureLayer();
ANDROID_API static void setTextureAtlas(RenderThread& thread,
const sp<GraphicBuffer>& buffer, int64_t* map, size_t mapSize);
virtual bool swapBuffers(const Frame& frame, bool drew, const SkRect& screenDirty,
FrameInfo* currentFrameInfo, bool* requireSwap) = 0;
virtual bool copyLayerInto(DeferredLayerUpdater* layer, SkBitmap* bitmap) = 0;
- virtual Layer* createTextureLayer() = 0;
+ virtual DeferredLayerUpdater* createTextureLayer() = 0;
virtual bool setSurface(Surface* window, SwapBehavior swapBehavior) = 0;
virtual void onStop() = 0;
virtual bool isSurfaceReady() = 0;
#include "DeferredLayerUpdater.h"
#include "EglManager.h"
-#include "LayerRenderer.h"
#include "renderstate/RenderState.h"
#include "Readback.h"
== CopyResult::Success;
}
-Layer* OpenGLPipeline::createTextureLayer() {
+DeferredLayerUpdater* OpenGLPipeline::createTextureLayer() {
mEglManager.initialize();
- return LayerRenderer::createTextureLayer(mRenderThread.renderState());
+ Layer* layer = new Layer(mRenderThread.renderState(), 0, 0);
+ Caches::getInstance().textureState().activateTexture(0);
+ layer->generateTexture();
+
+ return new DeferredLayerUpdater(layer);
}
void OpenGLPipeline::onStop() {
bool swapBuffers(const Frame& frame, bool drew, const SkRect& screenDirty,
FrameInfo* currentFrameInfo, bool* requireSwap) override;
bool copyLayerInto(DeferredLayerUpdater* layer, SkBitmap* bitmap) override;
- Layer* createTextureLayer() override;
+ DeferredLayerUpdater* createTextureLayer() override;
bool setSurface(Surface* window, SwapBehavior swapBehavior) override;
void onStop() override;
bool isSurfaceReady() override;
#include "DeferredLayerUpdater.h"
#include "DisplayList.h"
-#include "LayerRenderer.h"
#include "Readback.h"
#include "Rect.h"
#include "renderthread/CanvasContext.h"
}
CREATE_BRIDGE1(createTextureLayer, CanvasContext* context) {
- Layer* layer = args->context->createTextureLayer();
- if (!layer) return nullptr;
- return new DeferredLayerUpdater(layer);
+ return args->context->createTextureLayer();
}
DeferredLayerUpdater* RenderProxy::createTextureLayer() {
#include "hwui/Paint.h"
#include "DeferredLayerUpdater.h"
-#include "LayerRenderer.h"
#include <renderthread/EglManager.h>
+#include <renderthread/OpenGLPipeline.h>
#include <utils/Unicode.h>
namespace android {
sp<DeferredLayerUpdater> TestUtils::createTextureLayerUpdater(
renderthread::RenderThread& renderThread, uint32_t width, uint32_t height,
const SkMatrix& transform) {
- Layer* layer = LayerRenderer::createTextureLayer(renderThread.renderState());
- layer->getTransform().load(transform);
-
- sp<DeferredLayerUpdater> layerUpdater = new DeferredLayerUpdater(layer);
+ renderthread::OpenGLPipeline pipeline(renderThread);
+ sp<DeferredLayerUpdater> layerUpdater = pipeline.createTextureLayer();
+ layerUpdater->backingLayer()->getTransform().load(transform);
layerUpdater->setSize(width, height);
layerUpdater->setTransform(&transform);
// updateLayer so it's ready to draw
- bool isOpaque = true;
- bool forceFilter = true;
- GLenum renderTarget = GL_TEXTURE_EXTERNAL_OES;
- LayerRenderer::updateTextureLayer(layer, width, height, isOpaque, forceFilter,
- renderTarget, Matrix4::identity().data);
-
+ layerUpdater->updateLayer(true, GL_TEXTURE_EXTERNAL_OES, Matrix4::identity().data);
return layerUpdater;
}
void TestUtils::TestTask::run() {
// RenderState only valid once RenderThread is running, so queried here
renderthread::RenderThread& renderThread = renderthread::RenderThread::getInstance();
- bool hasEglContext = renderThread.eglManager().hasEglContext();
- RenderState& renderState = renderThread.renderState();
- if (!hasEglContext) {
- renderState.onGLContextCreated();
- }
+ renderThread.eglManager().initialize();
rtCallback(renderThread);
- if (!hasEglContext) {
- renderState.flush(Caches::FlushMode::Full);
- renderState.onGLContextDestroyed();
- }
+
+ renderThread.renderState().flush(Caches::FlushMode::Full);
+ renderThread.eglManager().destroy();
}
std::unique_ptr<uint16_t[]> TestUtils::asciiToUtf16(const char* str) {
--- /dev/null
+/*
+ * Copyright (C) 2016 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 "DeferredLayerUpdater.h"
+
+#include "renderthread/OpenGLPipeline.h"
+#include "tests/common/TestUtils.h"
+
+#include <gtest/gtest.h>
+
+using namespace android;
+using namespace android::uirenderer;
+
+RENDERTHREAD_TEST(DeferredLayerUpdater, updateLayer) {
+ renderthread::OpenGLPipeline pipeline(renderThread);
+ sp<DeferredLayerUpdater> layerUpdater = pipeline.createTextureLayer();
+ layerUpdater->setSize(100, 100);
+ layerUpdater->setBlend(true);
+
+
+ // updates are deferred so the backing layer should still be in its default state
+ EXPECT_EQ((uint32_t)GL_NONE, layerUpdater->backingLayer()->getRenderTarget());
+ EXPECT_EQ(0u, layerUpdater->backingLayer()->getWidth());
+ EXPECT_EQ(0u, layerUpdater->backingLayer()->getHeight());
+ EXPECT_FALSE(layerUpdater->backingLayer()->getForceFilter());
+ EXPECT_FALSE(layerUpdater->backingLayer()->isBlend());
+ EXPECT_EQ(Matrix4::identity(), layerUpdater->backingLayer()->getTexTransform());
+
+ // push the deferred updates to the layer
+ Matrix4 scaledMatrix;
+ scaledMatrix.loadScale(0.5, 0.5, 0.0);
+ layerUpdater->updateLayer(true, GL_TEXTURE_EXTERNAL_OES, scaledMatrix.data);
+
+ // the backing layer should now have all the properties applied.
+ EXPECT_EQ((uint32_t)GL_TEXTURE_EXTERNAL_OES, layerUpdater->backingLayer()->getRenderTarget());
+ EXPECT_EQ(100u, layerUpdater->backingLayer()->getWidth());
+ EXPECT_EQ(100u, layerUpdater->backingLayer()->getHeight());
+ EXPECT_TRUE(layerUpdater->backingLayer()->getForceFilter());
+ EXPECT_TRUE(layerUpdater->backingLayer()->isBlend());
+ EXPECT_EQ(scaledMatrix, layerUpdater->backingLayer()->getTexTransform());
+}
}
RENDERTHREAD_TEST(RenderNode, prepareTree_nullableDisplayList) {
+ auto rootNode = TestUtils::createNode(0, 0, 200, 400, nullptr);
ContextFactory contextFactory;
std::unique_ptr<CanvasContext> canvasContext(CanvasContext::create(
- renderThread, false, nullptr, &contextFactory));
+ renderThread, false, rootNode.get(), &contextFactory));
TreeInfo info(TreeInfo::MODE_RT_ONLY, *canvasContext.get());
DamageAccumulator damageAccumulator;
info.damageAccumulator = &damageAccumulator;