2010-09-26 18:40:37 -07:00
|
|
|
/*
|
|
|
|
* 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"
|
|
|
|
|
2012-03-13 11:18:20 -07:00
|
|
|
#include <SkCamera.h>
|
2013-03-15 19:06:39 -07:00
|
|
|
#include <SkCanvas.h>
|
2011-03-24 10:51:31 -07:00
|
|
|
|
2012-03-26 16:45:05 -07:00
|
|
|
#include <private/hwui/DrawGlInfo.h>
|
|
|
|
|
2013-02-14 15:36:01 -08:00
|
|
|
#include "DisplayList.h"
|
2013-02-04 16:16:33 -08:00
|
|
|
#include "DeferredDisplayList.h"
|
2011-03-24 10:51:31 -07:00
|
|
|
#include "DisplayListLogBuffer.h"
|
2012-11-26 18:30:17 -08:00
|
|
|
#include "DisplayListOp.h"
|
2010-09-26 18:40:37 -07:00
|
|
|
#include "DisplayListRenderer.h"
|
2011-03-24 10:51:31 -07:00
|
|
|
#include "Caches.h"
|
2012-01-30 17:41:55 -08:00
|
|
|
|
2010-09-26 18:40:37 -07:00
|
|
|
namespace android {
|
|
|
|
namespace uirenderer {
|
|
|
|
|
2012-09-07 11:58:36 -07:00
|
|
|
DisplayListRenderer::DisplayListRenderer():
|
2012-11-26 18:30:17 -08:00
|
|
|
mCaches(Caches::getInstance()), mDisplayListData(new DisplayListData),
|
2012-09-27 17:55:46 -07:00
|
|
|
mTranslateX(0.0f), mTranslateY(0.0f), mHasTranslate(false),
|
|
|
|
mHasDrawOps(false), mFunctorCount(0) {
|
2010-09-26 18:40:37 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
DisplayListRenderer::~DisplayListRenderer() {
|
|
|
|
reset();
|
|
|
|
}
|
|
|
|
|
|
|
|
void DisplayListRenderer::reset() {
|
2012-11-26 18:30:17 -08:00
|
|
|
mDisplayListData = new DisplayListData();
|
2012-09-07 11:58:36 -07:00
|
|
|
mCaches.resourceCache.lock();
|
|
|
|
|
2010-10-08 08:37:55 -07:00
|
|
|
for (size_t i = 0; i < mBitmapResources.size(); i++) {
|
2012-09-07 11:58:36 -07:00
|
|
|
mCaches.resourceCache.decrementRefcountLocked(mBitmapResources.itemAt(i));
|
2010-10-08 08:37:55 -07:00
|
|
|
}
|
2010-10-25 15:47:32 -07:00
|
|
|
|
2012-05-15 11:10:01 -07:00
|
|
|
for (size_t i = 0; i < mOwnedBitmapResources.size(); i++) {
|
2012-09-07 11:58:36 -07:00
|
|
|
mCaches.resourceCache.decrementRefcountLocked(mOwnedBitmapResources.itemAt(i));
|
2012-05-15 11:10:01 -07:00
|
|
|
}
|
|
|
|
|
2011-06-22 16:14:36 -07:00
|
|
|
for (size_t i = 0; i < mFilterResources.size(); i++) {
|
2012-09-07 11:58:36 -07:00
|
|
|
mCaches.resourceCache.decrementRefcountLocked(mFilterResources.itemAt(i));
|
2011-06-22 16:14:36 -07:00
|
|
|
}
|
|
|
|
|
2011-01-14 18:51:01 -08:00
|
|
|
for (size_t i = 0; i < mShaders.size(); i++) {
|
2012-09-07 11:58:36 -07:00
|
|
|
mCaches.resourceCache.decrementRefcountLocked(mShaders.itemAt(i));
|
2011-01-14 18:51:01 -08:00
|
|
|
}
|
|
|
|
|
2012-05-02 18:50:34 -07:00
|
|
|
for (size_t i = 0; i < mSourcePaths.size(); i++) {
|
2012-09-07 11:58:36 -07:00
|
|
|
mCaches.resourceCache.decrementRefcountLocked(mSourcePaths.itemAt(i));
|
2012-05-02 18:50:34 -07:00
|
|
|
}
|
2012-09-07 11:58:36 -07:00
|
|
|
|
Fix occasional crash bug with layers
Launcher occasionally crashes with a stack trace indicating that the memory
of a Layer object is corrupt. It is possible for us to delete a Layer
structure and then, briefly, use it to draw a DisplayList again before
that DisplayList gets recreated (without the layer that got deleted).
When this happens, if the memory got corrupted, it's possible to crash.
The fix is to add Layer to the other objects which we currently refcount
(bitmaps, shaders, etc.). Then instead of deleting a Layer, we decrement the
refcount. We increment when creating it, then increment it again when it's
referenced from a DisplayList. Then we decrement the refcount instead of
deleting it, and decrement when we clear a DisplayList that refers to it.
Then when the refcount reaches 0, we delete it.
Issue #6994632 Native crash in launcher when trying to launch all apps screen
Change-Id: I0627be8d49bb2f9ba8d158a84b764bb4e7df934c
2012-09-14 15:31:25 -07:00
|
|
|
for (size_t i = 0; i < mLayers.size(); i++) {
|
|
|
|
mCaches.resourceCache.decrementRefcountLocked(mLayers.itemAt(i));
|
|
|
|
}
|
|
|
|
|
2012-09-07 11:58:36 -07:00
|
|
|
mCaches.resourceCache.unlock();
|
|
|
|
|
|
|
|
mBitmapResources.clear();
|
|
|
|
mOwnedBitmapResources.clear();
|
|
|
|
mFilterResources.clear();
|
2012-05-02 18:50:34 -07:00
|
|
|
mSourcePaths.clear();
|
|
|
|
|
2012-09-07 11:58:36 -07:00
|
|
|
mShaders.clear();
|
|
|
|
mShaderMap.clear();
|
|
|
|
|
2011-01-14 18:51:01 -08:00
|
|
|
mPaints.clear();
|
|
|
|
mPaintMap.clear();
|
2011-06-22 16:14:36 -07:00
|
|
|
|
2012-12-03 12:34:51 -08:00
|
|
|
mRegions.clear();
|
|
|
|
mRegionMap.clear();
|
|
|
|
|
2011-02-03 15:06:05 -08:00
|
|
|
mPaths.clear();
|
|
|
|
mPathMap.clear();
|
2011-06-22 16:14:36 -07:00
|
|
|
|
2010-10-25 15:47:32 -07:00
|
|
|
mMatrices.clear();
|
2011-08-25 14:01:48 -07:00
|
|
|
|
Fix occasional crash bug with layers
Launcher occasionally crashes with a stack trace indicating that the memory
of a Layer object is corrupt. It is possible for us to delete a Layer
structure and then, briefly, use it to draw a DisplayList again before
that DisplayList gets recreated (without the layer that got deleted).
When this happens, if the memory got corrupted, it's possible to crash.
The fix is to add Layer to the other objects which we currently refcount
(bitmaps, shaders, etc.). Then instead of deleting a Layer, we decrement the
refcount. We increment when creating it, then increment it again when it's
referenced from a DisplayList. Then we decrement the refcount instead of
deleting it, and decrement when we clear a DisplayList that refers to it.
Then when the refcount reaches 0, we delete it.
Issue #6994632 Native crash in launcher when trying to launch all apps screen
Change-Id: I0627be8d49bb2f9ba8d158a84b764bb4e7df934c
2012-09-14 15:31:25 -07:00
|
|
|
mLayers.clear();
|
|
|
|
|
2011-08-25 14:01:48 -07:00
|
|
|
mHasDrawOps = false;
|
2012-09-27 17:55:46 -07:00
|
|
|
mFunctorCount = 0;
|
2010-09-26 18:40:37 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Operations
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2011-07-21 17:02:54 -07:00
|
|
|
DisplayList* DisplayListRenderer::getDisplayList(DisplayList* displayList) {
|
|
|
|
if (!displayList) {
|
|
|
|
displayList = new DisplayList(*this);
|
2011-01-05 18:01:22 -08:00
|
|
|
} else {
|
2011-07-21 17:02:54 -07:00
|
|
|
displayList->initFromDisplayListRenderer(*this, true);
|
2011-01-05 18:01:22 -08:00
|
|
|
}
|
2011-08-25 14:01:48 -07:00
|
|
|
displayList->setRenderable(mHasDrawOps);
|
2011-07-21 17:02:54 -07:00
|
|
|
return displayList;
|
2011-01-05 18:01:22 -08:00
|
|
|
}
|
|
|
|
|
2012-05-15 11:10:01 -07:00
|
|
|
bool DisplayListRenderer::isDeferred() {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2010-09-28 19:09:36 -07:00
|
|
|
void DisplayListRenderer::setViewport(int width, int height) {
|
|
|
|
mOrthoMatrix.loadOrtho(0, width, height, 0, -1, 1);
|
|
|
|
|
|
|
|
mWidth = width;
|
|
|
|
mHeight = height;
|
|
|
|
}
|
|
|
|
|
2012-10-18 15:05:02 -07:00
|
|
|
status_t DisplayListRenderer::prepareDirty(float left, float top,
|
2011-01-24 16:33:45 -08:00
|
|
|
float right, float bottom, bool opaque) {
|
2010-09-28 19:09:36 -07:00
|
|
|
mSnapshot = new Snapshot(mFirstSnapshot,
|
|
|
|
SkCanvas::kMatrix_SaveFlag | SkCanvas::kClip_SaveFlag);
|
|
|
|
mSaveCount = 1;
|
2012-09-11 17:17:07 -07:00
|
|
|
|
2010-09-28 19:09:36 -07:00
|
|
|
mSnapshot->setClip(0.0f, 0.0f, mWidth, mHeight);
|
2012-09-11 17:17:07 -07:00
|
|
|
mDirtyClip = opaque;
|
|
|
|
|
2011-01-23 12:01:41 -08:00
|
|
|
mRestoreSaveCount = -1;
|
2012-09-11 17:17:07 -07:00
|
|
|
|
2012-06-06 19:03:58 -07:00
|
|
|
return DrawGlInfo::kStatusDone; // No invalidate needed at record-time
|
2011-01-23 12:01:41 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
void DisplayListRenderer::finish() {
|
|
|
|
insertRestoreToCount();
|
2012-11-26 18:30:17 -08:00
|
|
|
insertTranslate();
|
2010-09-28 19:09:36 -07:00
|
|
|
}
|
|
|
|
|
2011-01-10 14:10:36 -08:00
|
|
|
void DisplayListRenderer::interrupt() {
|
|
|
|
}
|
|
|
|
|
2011-01-26 13:43:01 -08:00
|
|
|
void DisplayListRenderer::resume() {
|
2010-09-26 18:40:37 -07:00
|
|
|
}
|
|
|
|
|
2012-03-26 16:45:05 -07:00
|
|
|
status_t DisplayListRenderer::callDrawGLFunction(Functor *functor, Rect& dirty) {
|
2011-03-07 18:06:46 -08:00
|
|
|
// Ignore dirty during recording, it matters only when we replay
|
2012-11-26 18:30:17 -08:00
|
|
|
addDrawOp(new (alloc()) DrawFunctorOp(functor));
|
2012-09-27 17:55:46 -07:00
|
|
|
mFunctorCount++;
|
2012-03-26 16:45:05 -07:00
|
|
|
return DrawGlInfo::kStatusDone; // No invalidate needed at record-time
|
2011-01-10 14:10:36 -08:00
|
|
|
}
|
|
|
|
|
2010-09-26 18:40:37 -07:00
|
|
|
int DisplayListRenderer::save(int flags) {
|
2012-11-26 18:30:17 -08:00
|
|
|
addStateOp(new (alloc()) SaveOp(flags));
|
2010-09-26 18:40:37 -07:00
|
|
|
return OpenGLRenderer::save(flags);
|
|
|
|
}
|
|
|
|
|
|
|
|
void DisplayListRenderer::restore() {
|
2011-08-25 14:01:48 -07:00
|
|
|
if (mRestoreSaveCount < 0) {
|
2012-02-16 19:24:51 -08:00
|
|
|
restoreToCount(getSaveCount() - 1);
|
|
|
|
return;
|
2011-08-25 14:01:48 -07:00
|
|
|
}
|
2012-02-16 19:24:51 -08:00
|
|
|
|
|
|
|
mRestoreSaveCount--;
|
2012-11-26 18:30:17 -08:00
|
|
|
insertTranslate();
|
2010-09-26 18:40:37 -07:00
|
|
|
OpenGLRenderer::restore();
|
|
|
|
}
|
|
|
|
|
|
|
|
void DisplayListRenderer::restoreToCount(int saveCount) {
|
2011-01-23 12:01:41 -08:00
|
|
|
mRestoreSaveCount = saveCount;
|
2012-11-26 18:30:17 -08:00
|
|
|
insertTranslate();
|
2010-09-26 18:40:37 -07:00
|
|
|
OpenGLRenderer::restoreToCount(saveCount);
|
|
|
|
}
|
|
|
|
|
|
|
|
int DisplayListRenderer::saveLayer(float left, float top, float right, float bottom,
|
2013-03-08 13:12:16 -08:00
|
|
|
int alpha, SkXfermode::Mode mode, int flags) {
|
|
|
|
addStateOp(new (alloc()) SaveLayerOp(left, top, right, bottom, alpha, mode, flags));
|
2010-10-27 18:57:51 -07:00
|
|
|
return OpenGLRenderer::save(flags);
|
|
|
|
}
|
|
|
|
|
2010-09-26 18:40:37 -07:00
|
|
|
void DisplayListRenderer::translate(float dx, float dy) {
|
2012-02-16 19:24:51 -08:00
|
|
|
mHasTranslate = true;
|
|
|
|
mTranslateX += dx;
|
|
|
|
mTranslateY += dy;
|
|
|
|
insertRestoreToCount();
|
2010-09-26 18:40:37 -07:00
|
|
|
OpenGLRenderer::translate(dx, dy);
|
|
|
|
}
|
|
|
|
|
|
|
|
void DisplayListRenderer::rotate(float degrees) {
|
2012-11-26 18:30:17 -08:00
|
|
|
addStateOp(new (alloc()) RotateOp(degrees));
|
2010-09-26 18:40:37 -07:00
|
|
|
OpenGLRenderer::rotate(degrees);
|
|
|
|
}
|
|
|
|
|
|
|
|
void DisplayListRenderer::scale(float sx, float sy) {
|
2012-11-26 18:30:17 -08:00
|
|
|
addStateOp(new (alloc()) ScaleOp(sx, sy));
|
2010-09-26 18:40:37 -07:00
|
|
|
OpenGLRenderer::scale(sx, sy);
|
|
|
|
}
|
|
|
|
|
2011-01-18 11:19:19 -08:00
|
|
|
void DisplayListRenderer::skew(float sx, float sy) {
|
2012-11-26 18:30:17 -08:00
|
|
|
addStateOp(new (alloc()) SkewOp(sx, sy));
|
2011-01-18 11:19:19 -08:00
|
|
|
OpenGLRenderer::skew(sx, sy);
|
|
|
|
}
|
|
|
|
|
2010-09-26 18:40:37 -07:00
|
|
|
void DisplayListRenderer::setMatrix(SkMatrix* matrix) {
|
2012-11-26 18:30:17 -08:00
|
|
|
matrix = refMatrix(matrix);
|
|
|
|
addStateOp(new (alloc()) SetMatrixOp(matrix));
|
2010-09-26 18:40:37 -07:00
|
|
|
OpenGLRenderer::setMatrix(matrix);
|
|
|
|
}
|
|
|
|
|
|
|
|
void DisplayListRenderer::concatMatrix(SkMatrix* matrix) {
|
2012-11-26 18:30:17 -08:00
|
|
|
matrix = refMatrix(matrix);
|
|
|
|
addStateOp(new (alloc()) ConcatMatrixOp(matrix));
|
2010-09-26 18:40:37 -07:00
|
|
|
OpenGLRenderer::concatMatrix(matrix);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool DisplayListRenderer::clipRect(float left, float top, float right, float bottom,
|
|
|
|
SkRegion::Op op) {
|
2012-11-26 18:30:17 -08:00
|
|
|
addStateOp(new (alloc()) ClipRectOp(left, top, right, bottom, op));
|
2010-09-26 18:40:37 -07:00
|
|
|
return OpenGLRenderer::clipRect(left, top, right, bottom, op);
|
|
|
|
}
|
|
|
|
|
2012-12-03 12:34:51 -08:00
|
|
|
bool DisplayListRenderer::clipPath(SkPath* path, SkRegion::Op op) {
|
2012-11-26 18:30:17 -08:00
|
|
|
path = refPath(path);
|
|
|
|
addStateOp(new (alloc()) ClipPathOp(path, op));
|
2012-12-03 12:34:51 -08:00
|
|
|
return OpenGLRenderer::clipPath(path, op);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool DisplayListRenderer::clipRegion(SkRegion* region, SkRegion::Op op) {
|
2012-11-26 18:30:17 -08:00
|
|
|
region = refRegion(region);
|
|
|
|
addStateOp(new (alloc()) ClipRegionOp(region, op));
|
2012-12-03 12:34:51 -08:00
|
|
|
return OpenGLRenderer::clipRegion(region, op);
|
|
|
|
}
|
|
|
|
|
2012-03-26 16:45:05 -07:00
|
|
|
status_t DisplayListRenderer::drawDisplayList(DisplayList* displayList,
|
2013-02-04 16:16:33 -08:00
|
|
|
Rect& dirty, int32_t flags) {
|
2011-03-07 18:06:46 -08:00
|
|
|
// dirty is an out parameter and should not be recorded,
|
|
|
|
// it matters only when replaying the display list
|
2012-03-26 14:37:51 -07:00
|
|
|
|
2012-11-26 18:30:17 -08:00
|
|
|
// TODO: To be safe, the display list should be ref-counted in the
|
|
|
|
// resources cache, but we rely on the caller (UI toolkit) to
|
|
|
|
// do the right thing for now
|
|
|
|
|
|
|
|
addDrawOp(new (alloc()) DrawDisplayListOp(displayList, flags));
|
2012-03-26 16:45:05 -07:00
|
|
|
return DrawGlInfo::kStatusDone;
|
2010-11-08 12:08:41 -08:00
|
|
|
}
|
|
|
|
|
2013-03-15 17:24:33 -07:00
|
|
|
status_t DisplayListRenderer::drawLayer(Layer* layer, float x, float y) {
|
2013-03-28 11:32:33 -07:00
|
|
|
layer = refLayer(layer);
|
2013-03-15 17:24:33 -07:00
|
|
|
addDrawOp(new (alloc()) DrawLayerOp(layer, x, y));
|
2012-05-31 15:21:51 -07:00
|
|
|
return DrawGlInfo::kStatusDone;
|
2011-01-11 14:29:25 -08:00
|
|
|
}
|
|
|
|
|
2012-05-31 15:21:51 -07:00
|
|
|
status_t DisplayListRenderer::drawBitmap(SkBitmap* bitmap, float left, float top, SkPaint* paint) {
|
2012-11-26 18:30:17 -08:00
|
|
|
bitmap = refBitmap(bitmap);
|
|
|
|
paint = refPaint(paint);
|
|
|
|
|
|
|
|
addDrawOp(new (alloc()) DrawBitmapOp(bitmap, left, top, paint));
|
2012-05-31 15:21:51 -07:00
|
|
|
return DrawGlInfo::kStatusDone;
|
2010-09-26 18:40:37 -07:00
|
|
|
}
|
|
|
|
|
2012-05-31 15:21:51 -07:00
|
|
|
status_t DisplayListRenderer::drawBitmap(SkBitmap* bitmap, SkMatrix* matrix, SkPaint* paint) {
|
2012-11-26 18:30:17 -08:00
|
|
|
bitmap = refBitmap(bitmap);
|
|
|
|
matrix = refMatrix(matrix);
|
|
|
|
paint = refPaint(paint);
|
|
|
|
|
|
|
|
addDrawOp(new (alloc()) DrawBitmapMatrixOp(bitmap, matrix, paint));
|
2012-05-31 15:21:51 -07:00
|
|
|
return DrawGlInfo::kStatusDone;
|
2010-09-26 18:40:37 -07:00
|
|
|
}
|
|
|
|
|
2012-05-31 15:21:51 -07:00
|
|
|
status_t DisplayListRenderer::drawBitmap(SkBitmap* bitmap, float srcLeft, float srcTop,
|
2010-09-26 18:40:37 -07:00
|
|
|
float srcRight, float srcBottom, float dstLeft, float dstTop,
|
2010-10-08 08:37:55 -07:00
|
|
|
float dstRight, float dstBottom, SkPaint* paint) {
|
2012-11-26 18:30:17 -08:00
|
|
|
bitmap = refBitmap(bitmap);
|
|
|
|
paint = refPaint(paint);
|
|
|
|
|
2013-03-04 10:19:31 -08:00
|
|
|
if (srcLeft == 0 && srcTop == 0 &&
|
|
|
|
srcRight == bitmap->width() && srcBottom == bitmap->height() &&
|
|
|
|
(srcBottom - srcTop == dstBottom - dstTop) &&
|
|
|
|
(srcRight - srcLeft == dstRight - dstLeft)) {
|
|
|
|
// transform simple rect to rect drawing case into position bitmap ops, since they merge
|
|
|
|
addDrawOp(new (alloc()) DrawBitmapOp(bitmap, dstLeft, dstTop, paint));
|
|
|
|
return DrawGlInfo::kStatusDone;
|
|
|
|
}
|
|
|
|
|
2012-11-26 18:30:17 -08:00
|
|
|
addDrawOp(new (alloc()) DrawBitmapRectOp(bitmap,
|
|
|
|
srcLeft, srcTop, srcRight, srcBottom,
|
|
|
|
dstLeft, dstTop, dstRight, dstBottom, paint));
|
2012-05-31 15:21:51 -07:00
|
|
|
return DrawGlInfo::kStatusDone;
|
2010-09-26 18:40:37 -07:00
|
|
|
}
|
|
|
|
|
2012-05-31 15:21:51 -07:00
|
|
|
status_t DisplayListRenderer::drawBitmapData(SkBitmap* bitmap, float left, float top,
|
|
|
|
SkPaint* paint) {
|
2012-11-26 18:30:17 -08:00
|
|
|
bitmap = refBitmapData(bitmap);
|
|
|
|
paint = refPaint(paint);
|
|
|
|
|
|
|
|
addDrawOp(new (alloc()) DrawBitmapDataOp(bitmap, left, top, paint));
|
2012-05-31 15:21:51 -07:00
|
|
|
return DrawGlInfo::kStatusDone;
|
2012-05-14 19:44:40 -07:00
|
|
|
}
|
|
|
|
|
2012-05-31 15:21:51 -07:00
|
|
|
status_t DisplayListRenderer::drawBitmapMesh(SkBitmap* bitmap, int meshWidth, int meshHeight,
|
2011-01-20 19:09:30 -08:00
|
|
|
float* vertices, int* colors, SkPaint* paint) {
|
2012-11-26 18:30:17 -08:00
|
|
|
int count = (meshWidth + 1) * (meshHeight + 1) * 2;
|
|
|
|
bitmap = refBitmap(bitmap);
|
|
|
|
vertices = refBuffer<float>(vertices, count);
|
|
|
|
paint = refPaint(paint);
|
|
|
|
colors = refBuffer<int>(colors, count);
|
|
|
|
|
|
|
|
addDrawOp(new (alloc()) DrawBitmapMeshOp(bitmap, meshWidth, meshHeight,
|
|
|
|
vertices, colors, paint));
|
2012-05-31 15:21:51 -07:00
|
|
|
return DrawGlInfo::kStatusDone;
|
2011-01-20 19:09:30 -08:00
|
|
|
}
|
|
|
|
|
2012-05-31 15:21:51 -07:00
|
|
|
status_t DisplayListRenderer::drawPatch(SkBitmap* bitmap, const int32_t* xDivs,
|
|
|
|
const int32_t* yDivs, const uint32_t* colors, uint32_t width, uint32_t height,
|
|
|
|
int8_t numColors, float left, float top, float right, float bottom, SkPaint* paint) {
|
2012-07-16 12:41:17 -07:00
|
|
|
int alpha;
|
|
|
|
SkXfermode::Mode mode;
|
|
|
|
OpenGLRenderer::getAlphaAndModeDirect(paint, &alpha, &mode);
|
|
|
|
|
2012-11-26 18:30:17 -08:00
|
|
|
bitmap = refBitmap(bitmap);
|
|
|
|
xDivs = refBuffer<int>(xDivs, width);
|
|
|
|
yDivs = refBuffer<int>(yDivs, height);
|
|
|
|
colors = refBuffer<uint32_t>(colors, numColors);
|
|
|
|
|
|
|
|
addDrawOp(new (alloc()) DrawPatchOp(bitmap, xDivs, yDivs, colors, width, height, numColors,
|
|
|
|
left, top, right, bottom, alpha, mode));
|
2012-05-31 15:21:51 -07:00
|
|
|
return DrawGlInfo::kStatusDone;
|
2010-09-26 18:40:37 -07:00
|
|
|
}
|
|
|
|
|
2012-05-31 15:21:51 -07:00
|
|
|
status_t DisplayListRenderer::drawColor(int color, SkXfermode::Mode mode) {
|
2012-11-26 18:30:17 -08:00
|
|
|
addDrawOp(new (alloc()) DrawColorOp(color, mode));
|
2012-05-31 15:21:51 -07:00
|
|
|
return DrawGlInfo::kStatusDone;
|
2010-09-26 18:40:37 -07:00
|
|
|
}
|
|
|
|
|
2012-05-31 15:21:51 -07:00
|
|
|
status_t DisplayListRenderer::drawRect(float left, float top, float right, float bottom,
|
2010-10-08 08:37:55 -07:00
|
|
|
SkPaint* paint) {
|
2012-11-26 18:30:17 -08:00
|
|
|
paint = refPaint(paint);
|
|
|
|
addDrawOp(new (alloc()) DrawRectOp(left, top, right, bottom, paint));
|
2012-05-31 15:21:51 -07:00
|
|
|
return DrawGlInfo::kStatusDone;
|
2010-09-26 18:40:37 -07:00
|
|
|
}
|
|
|
|
|
2012-05-31 15:21:51 -07:00
|
|
|
status_t DisplayListRenderer::drawRoundRect(float left, float top, float right, float bottom,
|
2012-02-21 13:43:44 -08:00
|
|
|
float rx, float ry, SkPaint* paint) {
|
2012-11-26 18:30:17 -08:00
|
|
|
paint = refPaint(paint);
|
|
|
|
addDrawOp(new (alloc()) DrawRoundRectOp(left, top, right, bottom, rx, ry, paint));
|
2012-05-31 15:21:51 -07:00
|
|
|
return DrawGlInfo::kStatusDone;
|
2011-01-19 21:54:02 -08:00
|
|
|
}
|
|
|
|
|
2012-05-31 15:21:51 -07:00
|
|
|
status_t DisplayListRenderer::drawCircle(float x, float y, float radius, SkPaint* paint) {
|
2012-11-26 18:30:17 -08:00
|
|
|
paint = refPaint(paint);
|
|
|
|
addDrawOp(new (alloc()) DrawCircleOp(x, y, radius, paint));
|
2012-05-31 15:21:51 -07:00
|
|
|
return DrawGlInfo::kStatusDone;
|
2011-01-19 21:54:02 -08:00
|
|
|
}
|
|
|
|
|
2012-05-31 15:21:51 -07:00
|
|
|
status_t DisplayListRenderer::drawOval(float left, float top, float right, float bottom,
|
2011-01-23 14:18:41 -08:00
|
|
|
SkPaint* paint) {
|
2012-11-26 18:30:17 -08:00
|
|
|
paint = refPaint(paint);
|
|
|
|
addDrawOp(new (alloc()) DrawOvalOp(left, top, right, bottom, paint));
|
2012-05-31 15:21:51 -07:00
|
|
|
return DrawGlInfo::kStatusDone;
|
2011-01-23 14:18:41 -08:00
|
|
|
}
|
|
|
|
|
2012-05-31 15:21:51 -07:00
|
|
|
status_t DisplayListRenderer::drawArc(float left, float top, float right, float bottom,
|
2011-01-23 16:15:02 -08:00
|
|
|
float startAngle, float sweepAngle, bool useCenter, SkPaint* paint) {
|
2012-11-26 18:30:17 -08:00
|
|
|
paint = refPaint(paint);
|
|
|
|
addDrawOp(new (alloc()) DrawArcOp(left, top, right, bottom,
|
|
|
|
startAngle, sweepAngle, useCenter, paint));
|
2012-05-31 15:21:51 -07:00
|
|
|
return DrawGlInfo::kStatusDone;
|
2011-01-23 16:15:02 -08:00
|
|
|
}
|
|
|
|
|
2012-05-31 15:21:51 -07:00
|
|
|
status_t DisplayListRenderer::drawPath(SkPath* path, SkPaint* paint) {
|
2012-11-26 18:30:17 -08:00
|
|
|
path = refPath(path);
|
|
|
|
paint = refPaint(paint);
|
|
|
|
|
|
|
|
addDrawOp(new (alloc()) DrawPathOp(path, paint));
|
2012-05-31 15:21:51 -07:00
|
|
|
return DrawGlInfo::kStatusDone;
|
2010-09-26 18:40:37 -07:00
|
|
|
}
|
|
|
|
|
2012-05-31 15:21:51 -07:00
|
|
|
status_t DisplayListRenderer::drawLines(float* points, int count, SkPaint* paint) {
|
2012-11-26 18:30:17 -08:00
|
|
|
points = refBuffer<float>(points, count);
|
|
|
|
paint = refPaint(paint);
|
|
|
|
|
|
|
|
addDrawOp(new (alloc()) DrawLinesOp(points, count, paint));
|
2012-05-31 15:21:51 -07:00
|
|
|
return DrawGlInfo::kStatusDone;
|
2011-03-21 13:11:28 -07:00
|
|
|
}
|
|
|
|
|
2012-05-31 15:21:51 -07:00
|
|
|
status_t DisplayListRenderer::drawPoints(float* points, int count, SkPaint* paint) {
|
2012-11-26 18:30:17 -08:00
|
|
|
points = refBuffer<float>(points, count);
|
|
|
|
paint = refPaint(paint);
|
|
|
|
|
|
|
|
addDrawOp(new (alloc()) DrawPointsOp(points, count, paint));
|
2012-05-31 15:21:51 -07:00
|
|
|
return DrawGlInfo::kStatusDone;
|
2010-09-26 18:40:37 -07:00
|
|
|
}
|
|
|
|
|
2012-07-23 15:22:52 -07:00
|
|
|
status_t DisplayListRenderer::drawTextOnPath(const char* text, int bytesCount, int count,
|
|
|
|
SkPath* path, float hOffset, float vOffset, SkPaint* paint) {
|
|
|
|
if (!text || count <= 0) return DrawGlInfo::kStatusDone;
|
2012-11-26 18:30:17 -08:00
|
|
|
|
|
|
|
text = refText(text, bytesCount);
|
|
|
|
path = refPath(path);
|
|
|
|
paint = refPaint(paint);
|
|
|
|
|
|
|
|
DrawOp* op = new (alloc()) DrawTextOnPathOp(text, bytesCount, count, path,
|
|
|
|
hOffset, vOffset, paint);
|
2013-03-01 14:31:04 -08:00
|
|
|
addDrawOp(op);
|
2012-07-23 15:22:52 -07:00
|
|
|
return DrawGlInfo::kStatusDone;
|
|
|
|
}
|
|
|
|
|
|
|
|
status_t DisplayListRenderer::drawPosText(const char* text, int bytesCount, int count,
|
|
|
|
const float* positions, SkPaint* paint) {
|
|
|
|
if (!text || count <= 0) return DrawGlInfo::kStatusDone;
|
2012-11-26 18:30:17 -08:00
|
|
|
|
|
|
|
text = refText(text, bytesCount);
|
|
|
|
positions = refBuffer<float>(positions, count * 2);
|
|
|
|
paint = refPaint(paint);
|
|
|
|
|
|
|
|
DrawOp* op = new (alloc()) DrawPosTextOp(text, bytesCount, count, positions, paint);
|
2013-03-01 14:31:04 -08:00
|
|
|
addDrawOp(op);
|
2012-07-23 15:22:52 -07:00
|
|
|
return DrawGlInfo::kStatusDone;
|
|
|
|
}
|
|
|
|
|
2012-07-27 16:41:22 -07:00
|
|
|
status_t DisplayListRenderer::drawText(const char* text, int bytesCount, int count,
|
2013-03-04 10:19:31 -08:00
|
|
|
float x, float y, const float* positions, SkPaint* paint,
|
|
|
|
float length, DrawOpMode drawOpMode) {
|
|
|
|
|
2012-05-31 15:21:51 -07:00
|
|
|
if (!text || count <= 0) return DrawGlInfo::kStatusDone;
|
2012-02-16 19:24:51 -08:00
|
|
|
|
|
|
|
if (length < 0.0f) length = paint->measureText(text, bytesCount);
|
|
|
|
|
2012-11-26 18:30:17 -08:00
|
|
|
text = refText(text, bytesCount);
|
|
|
|
positions = refBuffer<float>(positions, count * 2);
|
|
|
|
paint = refPaint(paint);
|
2012-02-16 19:24:51 -08:00
|
|
|
|
2012-11-26 18:30:17 -08:00
|
|
|
DrawOp* op = new (alloc()) DrawTextOp(text, bytesCount, count, x, y, positions, paint, length);
|
2013-03-01 14:31:04 -08:00
|
|
|
addDrawOp(op);
|
2012-05-31 15:21:51 -07:00
|
|
|
return DrawGlInfo::kStatusDone;
|
2013-01-04 19:05:13 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
status_t DisplayListRenderer::drawRects(const float* rects, int count, SkPaint* paint) {
|
|
|
|
if (count <= 0) return DrawGlInfo::kStatusDone;
|
|
|
|
|
2012-11-26 18:30:17 -08:00
|
|
|
rects = refBuffer<float>(rects, count);
|
|
|
|
paint = refPaint(paint);
|
|
|
|
addDrawOp(new (alloc()) DrawRectsOp(rects, count, paint));
|
2013-01-04 19:05:13 -08:00
|
|
|
return DrawGlInfo::kStatusDone;
|
2012-01-17 17:39:26 -08:00
|
|
|
}
|
|
|
|
|
2010-09-26 18:40:37 -07:00
|
|
|
void DisplayListRenderer::resetShader() {
|
2012-11-26 18:30:17 -08:00
|
|
|
addStateOp(new (alloc()) ResetShaderOp());
|
2010-09-26 18:40:37 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void DisplayListRenderer::setupShader(SkiaShader* shader) {
|
2012-11-26 18:30:17 -08:00
|
|
|
shader = refShader(shader);
|
|
|
|
addStateOp(new (alloc()) SetupShaderOp(shader));
|
2010-09-26 18:40:37 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void DisplayListRenderer::resetColorFilter() {
|
2012-11-26 18:30:17 -08:00
|
|
|
addStateOp(new (alloc()) ResetColorFilterOp());
|
2010-09-26 18:40:37 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void DisplayListRenderer::setupColorFilter(SkiaColorFilter* filter) {
|
2012-11-26 18:30:17 -08:00
|
|
|
filter = refColorFilter(filter);
|
|
|
|
addStateOp(new (alloc()) SetupColorFilterOp(filter));
|
2010-09-26 18:40:37 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void DisplayListRenderer::resetShadow() {
|
2012-11-26 18:30:17 -08:00
|
|
|
addStateOp(new (alloc()) ResetShadowOp());
|
2010-09-26 18:40:37 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void DisplayListRenderer::setupShadow(float radius, float dx, float dy, int color) {
|
2012-11-26 18:30:17 -08:00
|
|
|
addStateOp(new (alloc()) SetupShadowOp(radius, dx, dy, color));
|
2010-09-26 18:40:37 -07:00
|
|
|
}
|
|
|
|
|
2012-01-23 17:09:05 -08:00
|
|
|
void DisplayListRenderer::resetPaintFilter() {
|
2012-11-26 18:30:17 -08:00
|
|
|
addStateOp(new (alloc()) ResetPaintFilterOp());
|
2012-01-23 17:09:05 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
void DisplayListRenderer::setupPaintFilter(int clearBits, int setBits) {
|
2012-11-26 18:30:17 -08:00
|
|
|
addStateOp(new (alloc()) SetupPaintFilterOp(clearBits, setBits));
|
|
|
|
}
|
|
|
|
|
|
|
|
void DisplayListRenderer::insertRestoreToCount() {
|
|
|
|
if (mRestoreSaveCount >= 0) {
|
|
|
|
DisplayListOp* op = new (alloc()) RestoreToCountOp(mRestoreSaveCount);
|
|
|
|
mDisplayListData->displayListOps.add(op);
|
|
|
|
mRestoreSaveCount = -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void DisplayListRenderer::insertTranslate() {
|
|
|
|
if (mHasTranslate) {
|
|
|
|
if (mTranslateX != 0.0f || mTranslateY != 0.0f) {
|
|
|
|
DisplayListOp* op = new (alloc()) TranslateOp(mTranslateX, mTranslateY);
|
|
|
|
mDisplayListData->displayListOps.add(op);
|
|
|
|
mTranslateX = mTranslateY = 0.0f;
|
|
|
|
}
|
|
|
|
mHasTranslate = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void DisplayListRenderer::addStateOp(StateOp* op) {
|
|
|
|
addOpInternal(op);
|
|
|
|
}
|
|
|
|
|
2013-03-01 14:31:04 -08:00
|
|
|
void DisplayListRenderer::addDrawOp(DrawOp* op) {
|
2012-11-26 18:30:17 -08:00
|
|
|
Rect localBounds;
|
|
|
|
if (op->getLocalBounds(localBounds)) {
|
2013-03-01 14:31:04 -08:00
|
|
|
bool rejected = quickRejectNoScissor(localBounds.left, localBounds.top,
|
2012-11-26 18:30:17 -08:00
|
|
|
localBounds.right, localBounds.bottom);
|
|
|
|
op->setQuickRejected(rejected);
|
|
|
|
}
|
|
|
|
mHasDrawOps = true;
|
|
|
|
addOpInternal(op);
|
2012-01-23 17:09:05 -08:00
|
|
|
}
|
|
|
|
|
2010-09-26 18:40:37 -07:00
|
|
|
}; // namespace uirenderer
|
|
|
|
}; // namespace android
|