2011-01-11 14:29:25 -08:00
|
|
|
/*
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef ANDROID_HWUI_LAYER_RENDERER_H
|
|
|
|
#define ANDROID_HWUI_LAYER_RENDERER_H
|
|
|
|
|
2011-10-12 13:48:51 -07:00
|
|
|
#include <cutils/compiler.h>
|
|
|
|
|
2011-01-11 14:29:25 -08:00
|
|
|
#include "OpenGLRenderer.h"
|
2011-01-13 12:13:20 -08:00
|
|
|
#include "Layer.h"
|
2011-01-11 14:29:25 -08:00
|
|
|
|
2011-06-14 16:45:55 -07:00
|
|
|
#include <SkBitmap.h>
|
|
|
|
|
2011-01-11 14:29:25 -08:00
|
|
|
namespace android {
|
|
|
|
namespace uirenderer {
|
|
|
|
|
2014-06-23 13:13:08 -07:00
|
|
|
class RenderState;
|
|
|
|
|
2011-01-12 14:30:59 -08:00
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Defines
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
// Debug
|
|
|
|
#if DEBUG_LAYER_RENDERER
|
2011-12-20 16:23:08 +00:00
|
|
|
#define LAYER_RENDERER_LOGD(...) ALOGD(__VA_ARGS__)
|
2011-01-12 14:30:59 -08:00
|
|
|
#else
|
|
|
|
#define LAYER_RENDERER_LOGD(...)
|
|
|
|
#endif
|
|
|
|
|
2011-01-11 14:29:25 -08:00
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Renderer
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
class LayerRenderer: public OpenGLRenderer {
|
|
|
|
public:
|
2014-06-23 13:13:08 -07:00
|
|
|
LayerRenderer(RenderState& renderState, Layer* layer);
|
2011-10-12 13:48:51 -07:00
|
|
|
virtual ~LayerRenderer();
|
2011-01-11 14:29:25 -08:00
|
|
|
|
2015-01-05 15:51:13 -08:00
|
|
|
virtual void onViewportInitialized() override { /* do nothing */ }
|
|
|
|
virtual void prepareDirty(float left, float top, float right, float bottom,
|
|
|
|
bool opaque) override;
|
|
|
|
virtual void clear(float left, float top, float right, float bottom, bool opaque) override;
|
|
|
|
virtual bool finish() override;
|
2011-01-11 14:29:25 -08:00
|
|
|
|
2014-06-23 13:13:08 -07:00
|
|
|
static Layer* createTextureLayer(RenderState& renderState);
|
|
|
|
static Layer* createRenderLayer(RenderState& renderState, uint32_t width, uint32_t height);
|
|
|
|
static bool resizeLayer(Layer* layer, uint32_t width, uint32_t height);
|
|
|
|
static void updateTextureLayer(Layer* layer, uint32_t width, uint32_t height,
|
2014-02-25 18:50:17 -08:00
|
|
|
bool isOpaque, bool forceFilter, GLenum renderTarget, float* textureTransform);
|
2014-06-23 13:13:08 -07:00
|
|
|
static void destroyLayer(Layer* layer);
|
|
|
|
static bool copyLayer(RenderState& renderState, Layer* layer, SkBitmap* bitmap);
|
2011-01-11 14:29:25 -08:00
|
|
|
|
2014-06-23 13:13:08 -07:00
|
|
|
static void flushLayer(RenderState& renderState, Layer* layer);
|
2012-09-26 10:27:40 -07:00
|
|
|
|
2012-09-21 00:39:43 -07:00
|
|
|
protected:
|
2015-01-05 15:51:13 -08:00
|
|
|
virtual void ensureStencilBuffer() override;
|
|
|
|
virtual bool hasLayer() const override;
|
|
|
|
virtual Region* getRegion() const override;
|
|
|
|
virtual GLuint onGetTargetFbo() const override;
|
|
|
|
virtual bool suppressErrorChecks() const override;
|
2012-09-21 00:39:43 -07:00
|
|
|
|
2011-01-11 14:29:25 -08:00
|
|
|
private:
|
2011-01-16 12:54:25 -08:00
|
|
|
void generateMesh();
|
|
|
|
|
2011-01-13 12:13:20 -08:00
|
|
|
Layer* mLayer;
|
2011-01-11 14:29:25 -08:00
|
|
|
}; // class LayerRenderer
|
|
|
|
|
|
|
|
}; // namespace uirenderer
|
|
|
|
}; // namespace android
|
|
|
|
|
|
|
|
#endif // ANDROID_HWUI_LAYER_RENDERER_H
|