diff options
author | Chris Craik <ccraik@google.com> | 2015-02-26 00:07:21 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2015-02-26 00:08:12 +0000 |
commit | ddd30928a7d8f410d7d13d5706da44ba20bac440 (patch) | |
tree | eafe0e3632f1d5a01942d5338d61d99f4bfa94f0 /libs | |
parent | 1a83127881e8130e16041f9bfd098224b6ed9b86 (diff) | |
parent | 03ae272459869b854e5db252fc81a64a516e111f (diff) | |
download | frameworks_base-ddd30928a7d8f410d7d13d5706da44ba20bac440.zip frameworks_base-ddd30928a7d8f410d7d13d5706da44ba20bac440.tar.gz frameworks_base-ddd30928a7d8f410d7d13d5706da44ba20bac440.tar.bz2 |
Merge "Remove renderer abstract class"
Diffstat (limited to 'libs')
-rw-r--r-- | libs/hwui/DisplayListOp.h | 2 | ||||
-rw-r--r-- | libs/hwui/DisplayListRenderer.h | 1 | ||||
-rw-r--r-- | libs/hwui/OpenGLRenderer.cpp | 6 | ||||
-rwxr-xr-x | libs/hwui/OpenGLRenderer.h | 178 | ||||
-rw-r--r-- | libs/hwui/Renderer.h | 198 |
5 files changed, 112 insertions, 273 deletions
diff --git a/libs/hwui/DisplayListOp.h b/libs/hwui/DisplayListOp.h index 00942d7..dba5121 100644 --- a/libs/hwui/DisplayListOp.h +++ b/libs/hwui/DisplayListOp.h @@ -1340,7 +1340,7 @@ public: const Vector<OpStatePair>& ops, const Rect& bounds) override { for (unsigned int i = 0; i < ops.size(); i++) { const DeferredDisplayState& state = *(ops[i].state); - DrawOpMode drawOpMode = (i == ops.size() - 1) ? kDrawOpMode_Flush : kDrawOpMode_Defer; + DrawOpMode drawOpMode = (i == ops.size() - 1) ? DrawOpMode::kFlush : DrawOpMode::kDefer; renderer.restoreDisplayState(state, true); // restore all but the clip DrawTextOp& op = *((DrawTextOp*)ops[i].op); diff --git a/libs/hwui/DisplayListRenderer.h b/libs/hwui/DisplayListRenderer.h index bd0b3b7..8d519bb 100644 --- a/libs/hwui/DisplayListRenderer.h +++ b/libs/hwui/DisplayListRenderer.h @@ -30,7 +30,6 @@ #include "DisplayList.h" #include "SkiaCanvasProxy.h" #include "RenderNode.h" -#include "Renderer.h" #include "ResourceCache.h" namespace android { diff --git a/libs/hwui/OpenGLRenderer.cpp b/libs/hwui/OpenGLRenderer.cpp index 161da87e..2bca9fa 100644 --- a/libs/hwui/OpenGLRenderer.cpp +++ b/libs/hwui/OpenGLRenderer.cpp @@ -2874,7 +2874,7 @@ void OpenGLRenderer::drawText(const char* text, int bytesCount, int count, float const float* positions, const SkPaint* paint, float totalAdvance, const Rect& bounds, DrawOpMode drawOpMode) { - if (drawOpMode == kDrawOpMode_Immediate) { + if (drawOpMode == DrawOpMode::kImmediate) { // The checks for corner-case ignorable text and quick rejection is only done for immediate // drawing as ops from DeferredDisplayList are already filtered for these if (text == nullptr || count == 0 || mState.currentlyIgnored() || canSkipText(paint) || @@ -2934,7 +2934,7 @@ void OpenGLRenderer::drawText(const char* text, int bytesCount, int count, float TextSetupFunctor functor(this, x, y, pureTranslate, alpha, mode, paint); // don't call issuedrawcommand, do it at end of batch - bool forceFinish = (drawOpMode != kDrawOpMode_Defer); + bool forceFinish = (drawOpMode != DrawOpMode::kDefer); if (CC_UNLIKELY(paint->getTextAlign() != SkPaint::kLeft_Align)) { SkPaint paintCopy(*paint); paintCopy.setTextAlign(SkPaint::kLeft_Align); @@ -2945,7 +2945,7 @@ void OpenGLRenderer::drawText(const char* text, int bytesCount, int count, float positions, hasActiveLayer ? &layerBounds : nullptr, &functor, forceFinish); } - if ((status || drawOpMode != kDrawOpMode_Immediate) && hasActiveLayer) { + if ((status || drawOpMode != DrawOpMode::kImmediate) && hasActiveLayer) { if (!pureTranslate) { transform.mapRect(layerBounds); } diff --git a/libs/hwui/OpenGLRenderer.h b/libs/hwui/OpenGLRenderer.h index 8547b67..ae53313 100755 --- a/libs/hwui/OpenGLRenderer.h +++ b/libs/hwui/OpenGLRenderer.h @@ -17,6 +17,18 @@ #ifndef ANDROID_HWUI_OPENGL_RENDERER_H #define ANDROID_HWUI_OPENGL_RENDERER_H +#include "CanvasState.h" +#include "Debug.h" +#include "Extensions.h" +#include "Matrix.h" +#include "Program.h" +#include "Rect.h" +#include "Snapshot.h" +#include "UvMapper.h" +#include "Vertex.h" +#include "Caches.h" +#include "utils/PaintUtils.h" + #include <GLES2/gl2.h> #include <GLES2/gl2ext.h> @@ -38,24 +50,17 @@ #include <androidfw/ResourceTypes.h> -#include "CanvasState.h" -#include "Debug.h" -#include "Extensions.h" -#include "Matrix.h" -#include "Program.h" -#include "Rect.h" -#include "Renderer.h" -#include "Snapshot.h" -#include "UvMapper.h" -#include "Vertex.h" -#include "Caches.h" -#include "utils/PaintUtils.h" - class SkShader; namespace android { namespace uirenderer { +enum class DrawOpMode { + kImmediate, + kDefer, + kFlush +}; + class DeferredDisplayState; struct Glop; class RenderState; @@ -118,23 +123,59 @@ enum ModelViewMode { /** * OpenGL Renderer implementation. */ -class OpenGLRenderer : public Renderer, public CanvasStateClient { +class OpenGLRenderer : public CanvasStateClient { public: OpenGLRenderer(RenderState& renderState); virtual ~OpenGLRenderer(); + /** + * Sets the dimension of the underlying drawing surface. This method must + * be called at least once every time the drawing surface changes size. + * + * @param width The width in pixels of the underlysing surface + * @param height The height in pixels of the underlysing surface + */ + void setViewport(int width, int height) { mState.setViewport(width, height); } + void initProperties(); void initLight(const Vector3& lightCenter, float lightRadius, uint8_t ambientShadowAlpha, uint8_t spotShadowAlpha); + /* + * Prepares the renderer to draw a frame. This method must be invoked + * at the beginning of each frame. Only the specified rectangle of the + * frame is assumed to be dirty. A clip will automatically be set to + * the specified rectangle. + * + * @param opaque If true, the target surface is considered opaque + * and will not be cleared. If false, the target surface + * will be cleared + */ virtual void prepareDirty(float left, float top, float right, float bottom, - bool opaque) override; - virtual void prepare(bool opaque) override { + bool opaque); + + /** + * Prepares the renderer to draw a frame. This method must be invoked + * at the beginning of each frame. When this method is invoked, the + * entire drawing surface is assumed to be redrawn. + * + * @param opaque If true, the target surface is considered opaque + * and will not be cleared. If false, the target surface + * will be cleared + */ + void prepare(bool opaque) { prepareDirty(0.0f, 0.0f, mState.getWidth(), mState.getHeight(), opaque); } - virtual bool finish() override; - virtual void callDrawGLFunction(Functor* functor, Rect& dirty) override; + /** + * Indicates the end of a frame. This method must be invoked whenever + * the caller is done rendering a frame. + * Returns true if any drawing was done during the frame (the output + * has changed / is "dirty" and should be displayed to the user). + */ + virtual bool finish(); + + void callDrawGLFunction(Functor* functor, Rect& dirty); void pushLayerUpdate(Layer* layer); void cancelLayerUpdate(Layer* layer); @@ -142,7 +183,7 @@ public: void markLayersAsBuildLayers(); virtual int saveLayer(float left, float top, float right, float bottom, - const SkPaint* paint, int flags) override { + const SkPaint* paint, int flags) { return saveLayer(left, top, right, bottom, paint, flags, nullptr); } @@ -154,49 +195,48 @@ public: int saveLayerDeferred(float left, float top, float right, float bottom, const SkPaint* paint, int flags); - virtual void drawRenderNode(RenderNode* displayList, Rect& dirty, - int32_t replayFlags = 1) override; - virtual void drawLayer(Layer* layer, float x, float y); - virtual void drawBitmap(const SkBitmap* bitmap, const SkPaint* paint) override; + void drawRenderNode(RenderNode* displayList, Rect& dirty, int32_t replayFlags = 1); + void drawLayer(Layer* layer, float x, float y); + void drawBitmap(const SkBitmap* bitmap, const SkPaint* paint); void drawBitmaps(const SkBitmap* bitmap, AssetAtlas::Entry* entry, int bitmapCount, TextureVertex* vertices, bool pureTranslate, const Rect& bounds, const SkPaint* paint); - virtual void drawBitmap(const SkBitmap* bitmap, Rect src, Rect dst, - const SkPaint* paint) override; - virtual void drawBitmapMesh(const SkBitmap* bitmap, int meshWidth, int meshHeight, - const float* vertices, const int* colors, const SkPaint* paint) override; + void drawBitmap(const SkBitmap* bitmap, Rect src, Rect dst, + const SkPaint* paint); + void drawBitmapMesh(const SkBitmap* bitmap, int meshWidth, int meshHeight, + const float* vertices, const int* colors, const SkPaint* paint); void drawPatches(const SkBitmap* bitmap, AssetAtlas::Entry* entry, TextureVertex* vertices, uint32_t indexCount, const SkPaint* paint); - virtual void drawPatch(const SkBitmap* bitmap, const Res_png_9patch* patch, - float left, float top, float right, float bottom, const SkPaint* paint) override; + void drawPatch(const SkBitmap* bitmap, const Res_png_9patch* patch, + float left, float top, float right, float bottom, const SkPaint* paint); void drawPatch(const SkBitmap* bitmap, const Patch* mesh, AssetAtlas::Entry* entry, float left, float top, float right, float bottom, const SkPaint* paint); - virtual void drawColor(int color, SkXfermode::Mode mode) override; - virtual void drawRect(float left, float top, float right, float bottom, - const SkPaint* paint) override; - virtual void drawRoundRect(float left, float top, float right, float bottom, - float rx, float ry, const SkPaint* paint) override; - virtual void drawCircle(float x, float y, float radius, const SkPaint* paint) override; - virtual void drawOval(float left, float top, float right, float bottom, - const SkPaint* paint) override; - virtual void drawArc(float left, float top, float right, float bottom, - float startAngle, float sweepAngle, bool useCenter, const SkPaint* paint) override; - virtual void drawPath(const SkPath* path, const SkPaint* paint) override; - virtual void drawLines(const float* points, int count, const SkPaint* paint) override; - virtual void drawPoints(const float* points, int count, const SkPaint* paint) override; - virtual void drawTextOnPath(const char* text, int bytesCount, int count, const SkPath* path, - float hOffset, float vOffset, const SkPaint* paint) override; - virtual void drawPosText(const char* text, int bytesCount, int count, - const float* positions, const SkPaint* paint) override; - virtual void drawText(const char* text, int bytesCount, int count, float x, float y, + void drawColor(int color, SkXfermode::Mode mode); + void drawRect(float left, float top, float right, float bottom, + const SkPaint* paint); + void drawRoundRect(float left, float top, float right, float bottom, + float rx, float ry, const SkPaint* paint); + void drawCircle(float x, float y, float radius, const SkPaint* paint); + void drawOval(float left, float top, float right, float bottom, + const SkPaint* paint); + void drawArc(float left, float top, float right, float bottom, + float startAngle, float sweepAngle, bool useCenter, const SkPaint* paint); + void drawPath(const SkPath* path, const SkPaint* paint); + void drawLines(const float* points, int count, const SkPaint* paint); + void drawPoints(const float* points, int count, const SkPaint* paint); + void drawTextOnPath(const char* text, int bytesCount, int count, const SkPath* path, + float hOffset, float vOffset, const SkPaint* paint); + void drawPosText(const char* text, int bytesCount, int count, + const float* positions, const SkPaint* paint); + void drawText(const char* text, int bytesCount, int count, float x, float y, const float* positions, const SkPaint* paint, float totalAdvance, const Rect& bounds, - DrawOpMode drawOpMode = kDrawOpMode_Immediate) override; - virtual void drawRects(const float* rects, int count, const SkPaint* paint) override; + DrawOpMode drawOpMode = DrawOpMode::kImmediate); + void drawRects(const float* rects, int count, const SkPaint* paint); void drawShadow(float casterAlpha, const VertexBuffer* ambientShadowVertexBuffer, const VertexBuffer* spotShadowVertexBuffer); - virtual void setDrawFilter(SkDrawFilter* filter) override; + void setDrawFilter(SkDrawFilter* filter); // If this value is set to < 1.0, it overrides alpha set on layer (see drawBitmap, drawLayer) void setOverrideLayerAlpha(float alpha) { mDrawModifiers.mOverrideLayerAlpha = alpha; } @@ -339,36 +379,34 @@ public: /////////////////////////////////////////////////////////////////// /// State manipulation - virtual void setViewport(int width, int height) override { mState.setViewport(width, height); } - - virtual int getSaveCount() const override; - virtual int save(int flags) override; - virtual void restore() override; - virtual void restoreToCount(int saveCount) override; + int getSaveCount() const; + int save(int flags); + void restore(); + void restoreToCount(int saveCount); - virtual void getMatrix(SkMatrix* outMatrix) const override { mState.getMatrix(outMatrix); } - virtual void setMatrix(const SkMatrix& matrix) override { mState.setMatrix(matrix); } - virtual void concatMatrix(const SkMatrix& matrix) override { mState.concatMatrix(matrix); } + void getMatrix(SkMatrix* outMatrix) const { mState.getMatrix(outMatrix); } + void setMatrix(const SkMatrix& matrix) { mState.setMatrix(matrix); } + void concatMatrix(const SkMatrix& matrix) { mState.concatMatrix(matrix); } - virtual void translate(float dx, float dy, float dz = 0.0f) override; - virtual void rotate(float degrees) override; - virtual void scale(float sx, float sy) override; - virtual void skew(float sx, float sy) override; + void translate(float dx, float dy, float dz = 0.0f); + void rotate(float degrees); + void scale(float sx, float sy); + void skew(float sx, float sy); void setMatrix(const Matrix4& matrix); // internal only convenience method void concatMatrix(const Matrix4& matrix); // internal only convenience method - virtual const Rect& getLocalClipBounds() const override { return mState.getLocalClipBounds(); } + const Rect& getLocalClipBounds() const { return mState.getLocalClipBounds(); } const Rect& getRenderTargetClipBounds() const { return mState.getRenderTargetClipBounds(); } - virtual bool quickRejectConservative(float left, float top, - float right, float bottom) const override { + bool quickRejectConservative(float left, float top, + float right, float bottom) const { return mState.quickRejectConservative(left, top, right, bottom); } - virtual bool clipRect(float left, float top, - float right, float bottom, SkRegion::Op op) override; - virtual bool clipPath(const SkPath* path, SkRegion::Op op) override; - virtual bool clipRegion(const SkRegion* region, SkRegion::Op op) override; + bool clipRect(float left, float top, + float right, float bottom, SkRegion::Op op); + bool clipPath(const SkPath* path, SkRegion::Op op); + bool clipRegion(const SkRegion* region, SkRegion::Op op); /** * Does not support different clipping Ops (that is, every call to setClippingOutline is diff --git a/libs/hwui/Renderer.h b/libs/hwui/Renderer.h deleted file mode 100644 index 1e737c0..0000000 --- a/libs/hwui/Renderer.h +++ /dev/null @@ -1,198 +0,0 @@ -/* - * Copyright (C) 2013 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_RENDERER_H -#define ANDROID_HWUI_RENDERER_H - -#include <SkColorFilter.h> -#include <SkPaint.h> -#include <SkRegion.h> -#include <utils/String8.h> - -#include "AssetAtlas.h" - -class SkDrawFilter; - -namespace android { - -class Functor; -struct Res_png_9patch; - -namespace uirenderer { - -class RenderNode; -class Layer; -class Matrix4; -class SkiaColorFilter; -class Patch; - -enum DrawOpMode { - kDrawOpMode_Immediate, - kDrawOpMode_Defer, - kDrawOpMode_Flush -}; - -/** - * Hwui's abstract version of Canvas. - * - * Provides methods for frame state operations, as well as the SkCanvas style transform/clip state, - * and varied drawing operations. - * - * Should at some point interact with native SkCanvas. - */ -class ANDROID_API Renderer { -public: - virtual ~Renderer() {} - -// ---------------------------------------------------------------------------- -// Frame state operations -// ---------------------------------------------------------------------------- - /** - * Sets the dimension of the underlying drawing surface. This method must - * be called at least once every time the drawing surface changes size. - * - * @param width The width in pixels of the underlysing surface - * @param height The height in pixels of the underlysing surface - */ - virtual void setViewport(int width, int height) = 0; - - /** - * Prepares the renderer to draw a frame. This method must be invoked - * at the beginning of each frame. When this method is invoked, the - * entire drawing surface is assumed to be redrawn. - * - * @param opaque If true, the target surface is considered opaque - * and will not be cleared. If false, the target surface - * will be cleared - */ - virtual void prepare(bool opaque) = 0; - - /** - * Prepares the renderer to draw a frame. This method must be invoked - * at the beginning of each frame. Only the specified rectangle of the - * frame is assumed to be dirty. A clip will automatically be set to - * the specified rectangle. - * - * @param left The left coordinate of the dirty rectangle - * @param top The top coordinate of the dirty rectangle - * @param right The right coordinate of the dirty rectangle - * @param bottom The bottom coordinate of the dirty rectangle - * @param opaque If true, the target surface is considered opaque - * and will not be cleared. If false, the target surface - * will be cleared in the specified dirty rectangle - */ - virtual void prepareDirty(float left, float top, float right, float bottom, - bool opaque) = 0; - - /** - * Indicates the end of a frame. This method must be invoked whenever - * the caller is done rendering a frame. - * Returns true if any drawing was done during the frame (the output - * has changed / is "dirty" and should be displayed to the user). - */ - virtual bool finish() = 0; - -// ---------------------------------------------------------------------------- -// Canvas state operations -// ---------------------------------------------------------------------------- - // Save (layer) - virtual int getSaveCount() const = 0; - virtual int save(int flags) = 0; - virtual void restore() = 0; - virtual void restoreToCount(int saveCount) = 0; - - virtual int saveLayer(float left, float top, float right, float bottom, - const SkPaint* paint, int flags) = 0; - - int saveLayerAlpha(float left, float top, float right, float bottom, - int alpha, int flags) { - SkPaint paint; - paint.setAlpha(alpha); - return saveLayer(left, top, right, bottom, &paint, flags); - } - - // Matrix - virtual void getMatrix(SkMatrix* outMatrix) const = 0; - virtual void translate(float dx, float dy, float dz = 0.0f) = 0; - virtual void rotate(float degrees) = 0; - virtual void scale(float sx, float sy) = 0; - virtual void skew(float sx, float sy) = 0; - - virtual void setMatrix(const SkMatrix& matrix) = 0; - virtual void concatMatrix(const SkMatrix& matrix) = 0; - - // clip - virtual const Rect& getLocalClipBounds() const = 0; - virtual bool quickRejectConservative(float left, float top, - float right, float bottom) const = 0; - virtual bool clipRect(float left, float top, float right, float bottom, SkRegion::Op op) = 0; - virtual bool clipPath(const SkPath* path, SkRegion::Op op) = 0; - virtual bool clipRegion(const SkRegion* region, SkRegion::Op op) = 0; - - // Misc - virtual void setDrawFilter(SkDrawFilter* filter) = 0; - -// ---------------------------------------------------------------------------- -// Canvas draw operations -// ---------------------------------------------------------------------------- - virtual void drawColor(int color, SkXfermode::Mode mode) = 0; - - // Bitmap-based - virtual void drawBitmap(const SkBitmap* bitmap, const SkPaint* paint) = 0; - virtual void drawBitmap(const SkBitmap* bitmap, Rect src, Rect dst, const SkPaint* paint) = 0; - virtual void drawBitmapMesh(const SkBitmap* bitmap, int meshWidth, int meshHeight, - const float* vertices, const int* colors, const SkPaint* paint) = 0; - virtual void drawPatch(const SkBitmap* bitmap, const Res_png_9patch* patch, - float left, float top, float right, float bottom, const SkPaint* paint) = 0; - - // Shapes - virtual void drawRect(float left, float top, float right, float bottom, - const SkPaint* paint) = 0; - virtual void drawRects(const float* rects, int count, const SkPaint* paint) = 0; - virtual void drawRoundRect(float left, float top, float right, float bottom, - float rx, float ry, const SkPaint* paint) = 0; - virtual void drawCircle(float x, float y, float radius, const SkPaint* paint) = 0; - virtual void drawOval(float left, float top, float right, float bottom, - const SkPaint* paint) = 0; - virtual void drawArc(float left, float top, float right, float bottom, - float startAngle, float sweepAngle, bool useCenter, const SkPaint* paint) = 0; - virtual void drawPath(const SkPath* path, const SkPaint* paint) = 0; - virtual void drawLines(const float* points, int count, const SkPaint* paint) = 0; - virtual void drawPoints(const float* points, int count, const SkPaint* paint) = 0; - - // Text - virtual void drawText(const char* text, int bytesCount, int count, float x, float y, - const float* positions, const SkPaint* paint, float totalAdvance, const Rect& bounds, - DrawOpMode drawOpMode = kDrawOpMode_Immediate) = 0; - virtual void drawTextOnPath(const char* text, int bytesCount, int count, const SkPath* path, - float hOffset, float vOffset, const SkPaint* paint) = 0; - virtual void drawPosText(const char* text, int bytesCount, int count, - const float* positions, const SkPaint* paint) = 0; - -// ---------------------------------------------------------------------------- -// Canvas draw operations - special -// ---------------------------------------------------------------------------- - virtual void drawRenderNode(RenderNode* renderNode, Rect& dirty, - int32_t replayFlags) = 0; - - // TODO: rename for consistency - virtual void callDrawGLFunction(Functor* functor, Rect& dirty) = 0; -}; // class Renderer - -}; // namespace uirenderer -}; // namespace android - -#endif // ANDROID_HWUI_RENDERER_H |