Use const where possible for drawing parameters
They should never be modified by a Renderer, only read and copied.
Change-Id: I9d8d55dca19115ee9dfeb2bb3f092ba2fb327cd4
diff --git a/libs/hwui/AssetAtlas.cpp b/libs/hwui/AssetAtlas.cpp
index eb8bb9f..fddfe90 100644
--- a/libs/hwui/AssetAtlas.cpp
+++ b/libs/hwui/AssetAtlas.cpp
@@ -74,12 +74,12 @@
// Entries
///////////////////////////////////////////////////////////////////////////////
-AssetAtlas::Entry* AssetAtlas::getEntry(SkBitmap* const bitmap) const {
+AssetAtlas::Entry* AssetAtlas::getEntry(const SkBitmap* bitmap) const {
ssize_t index = mEntries.indexOfKey(bitmap);
return index >= 0 ? mEntries.valueAt(index) : NULL;
}
-Texture* AssetAtlas::getEntryTexture(SkBitmap* const bitmap) const {
+Texture* AssetAtlas::getEntryTexture(const SkBitmap* bitmap) const {
ssize_t index = mEntries.indexOfKey(bitmap);
return index >= 0 ? mEntries.valueAt(index)->texture : NULL;
}
diff --git a/libs/hwui/AssetAtlas.h b/libs/hwui/AssetAtlas.h
index a28efc6..57c8a60 100644
--- a/libs/hwui/AssetAtlas.h
+++ b/libs/hwui/AssetAtlas.h
@@ -160,13 +160,13 @@
* Returns the entry in the atlas associated with the specified
* bitmap. If the bitmap is not in the atlas, return NULL.
*/
- Entry* getEntry(SkBitmap* const bitmap) const;
+ Entry* getEntry(const SkBitmap* bitmap) const;
/**
* Returns the texture for the atlas entry associated with the
* specified bitmap. If the bitmap is not in the atlas, return NULL.
*/
- Texture* getEntryTexture(SkBitmap* const bitmap) const;
+ Texture* getEntryTexture(const SkBitmap* bitmap) const;
/**
* Returns the current generation id of the atlas.
@@ -186,7 +186,7 @@
const bool mBlendKey;
const bool mOpaqueKey;
- KeyedVector<SkBitmap*, Entry*> mEntries;
+ KeyedVector<const SkBitmap*, Entry*> mEntries;
}; // class AssetAtlas
}; // namespace uirenderer
diff --git a/libs/hwui/DisplayList.cpp b/libs/hwui/DisplayList.cpp
index 2fe141b..8da425d 100644
--- a/libs/hwui/DisplayList.cpp
+++ b/libs/hwui/DisplayList.cpp
@@ -90,7 +90,7 @@
}
for (size_t i = 0; i < mOwnedBitmapResources.size(); i++) {
- SkBitmap* bitmap = mOwnedBitmapResources.itemAt(i);
+ const SkBitmap* bitmap = mOwnedBitmapResources.itemAt(i);
caches.resourceCache.decrementRefcountLocked(bitmap);
caches.resourceCache.destructorLocked(bitmap);
}
@@ -173,16 +173,16 @@
caches.registerFunctors(mFunctorCount);
caches.resourceCache.lock();
- const Vector<SkBitmap*>& bitmapResources = recorder.getBitmapResources();
+ const Vector<const SkBitmap*>& bitmapResources = recorder.getBitmapResources();
for (size_t i = 0; i < bitmapResources.size(); i++) {
- SkBitmap* resource = bitmapResources.itemAt(i);
+ const SkBitmap* resource = bitmapResources.itemAt(i);
mBitmapResources.add(resource);
caches.resourceCache.incrementRefcountLocked(resource);
}
- const Vector<SkBitmap*> &ownedBitmapResources = recorder.getOwnedBitmapResources();
+ const Vector<const SkBitmap*>& ownedBitmapResources = recorder.getOwnedBitmapResources();
for (size_t i = 0; i < ownedBitmapResources.size(); i++) {
- SkBitmap* resource = ownedBitmapResources.itemAt(i);
+ const SkBitmap* resource = ownedBitmapResources.itemAt(i);
mOwnedBitmapResources.add(resource);
caches.resourceCache.incrementRefcountLocked(resource);
}
@@ -194,9 +194,9 @@
caches.resourceCache.incrementRefcountLocked(resource);
}
- const Vector<Res_png_9patch*>& patchResources = recorder.getPatchResources();
+ const Vector<const Res_png_9patch*>& patchResources = recorder.getPatchResources();
for (size_t i = 0; i < patchResources.size(); i++) {
- Res_png_9patch* resource = patchResources.itemAt(i);
+ const Res_png_9patch* resource = patchResources.itemAt(i);
mPatchResources.add(resource);
caches.resourceCache.incrementRefcountLocked(resource);
}
@@ -208,7 +208,7 @@
caches.resourceCache.incrementRefcountLocked(resource);
}
- const SortedVector<SkPath*>& sourcePaths = recorder.getSourcePaths();
+ const SortedVector<const SkPath*>& sourcePaths = recorder.getSourcePaths();
for (size_t i = 0; i < sourcePaths.size(); i++) {
mSourcePaths.add(sourcePaths.itemAt(i));
caches.resourceCache.incrementRefcountLocked(sourcePaths.itemAt(i));
diff --git a/libs/hwui/DisplayList.h b/libs/hwui/DisplayList.h
index 9933d9d..3f9ad9b 100644
--- a/libs/hwui/DisplayList.h
+++ b/libs/hwui/DisplayList.h
@@ -549,16 +549,16 @@
const char* mText;
};
- Vector<SkBitmap*> mBitmapResources;
- Vector<SkBitmap*> mOwnedBitmapResources;
+ Vector<const SkBitmap*> mBitmapResources;
+ Vector<const SkBitmap*> mOwnedBitmapResources;
Vector<SkiaColorFilter*> mFilterResources;
- Vector<Res_png_9patch*> mPatchResources;
+ Vector<const Res_png_9patch*> mPatchResources;
- Vector<SkPaint*> mPaints;
- Vector<SkPath*> mPaths;
- SortedVector<SkPath*> mSourcePaths;
- Vector<SkRegion*> mRegions;
- Vector<SkMatrix*> mMatrices;
+ Vector<const SkPaint*> mPaints;
+ Vector<const SkPath*> mPaths;
+ SortedVector<const SkPath*> mSourcePaths;
+ Vector<const SkRegion*> mRegions;
+ Vector<const SkMatrix*> mMatrices;
Vector<SkiaShader*> mShaders;
Vector<Layer*> mLayers;
diff --git a/libs/hwui/DisplayListOp.h b/libs/hwui/DisplayListOp.h
index 1980b03..c375bfa 100644
--- a/libs/hwui/DisplayListOp.h
+++ b/libs/hwui/DisplayListOp.h
@@ -111,7 +111,7 @@
class DrawOp : public DisplayListOp {
friend class MergingDrawBatch;
public:
- DrawOp(SkPaint* paint)
+ DrawOp(const SkPaint* paint)
: mPaint(paint), mQuickRejected(false) {}
virtual void defer(DeferStateStruct& deferStruct, int saveCount, int level,
@@ -191,7 +191,7 @@
}
protected:
- SkPaint* getPaint(OpenGLRenderer& renderer) {
+ const SkPaint* getPaint(OpenGLRenderer& renderer) {
return renderer.filterPaint(mPaint);
}
@@ -212,22 +212,22 @@
}
- SkPaint* mPaint; // should be accessed via getPaint() when applying
+ const SkPaint* mPaint; // should be accessed via getPaint() when applying
bool mQuickRejected;
};
class DrawBoundedOp : public DrawOp {
public:
- DrawBoundedOp(float left, float top, float right, float bottom, SkPaint* paint)
+ DrawBoundedOp(float left, float top, float right, float bottom, const SkPaint* paint)
: DrawOp(paint), mLocalBounds(left, top, right, bottom) {}
- DrawBoundedOp(const Rect& localBounds, SkPaint* paint)
+ DrawBoundedOp(const Rect& localBounds, const SkPaint* paint)
: DrawOp(paint), mLocalBounds(localBounds) {}
// Calculates bounds as smallest rect encompassing all points
// NOTE: requires at least 1 vertex, and doesn't account for stroke size (should be handled in
// subclass' constructor)
- DrawBoundedOp(const float* points, int count, SkPaint* paint)
+ DrawBoundedOp(const float* points, int count, const SkPaint* paint)
: DrawOp(paint), mLocalBounds(points[0], points[1], points[0], points[1]) {
for (int i = 2; i < count; i += 2) {
mLocalBounds.left = fminf(mLocalBounds.left, points[i]);
@@ -238,7 +238,7 @@
}
// default empty constructor for bounds, to be overridden in child constructor body
- DrawBoundedOp(SkPaint* paint): DrawOp(paint) { }
+ DrawBoundedOp(const SkPaint* paint): DrawOp(paint) { }
bool getLocalBounds(const DrawModifiers& drawModifiers, Rect& localBounds) {
localBounds.set(mLocalBounds);
@@ -456,7 +456,7 @@
class SetMatrixOp : public StateOp {
public:
- SetMatrixOp(SkMatrix* matrix)
+ SetMatrixOp(const SkMatrix* matrix)
: mMatrix(matrix) {}
virtual void applyState(OpenGLRenderer& renderer, int saveCount) const {
@@ -474,12 +474,12 @@
virtual const char* name() { return "SetMatrix"; }
private:
- SkMatrix* mMatrix;
+ const SkMatrix* mMatrix;
};
class ConcatMatrixOp : public StateOp {
public:
- ConcatMatrixOp(SkMatrix* matrix)
+ ConcatMatrixOp(const SkMatrix* matrix)
: mMatrix(matrix) {}
virtual void applyState(OpenGLRenderer& renderer, int saveCount) const {
@@ -493,7 +493,7 @@
virtual const char* name() { return "ConcatMatrix"; }
private:
- SkMatrix* mMatrix;
+ const SkMatrix* mMatrix;
};
class ClipOp : public StateOp {
@@ -551,7 +551,7 @@
class ClipPathOp : public ClipOp {
public:
- ClipPathOp(SkPath* path, SkRegion::Op op)
+ ClipPathOp(const SkPath* path, SkRegion::Op op)
: ClipOp(op), mPath(path) {}
virtual void applyState(OpenGLRenderer& renderer, int saveCount) const {
@@ -567,12 +567,12 @@
virtual const char* name() { return "ClipPath"; }
private:
- SkPath* mPath;
+ const SkPath* mPath;
};
class ClipRegionOp : public ClipOp {
public:
- ClipRegionOp(SkRegion* region, SkRegion::Op op)
+ ClipRegionOp(const SkRegion* region, SkRegion::Op op)
: ClipOp(op), mRegion(region) {}
virtual void applyState(OpenGLRenderer& renderer, int saveCount) const {
@@ -588,7 +588,7 @@
virtual const char* name() { return "ClipRegion"; }
private:
- SkRegion* mRegion;
+ const SkRegion* mRegion;
};
class ResetShaderOp : public StateOp {
@@ -728,7 +728,7 @@
class DrawBitmapOp : public DrawBoundedOp {
public:
- DrawBitmapOp(SkBitmap* bitmap, float left, float top, SkPaint* paint)
+ DrawBitmapOp(const SkBitmap* bitmap, float left, float top, const SkPaint* paint)
: DrawBoundedOp(left, top, left + bitmap->width(), top + bitmap->height(), paint),
mBitmap(bitmap), mAtlas(Caches::getInstance().assetAtlas) {
mEntry = mAtlas.getEntry(bitmap);
@@ -827,7 +827,7 @@
const SkBitmap* bitmap() { return mBitmap; }
protected:
- SkBitmap* mBitmap;
+ const SkBitmap* mBitmap;
const AssetAtlas& mAtlas;
uint32_t mEntryGenerationId;
AssetAtlas::Entry* mEntry;
@@ -836,7 +836,7 @@
class DrawBitmapMatrixOp : public DrawBoundedOp {
public:
- DrawBitmapMatrixOp(SkBitmap* bitmap, SkMatrix* matrix, SkPaint* paint)
+ DrawBitmapMatrixOp(const SkBitmap* bitmap, const SkMatrix* matrix, const SkPaint* paint)
: DrawBoundedOp(paint), mBitmap(bitmap), mMatrix(matrix) {
mLocalBounds.set(0, 0, bitmap->width(), bitmap->height());
const mat4 transform(*matrix);
@@ -859,14 +859,15 @@
}
private:
- SkBitmap* mBitmap;
- SkMatrix* mMatrix;
+ const SkBitmap* mBitmap;
+ const SkMatrix* mMatrix;
};
class DrawBitmapRectOp : public DrawBoundedOp {
public:
- DrawBitmapRectOp(SkBitmap* bitmap, float srcLeft, float srcTop, float srcRight, float srcBottom,
- float dstLeft, float dstTop, float dstRight, float dstBottom, SkPaint* paint)
+ DrawBitmapRectOp(const SkBitmap* bitmap,
+ float srcLeft, float srcTop, float srcRight, float srcBottom,
+ float dstLeft, float dstTop, float dstRight, float dstBottom, const SkPaint* paint)
: DrawBoundedOp(dstLeft, dstTop, dstRight, dstBottom, paint),
mBitmap(bitmap), mSrc(srcLeft, srcTop, srcRight, srcBottom) {}
@@ -889,13 +890,13 @@
}
private:
- SkBitmap* mBitmap;
+ const SkBitmap* mBitmap;
Rect mSrc;
};
class DrawBitmapDataOp : public DrawBitmapOp {
public:
- DrawBitmapDataOp(SkBitmap* bitmap, float left, float top, SkPaint* paint)
+ DrawBitmapDataOp(const SkBitmap* bitmap, float left, float top, const SkPaint* paint)
: DrawBitmapOp(bitmap, left, top, paint) {}
virtual status_t applyDraw(OpenGLRenderer& renderer, Rect& dirty) {
@@ -917,8 +918,8 @@
class DrawBitmapMeshOp : public DrawBoundedOp {
public:
- DrawBitmapMeshOp(SkBitmap* bitmap, int meshWidth, int meshHeight,
- float* vertices, int* colors, SkPaint* paint)
+ DrawBitmapMeshOp(const SkBitmap* bitmap, int meshWidth, int meshHeight,
+ const float* vertices, const int* colors, const SkPaint* paint)
: DrawBoundedOp(vertices, 2 * (meshWidth + 1) * (meshHeight + 1), paint),
mBitmap(bitmap), mMeshWidth(meshWidth), mMeshHeight(meshHeight),
mVertices(vertices), mColors(colors) {}
@@ -940,17 +941,17 @@
}
private:
- SkBitmap* mBitmap;
+ const SkBitmap* mBitmap;
int mMeshWidth;
int mMeshHeight;
- float* mVertices;
- int* mColors;
+ const float* mVertices;
+ const int* mColors;
};
class DrawPatchOp : public DrawBoundedOp {
public:
- DrawPatchOp(SkBitmap* bitmap, Res_png_9patch* patch,
- float left, float top, float right, float bottom, SkPaint* paint)
+ DrawPatchOp(const SkBitmap* bitmap, const Res_png_9patch* patch,
+ float left, float top, float right, float bottom, const SkPaint* paint)
: DrawBoundedOp(left, top, right, bottom, paint),
mBitmap(bitmap), mPatch(patch), mGenerationId(0), mMesh(NULL),
mAtlas(Caches::getInstance().assetAtlas) {
@@ -1082,8 +1083,8 @@
}
private:
- SkBitmap* mBitmap;
- Res_png_9patch* mPatch;
+ const SkBitmap* mBitmap;
+ const Res_png_9patch* mPatch;
uint32_t mGenerationId;
const Patch* mMesh;
@@ -1115,7 +1116,7 @@
class DrawStrokableOp : public DrawBoundedOp {
public:
- DrawStrokableOp(float left, float top, float right, float bottom, SkPaint* paint)
+ DrawStrokableOp(float left, float top, float right, float bottom, const SkPaint* paint)
: DrawBoundedOp(left, top, right, bottom, paint) {};
bool getLocalBounds(const DrawModifiers& drawModifiers, Rect& localBounds) {
@@ -1140,7 +1141,7 @@
class DrawRectOp : public DrawStrokableOp {
public:
- DrawRectOp(float left, float top, float right, float bottom, SkPaint* paint)
+ DrawRectOp(float left, float top, float right, float bottom, const SkPaint* paint)
: DrawStrokableOp(left, top, right, bottom, paint) {}
virtual status_t applyDraw(OpenGLRenderer& renderer, Rect& dirty) {
@@ -1164,7 +1165,7 @@
class DrawRectsOp : public DrawBoundedOp {
public:
- DrawRectsOp(const float* rects, int count, SkPaint* paint)
+ DrawRectsOp(const float* rects, int count, const SkPaint* paint)
: DrawBoundedOp(rects, count, paint),
mRects(rects), mCount(count) {}
@@ -1191,7 +1192,7 @@
class DrawRoundRectOp : public DrawStrokableOp {
public:
DrawRoundRectOp(float left, float top, float right, float bottom,
- float rx, float ry, SkPaint* paint)
+ float rx, float ry, const SkPaint* paint)
: DrawStrokableOp(left, top, right, bottom, paint), mRx(rx), mRy(ry) {}
virtual status_t applyDraw(OpenGLRenderer& renderer, Rect& dirty) {
@@ -1212,7 +1213,7 @@
class DrawCircleOp : public DrawStrokableOp {
public:
- DrawCircleOp(float x, float y, float radius, SkPaint* paint)
+ DrawCircleOp(float x, float y, float radius, const SkPaint* paint)
: DrawStrokableOp(x - radius, y - radius, x + radius, y + radius, paint),
mX(x), mY(y), mRadius(radius) {}
@@ -1234,7 +1235,7 @@
class DrawOvalOp : public DrawStrokableOp {
public:
- DrawOvalOp(float left, float top, float right, float bottom, SkPaint* paint)
+ DrawOvalOp(float left, float top, float right, float bottom, const SkPaint* paint)
: DrawStrokableOp(left, top, right, bottom, paint) {}
virtual status_t applyDraw(OpenGLRenderer& renderer, Rect& dirty) {
@@ -1252,7 +1253,7 @@
class DrawArcOp : public DrawStrokableOp {
public:
DrawArcOp(float left, float top, float right, float bottom,
- float startAngle, float sweepAngle, bool useCenter, SkPaint* paint)
+ float startAngle, float sweepAngle, bool useCenter, const SkPaint* paint)
: DrawStrokableOp(left, top, right, bottom, paint),
mStartAngle(startAngle), mSweepAngle(sweepAngle), mUseCenter(useCenter) {}
@@ -1277,7 +1278,7 @@
class DrawPathOp : public DrawBoundedOp {
public:
- DrawPathOp(SkPath* path, SkPaint* paint)
+ DrawPathOp(const SkPath* path, const SkPaint* paint)
: DrawBoundedOp(paint), mPath(path) {
float left, top, offset;
uint32_t width, height;
@@ -1293,7 +1294,7 @@
virtual void onDefer(OpenGLRenderer& renderer, DeferInfo& deferInfo,
const DeferredDisplayState& state) {
- SkPaint* paint = getPaint(renderer);
+ const SkPaint* paint = getPaint(renderer);
renderer.getCaches().pathCache.precache(mPath, paint);
deferInfo.batchId = DeferredDisplayList::kOpBatch_AlphaMaskTexture;
@@ -1306,12 +1307,12 @@
virtual const char* name() { return "DrawPath"; }
private:
- SkPath* mPath;
+ const SkPath* mPath;
};
class DrawLinesOp : public DrawBoundedOp {
public:
- DrawLinesOp(float* points, int count, SkPaint* paint)
+ DrawLinesOp(const float* points, int count, const SkPaint* paint)
: DrawBoundedOp(points, count, paint),
mPoints(points), mCount(count) {
mLocalBounds.outset(strokeWidthOutset());
@@ -1335,13 +1336,13 @@
}
protected:
- float* mPoints;
+ const float* mPoints;
int mCount;
};
class DrawPointsOp : public DrawLinesOp {
public:
- DrawPointsOp(float* points, int count, SkPaint* paint)
+ DrawPointsOp(const float* points, int count, const SkPaint* paint)
: DrawLinesOp(points, count, paint) {}
virtual status_t applyDraw(OpenGLRenderer& renderer, Rect& dirty) {
@@ -1357,7 +1358,7 @@
class DrawSomeTextOp : public DrawOp {
public:
- DrawSomeTextOp(const char* text, int bytesCount, int count, SkPaint* paint)
+ DrawSomeTextOp(const char* text, int bytesCount, int count, const SkPaint* paint)
: DrawOp(paint), mText(text), mBytesCount(bytesCount), mCount(count) {};
virtual void output(int level, uint32_t logFlags) const {
@@ -1366,7 +1367,7 @@
virtual void onDefer(OpenGLRenderer& renderer, DeferInfo& deferInfo,
const DeferredDisplayState& state) {
- SkPaint* paint = getPaint(renderer);
+ const SkPaint* paint = getPaint(renderer);
FontRenderer& fontRenderer = renderer.getCaches().fontRenderer->getFontRenderer(paint);
fontRenderer.precache(paint, mText, mCount, mat4::identity());
@@ -1384,7 +1385,7 @@
class DrawTextOnPathOp : public DrawSomeTextOp {
public:
DrawTextOnPathOp(const char* text, int bytesCount, int count,
- SkPath* path, float hOffset, float vOffset, SkPaint* paint)
+ const SkPath* path, float hOffset, float vOffset, const SkPaint* paint)
: DrawSomeTextOp(text, bytesCount, count, paint),
mPath(path), mHOffset(hOffset), mVOffset(vOffset) {
/* TODO: inherit from DrawBounded and init mLocalBounds */
@@ -1398,7 +1399,7 @@
virtual const char* name() { return "DrawTextOnPath"; }
private:
- SkPath* mPath;
+ const SkPath* mPath;
float mHOffset;
float mVOffset;
};
@@ -1406,7 +1407,7 @@
class DrawPosTextOp : public DrawSomeTextOp {
public:
DrawPosTextOp(const char* text, int bytesCount, int count,
- const float* positions, SkPaint* paint)
+ const float* positions, const SkPaint* paint)
: DrawSomeTextOp(text, bytesCount, count, paint), mPositions(positions) {
/* TODO: inherit from DrawBounded and init mLocalBounds */
}
@@ -1424,7 +1425,7 @@
class DrawTextOp : public DrawBoundedOp {
public:
DrawTextOp(const char* text, int bytesCount, int count, float x, float y,
- const float* positions, SkPaint* paint, float totalAdvance, const Rect& bounds)
+ const float* positions, const SkPaint* paint, float totalAdvance, const Rect& bounds)
: DrawBoundedOp(bounds, paint), mText(text), mBytesCount(bytesCount), mCount(count),
mX(x), mY(y), mPositions(positions), mTotalAdvance(totalAdvance) {
memset(&mPrecacheTransform.data[0], 0xff, 16 * sizeof(float));
@@ -1432,7 +1433,7 @@
virtual void onDefer(OpenGLRenderer& renderer, DeferInfo& deferInfo,
const DeferredDisplayState& state) {
- SkPaint* paint = getPaint(renderer);
+ const SkPaint* paint = getPaint(renderer);
FontRenderer& fontRenderer = renderer.getCaches().fontRenderer->getFontRenderer(paint);
const mat4& transform = renderer.findBestFontTransform(state.mMatrix);
if (mPrecacheTransform != transform) {
diff --git a/libs/hwui/DisplayListRenderer.cpp b/libs/hwui/DisplayListRenderer.cpp
index 0376db7..051ccfe 100644
--- a/libs/hwui/DisplayListRenderer.cpp
+++ b/libs/hwui/DisplayListRenderer.cpp
@@ -203,13 +203,13 @@
StatefulBaseRenderer::skew(sx, sy);
}
-void DisplayListRenderer::setMatrix(SkMatrix* matrix) {
+void DisplayListRenderer::setMatrix(const SkMatrix* matrix) {
matrix = refMatrix(matrix);
addStateOp(new (alloc()) SetMatrixOp(matrix));
StatefulBaseRenderer::setMatrix(matrix);
}
-void DisplayListRenderer::concatMatrix(SkMatrix* matrix) {
+void DisplayListRenderer::concatMatrix(const SkMatrix* matrix) {
matrix = refMatrix(matrix);
addStateOp(new (alloc()) ConcatMatrixOp(matrix));
StatefulBaseRenderer::concatMatrix(matrix);
@@ -221,13 +221,13 @@
return StatefulBaseRenderer::clipRect(left, top, right, bottom, op);
}
-bool DisplayListRenderer::clipPath(SkPath* path, SkRegion::Op op) {
+bool DisplayListRenderer::clipPath(const SkPath* path, SkRegion::Op op) {
path = refPath(path);
addStateOp(new (alloc()) ClipPathOp(path, op));
return StatefulBaseRenderer::clipPath(path, op);
}
-bool DisplayListRenderer::clipRegion(SkRegion* region, SkRegion::Op op) {
+bool DisplayListRenderer::clipRegion(const SkRegion* region, SkRegion::Op op) {
region = refRegion(region);
addStateOp(new (alloc()) ClipRegionOp(region, op));
return StatefulBaseRenderer::clipRegion(region, op);
@@ -256,7 +256,8 @@
return DrawGlInfo::kStatusDone;
}
-status_t DisplayListRenderer::drawBitmap(SkBitmap* bitmap, float left, float top, SkPaint* paint) {
+status_t DisplayListRenderer::drawBitmap(const SkBitmap* bitmap, float left, float top,
+ const SkPaint* paint) {
bitmap = refBitmap(bitmap);
paint = refPaint(paint);
@@ -264,7 +265,8 @@
return DrawGlInfo::kStatusDone;
}
-status_t DisplayListRenderer::drawBitmap(SkBitmap* bitmap, SkMatrix* matrix, SkPaint* paint) {
+status_t DisplayListRenderer::drawBitmap(const SkBitmap* bitmap, const SkMatrix* matrix,
+ const SkPaint* paint) {
bitmap = refBitmap(bitmap);
matrix = refMatrix(matrix);
paint = refPaint(paint);
@@ -273,9 +275,9 @@
return DrawGlInfo::kStatusDone;
}
-status_t DisplayListRenderer::drawBitmap(SkBitmap* bitmap, float srcLeft, float srcTop,
+status_t DisplayListRenderer::drawBitmap(const SkBitmap* bitmap, float srcLeft, float srcTop,
float srcRight, float srcBottom, float dstLeft, float dstTop,
- float dstRight, float dstBottom, SkPaint* paint) {
+ float dstRight, float dstBottom, const SkPaint* paint) {
bitmap = refBitmap(bitmap);
paint = refPaint(paint);
@@ -294,8 +296,8 @@
return DrawGlInfo::kStatusDone;
}
-status_t DisplayListRenderer::drawBitmapData(SkBitmap* bitmap, float left, float top,
- SkPaint* paint) {
+status_t DisplayListRenderer::drawBitmapData(const SkBitmap* bitmap, float left, float top,
+ const SkPaint* paint) {
bitmap = refBitmapData(bitmap);
paint = refPaint(paint);
@@ -303,8 +305,8 @@
return DrawGlInfo::kStatusDone;
}
-status_t DisplayListRenderer::drawBitmapMesh(SkBitmap* bitmap, int meshWidth, int meshHeight,
- float* vertices, int* colors, SkPaint* paint) {
+status_t DisplayListRenderer::drawBitmapMesh(const SkBitmap* bitmap, int meshWidth, int meshHeight,
+ const float* vertices, const int* colors, const SkPaint* paint) {
int count = (meshWidth + 1) * (meshHeight + 1) * 2;
bitmap = refBitmap(bitmap);
vertices = refBuffer<float>(vertices, count);
@@ -316,8 +318,8 @@
return DrawGlInfo::kStatusDone;
}
-status_t DisplayListRenderer::drawPatch(SkBitmap* bitmap, Res_png_9patch* patch,
- float left, float top, float right, float bottom, SkPaint* paint) {
+status_t DisplayListRenderer::drawPatch(const SkBitmap* bitmap, const Res_png_9patch* patch,
+ float left, float top, float right, float bottom, const SkPaint* paint) {
bitmap = refBitmap(bitmap);
patch = refPatch(patch);
paint = refPaint(paint);
@@ -332,41 +334,41 @@
}
status_t DisplayListRenderer::drawRect(float left, float top, float right, float bottom,
- SkPaint* paint) {
+ const SkPaint* paint) {
paint = refPaint(paint);
addDrawOp(new (alloc()) DrawRectOp(left, top, right, bottom, paint));
return DrawGlInfo::kStatusDone;
}
status_t DisplayListRenderer::drawRoundRect(float left, float top, float right, float bottom,
- float rx, float ry, SkPaint* paint) {
+ float rx, float ry, const SkPaint* paint) {
paint = refPaint(paint);
addDrawOp(new (alloc()) DrawRoundRectOp(left, top, right, bottom, rx, ry, paint));
return DrawGlInfo::kStatusDone;
}
-status_t DisplayListRenderer::drawCircle(float x, float y, float radius, SkPaint* paint) {
+status_t DisplayListRenderer::drawCircle(float x, float y, float radius, const SkPaint* paint) {
paint = refPaint(paint);
addDrawOp(new (alloc()) DrawCircleOp(x, y, radius, paint));
return DrawGlInfo::kStatusDone;
}
status_t DisplayListRenderer::drawOval(float left, float top, float right, float bottom,
- SkPaint* paint) {
+ const SkPaint* paint) {
paint = refPaint(paint);
addDrawOp(new (alloc()) DrawOvalOp(left, top, right, bottom, paint));
return DrawGlInfo::kStatusDone;
}
status_t DisplayListRenderer::drawArc(float left, float top, float right, float bottom,
- float startAngle, float sweepAngle, bool useCenter, SkPaint* paint) {
+ float startAngle, float sweepAngle, bool useCenter, const SkPaint* paint) {
paint = refPaint(paint);
addDrawOp(new (alloc()) DrawArcOp(left, top, right, bottom,
startAngle, sweepAngle, useCenter, paint));
return DrawGlInfo::kStatusDone;
}
-status_t DisplayListRenderer::drawPath(SkPath* path, SkPaint* paint) {
+status_t DisplayListRenderer::drawPath(const SkPath* path, const SkPaint* paint) {
path = refPath(path);
paint = refPaint(paint);
@@ -374,7 +376,7 @@
return DrawGlInfo::kStatusDone;
}
-status_t DisplayListRenderer::drawLines(float* points, int count, SkPaint* paint) {
+status_t DisplayListRenderer::drawLines(const float* points, int count, const SkPaint* paint) {
points = refBuffer<float>(points, count);
paint = refPaint(paint);
@@ -382,7 +384,7 @@
return DrawGlInfo::kStatusDone;
}
-status_t DisplayListRenderer::drawPoints(float* points, int count, SkPaint* paint) {
+status_t DisplayListRenderer::drawPoints(const float* points, int count, const SkPaint* paint) {
points = refBuffer<float>(points, count);
paint = refPaint(paint);
@@ -391,7 +393,7 @@
}
status_t DisplayListRenderer::drawTextOnPath(const char* text, int bytesCount, int count,
- SkPath* path, float hOffset, float vOffset, SkPaint* paint) {
+ const SkPath* path, float hOffset, float vOffset, const SkPaint* paint) {
if (!text || count <= 0) return DrawGlInfo::kStatusDone;
text = refText(text, bytesCount);
@@ -405,7 +407,7 @@
}
status_t DisplayListRenderer::drawPosText(const char* text, int bytesCount, int count,
- const float* positions, SkPaint* paint) {
+ const float* positions, const SkPaint* paint) {
if (!text || count <= 0) return DrawGlInfo::kStatusDone;
text = refText(text, bytesCount);
@@ -418,7 +420,7 @@
}
status_t DisplayListRenderer::drawText(const char* text, int bytesCount, int count,
- float x, float y, const float* positions, SkPaint* paint,
+ float x, float y, const float* positions, const SkPaint* paint,
float totalAdvance, const Rect& bounds, DrawOpMode drawOpMode) {
if (!text || count <= 0) return DrawGlInfo::kStatusDone;
@@ -433,7 +435,7 @@
return DrawGlInfo::kStatusDone;
}
-status_t DisplayListRenderer::drawRects(const float* rects, int count, SkPaint* paint) {
+status_t DisplayListRenderer::drawRects(const float* rects, int count, const SkPaint* paint) {
if (count <= 0) return DrawGlInfo::kStatusDone;
rects = refBuffer<float>(rects, count);
diff --git a/libs/hwui/DisplayListRenderer.h b/libs/hwui/DisplayListRenderer.h
index 4326c90..f129c10 100644
--- a/libs/hwui/DisplayListRenderer.h
+++ b/libs/hwui/DisplayListRenderer.h
@@ -90,13 +90,13 @@
virtual void scale(float sx, float sy);
virtual void skew(float sx, float sy);
- virtual void setMatrix(SkMatrix* matrix);
- virtual void concatMatrix(SkMatrix* matrix);
+ virtual void setMatrix(const SkMatrix* matrix);
+ virtual void concatMatrix(const SkMatrix* matrix);
// Clip
virtual bool clipRect(float left, float top, float right, float bottom, SkRegion::Op op);
- virtual bool clipPath(SkPath* path, SkRegion::Op op);
- virtual bool clipRegion(SkRegion* region, SkRegion::Op op);
+ virtual bool clipPath(const SkPath* path, SkRegion::Op op);
+ virtual bool clipRegion(const SkRegion* region, SkRegion::Op op);
// Misc - should be implemented with SkPaint inspection
virtual void resetShader();
@@ -117,38 +117,43 @@
virtual status_t drawColor(int color, SkXfermode::Mode mode);
// Bitmap-based
- virtual status_t drawBitmap(SkBitmap* bitmap, float left, float top, SkPaint* paint);
- virtual status_t drawBitmap(SkBitmap* bitmap, SkMatrix* matrix, SkPaint* paint);
- virtual status_t drawBitmap(SkBitmap* bitmap, float srcLeft, float srcTop,
+ virtual status_t drawBitmap(const SkBitmap* bitmap, float left, float top,
+ const SkPaint* paint);
+ virtual status_t drawBitmap(const SkBitmap* bitmap, const SkMatrix* matrix,
+ const SkPaint* paint);
+ virtual status_t drawBitmap(const SkBitmap* bitmap, float srcLeft, float srcTop,
float srcRight, float srcBottom, float dstLeft, float dstTop,
- float dstRight, float dstBottom, SkPaint* paint);
- virtual status_t drawBitmapData(SkBitmap* bitmap, float left, float top, SkPaint* paint);
- virtual status_t drawBitmapMesh(SkBitmap* bitmap, int meshWidth, int meshHeight,
- float* vertices, int* colors, SkPaint* paint);
- virtual status_t drawPatch(SkBitmap* bitmap, Res_png_9patch* patch,
- float left, float top, float right, float bottom, SkPaint* paint);
+ float dstRight, float dstBottom, const SkPaint* paint);
+ virtual status_t drawBitmapData(const SkBitmap* bitmap, float left, float top,
+ const SkPaint* paint);
+ virtual status_t drawBitmapMesh(const SkBitmap* bitmap, int meshWidth, int meshHeight,
+ const float* vertices, const int* colors, const SkPaint* paint);
+ virtual status_t drawPatch(const SkBitmap* bitmap, const Res_png_9patch* patch,
+ float left, float top, float right, float bottom, const SkPaint* paint);
// Shapes
- virtual status_t drawRect(float left, float top, float right, float bottom, SkPaint* paint);
- virtual status_t drawRects(const float* rects, int count, SkPaint* paint);
+ virtual status_t drawRect(float left, float top, float right, float bottom,
+ const SkPaint* paint);
+ virtual status_t drawRects(const float* rects, int count, const SkPaint* paint);
virtual status_t drawRoundRect(float left, float top, float right, float bottom,
- float rx, float ry, SkPaint* paint);
- virtual status_t drawCircle(float x, float y, float radius, SkPaint* paint);
- virtual status_t drawOval(float left, float top, float right, float bottom, SkPaint* paint);
+ float rx, float ry, const SkPaint* paint);
+ virtual status_t drawCircle(float x, float y, float radius, const SkPaint* paint);
+ virtual status_t drawOval(float left, float top, float right, float bottom,
+ const SkPaint* paint);
virtual status_t drawArc(float left, float top, float right, float bottom,
- float startAngle, float sweepAngle, bool useCenter, SkPaint* paint);
- virtual status_t drawPath(SkPath* path, SkPaint* paint);
- virtual status_t drawLines(float* points, int count, SkPaint* paint);
- virtual status_t drawPoints(float* points, int count, SkPaint* paint);
+ float startAngle, float sweepAngle, bool useCenter, const SkPaint* paint);
+ virtual status_t drawPath(const SkPath* path, const SkPaint* paint);
+ virtual status_t drawLines(const float* points, int count, const SkPaint* paint);
+ virtual status_t drawPoints(const float* points, int count, const SkPaint* paint);
// Text
virtual status_t drawText(const char* text, int bytesCount, int count, float x, float y,
- const float* positions, SkPaint* paint, float totalAdvance, const Rect& bounds,
+ const float* positions, const SkPaint* paint, float totalAdvance, const Rect& bounds,
DrawOpMode drawOpMode = kDrawOpMode_Immediate);
- virtual status_t drawTextOnPath(const char* text, int bytesCount, int count, SkPath* path,
- float hOffset, float vOffset, SkPaint* paint);
+ virtual status_t drawTextOnPath(const char* text, int bytesCount, int count, const SkPath* path,
+ float hOffset, float vOffset, const SkPaint* paint);
virtual status_t drawPosText(const char* text, int bytesCount, int count,
- const float* positions, SkPaint* paint);
+ const float* positions, const SkPaint* paint);
// ----------------------------------------------------------------------------
// Canvas draw operations - special
@@ -169,11 +174,11 @@
return mDisplayListData;
}
- const Vector<SkBitmap*>& getBitmapResources() const {
+ const Vector<const SkBitmap*>& getBitmapResources() const {
return mBitmapResources;
}
- const Vector<SkBitmap*>& getOwnedBitmapResources() const {
+ const Vector<const SkBitmap*>& getOwnedBitmapResources() const {
return mOwnedBitmapResources;
}
@@ -181,7 +186,7 @@
return mFilterResources;
}
- const Vector<Res_png_9patch*>& getPatchResources() const {
+ const Vector<const Res_png_9patch*>& getPatchResources() const {
return mPatchResources;
}
@@ -189,19 +194,19 @@
return mShaders;
}
- const Vector<SkPaint*>& getPaints() const {
+ const Vector<const SkPaint*>& getPaints() const {
return mPaints;
}
- const Vector<SkPath*>& getPaths() const {
+ const Vector<const SkPath*>& getPaths() const {
return mPaths;
}
- const SortedVector<SkPath*>& getSourcePaths() const {
+ const SortedVector<const SkPath*>& getSourcePaths() const {
return mSourcePaths;
}
- const Vector<SkRegion*>& getRegions() const {
+ const Vector<const SkRegion*>& getRegions() const {
return mRegions;
}
@@ -209,7 +214,7 @@
return mLayers;
}
- const Vector<SkMatrix*>& getMatrices() const {
+ const Vector<const SkMatrix*>& getMatrices() const {
return mMatrices;
}
@@ -231,8 +236,9 @@
}
template<class T>
- inline T* refBuffer(const T* srcBuffer, int32_t count) {
- if (srcBuffer == NULL) return NULL;
+ inline const T* refBuffer(const T* srcBuffer, int32_t count) {
+ if (!srcBuffer) return NULL;
+
T* dstBuffer = (T*) mDisplayListData->allocator.alloc(count * sizeof(T));
memcpy(dstBuffer, srcBuffer, count * sizeof(T));
return dstBuffer;
@@ -242,13 +248,15 @@
return (char*) refBuffer<uint8_t>((uint8_t*)text, byteLength);
}
- inline SkPath* refPath(SkPath* path) {
+ inline const SkPath* refPath(const SkPath* path) {
if (!path) return NULL;
- SkPath* pathCopy = mPathMap.valueFor(path);
+ const SkPath* pathCopy = mPathMap.valueFor(path);
if (pathCopy == NULL || pathCopy->getGenerationID() != path->getGenerationID()) {
- pathCopy = new SkPath(*path);
- pathCopy->setSourcePath(path);
+ SkPath* newPathCopy = new SkPath(*path);
+ newPathCopy->setSourcePath(path);
+
+ pathCopy = newPathCopy;
// replaceValueFor() performs an add if the entry doesn't exist
mPathMap.replaceValueFor(path, pathCopy);
mPaths.add(pathCopy);
@@ -260,12 +268,12 @@
return pathCopy;
}
- inline SkPaint* refPaint(SkPaint* paint) {
+ inline const SkPaint* refPaint(const SkPaint* paint) {
if (!paint) {
return paint;
}
- SkPaint* paintCopy = mPaintMap.valueFor(paint);
+ const SkPaint* paintCopy = mPaintMap.valueFor(paint);
if (paintCopy == NULL || paintCopy->getGenerationID() != paint->getGenerationID()) {
paintCopy = new SkPaint(*paint);
// replaceValueFor() performs an add if the entry doesn't exist
@@ -276,12 +284,12 @@
return paintCopy;
}
- inline SkRegion* refRegion(SkRegion* region) {
+ inline const SkRegion* refRegion(const SkRegion* region) {
if (!region) {
return region;
}
- SkRegion* regionCopy = mRegionMap.valueFor(region);
+ const SkRegion* regionCopy = mRegionMap.valueFor(region);
// TODO: Add generation ID to SkRegion
if (regionCopy == NULL) {
regionCopy = new SkRegion(*region);
@@ -293,11 +301,11 @@
return regionCopy;
}
- inline SkMatrix* refMatrix(SkMatrix* matrix) {
+ inline const SkMatrix* refMatrix(const SkMatrix* matrix) {
if (matrix) {
// Copying the matrix is cheap and prevents against the user changing
// the original matrix before the operation that uses it
- SkMatrix* copy = new SkMatrix(*matrix);
+ const SkMatrix* copy = new SkMatrix(*matrix);
mMatrices.add(copy);
return copy;
}
@@ -310,7 +318,7 @@
return layer;
}
- inline SkBitmap* refBitmap(SkBitmap* bitmap) {
+ inline const SkBitmap* refBitmap(const SkBitmap* bitmap) {
// Note that this assumes the bitmap is immutable. There are cases this won't handle
// correctly, such as creating the bitmap from scratch, drawing with it, changing its
// contents, and drawing again. The only fix would be to always copy it the first time,
@@ -320,7 +328,7 @@
return bitmap;
}
- inline SkBitmap* refBitmapData(SkBitmap* bitmap) {
+ inline const SkBitmap* refBitmapData(const SkBitmap* bitmap) {
mOwnedBitmapResources.add(bitmap);
mCaches.resourceCache.incrementRefcount(bitmap);
return bitmap;
@@ -347,33 +355,33 @@
return colorFilter;
}
- inline Res_png_9patch* refPatch(Res_png_9patch* patch) {
+ inline const Res_png_9patch* refPatch(const Res_png_9patch* patch) {
mPatchResources.add(patch);
mCaches.resourceCache.incrementRefcount(patch);
return patch;
}
// TODO: move these to DisplayListData
- Vector<SkBitmap*> mBitmapResources;
- Vector<SkBitmap*> mOwnedBitmapResources;
+ Vector<const SkBitmap*> mBitmapResources;
+ Vector<const SkBitmap*> mOwnedBitmapResources;
Vector<SkiaColorFilter*> mFilterResources;
- Vector<Res_png_9patch*> mPatchResources;
+ Vector<const Res_png_9patch*> mPatchResources;
- Vector<SkPaint*> mPaints;
- DefaultKeyedVector<SkPaint*, SkPaint*> mPaintMap;
+ Vector<const SkPaint*> mPaints;
+ DefaultKeyedVector<const SkPaint*, const SkPaint*> mPaintMap;
- Vector<SkPath*> mPaths;
- DefaultKeyedVector<SkPath*, SkPath*> mPathMap;
+ Vector<const SkPath*> mPaths;
+ DefaultKeyedVector<const SkPath*, const SkPath*> mPathMap;
- SortedVector<SkPath*> mSourcePaths;
+ SortedVector<const SkPath*> mSourcePaths;
- Vector<SkRegion*> mRegions;
- DefaultKeyedVector<SkRegion*, SkRegion*> mRegionMap;
+ Vector<const SkRegion*> mRegions;
+ DefaultKeyedVector<const SkRegion*, const SkRegion*> mRegionMap;
Vector<SkiaShader*> mShaders;
DefaultKeyedVector<SkiaShader*, SkiaShader*> mShaderMap;
- Vector<SkMatrix*> mMatrices;
+ Vector<const SkMatrix*> mMatrices;
Vector<Layer*> mLayers;
diff --git a/libs/hwui/FontRenderer.cpp b/libs/hwui/FontRenderer.cpp
index f7493a3..f907d64 100644
--- a/libs/hwui/FontRenderer.cpp
+++ b/libs/hwui/FontRenderer.cpp
@@ -587,11 +587,11 @@
}
}
-void FontRenderer::setFont(SkPaint* paint, const mat4& matrix) {
+void FontRenderer::setFont(const SkPaint* paint, const mat4& matrix) {
mCurrentFont = Font::create(this, paint, matrix);
}
-FontRenderer::DropShadow FontRenderer::renderDropShadow(SkPaint* paint, const char *text,
+FontRenderer::DropShadow FontRenderer::renderDropShadow(const SkPaint* paint, const char *text,
uint32_t startIndex, uint32_t len, int numGlyphs, uint32_t radius, const float* positions) {
checkInit();
@@ -676,7 +676,8 @@
issueDrawCommand();
}
-void FontRenderer::precache(SkPaint* paint, const char* text, int numGlyphs, const mat4& matrix) {
+void FontRenderer::precache(const SkPaint* paint, const char* text, int numGlyphs,
+ const mat4& matrix) {
Font* font = Font::create(this, paint, matrix);
font->precache(paint, text, numGlyphs);
}
@@ -685,7 +686,7 @@
checkTextureUpdate();
}
-bool FontRenderer::renderPosText(SkPaint* paint, const Rect* clip, const char *text,
+bool FontRenderer::renderPosText(const SkPaint* paint, const Rect* clip, const char *text,
uint32_t startIndex, uint32_t len, int numGlyphs, int x, int y,
const float* positions, Rect* bounds, Functor* functor, bool forceFinish) {
if (!mCurrentFont) {
@@ -703,8 +704,8 @@
return mDrawn;
}
-bool FontRenderer::renderTextOnPath(SkPaint* paint, const Rect* clip, const char *text,
- uint32_t startIndex, uint32_t len, int numGlyphs, SkPath* path,
+bool FontRenderer::renderTextOnPath(const SkPaint* paint, const Rect* clip, const char *text,
+ uint32_t startIndex, uint32_t len, int numGlyphs, const SkPath* path,
float hOffset, float vOffset, Rect* bounds, Functor* functor) {
if (!mCurrentFont) {
ALOGE("No font set");
diff --git a/libs/hwui/FontRenderer.h b/libs/hwui/FontRenderer.h
index db4e020..9259028 100644
--- a/libs/hwui/FontRenderer.h
+++ b/libs/hwui/FontRenderer.h
@@ -62,7 +62,7 @@
};
TextSetupFunctor(OpenGLRenderer* renderer, float x, float y, bool pureTranslate,
- int alpha, SkXfermode::Mode mode, SkPaint* paint): Functor(),
+ int alpha, SkXfermode::Mode mode, const SkPaint* paint): Functor(),
renderer(renderer), x(x), y(y), pureTranslate(pureTranslate),
alpha(alpha), mode(mode), paint(paint) {
}
@@ -76,7 +76,7 @@
bool pureTranslate;
int alpha;
SkXfermode::Mode mode;
- SkPaint* paint;
+ const SkPaint* paint;
};
///////////////////////////////////////////////////////////////////////////////
@@ -95,20 +95,20 @@
mGammaTable = gammaTable;
}
- void setFont(SkPaint* paint, const mat4& matrix);
+ void setFont(const SkPaint* paint, const mat4& matrix);
- void precache(SkPaint* paint, const char* text, int numGlyphs, const mat4& matrix);
+ void precache(const SkPaint* paint, const char* text, int numGlyphs, const mat4& matrix);
void endPrecaching();
// bounds is an out parameter
- bool renderPosText(SkPaint* paint, const Rect* clip, const char *text, uint32_t startIndex,
- uint32_t len, int numGlyphs, int x, int y, const float* positions, Rect* bounds,
- Functor* functor, bool forceFinish = true);
+ bool renderPosText(const SkPaint* paint, const Rect* clip, const char *text,
+ uint32_t startIndex, uint32_t len, int numGlyphs, int x, int y, const float* positions,
+ Rect* bounds, Functor* functor, bool forceFinish = true);
// bounds is an out parameter
- bool renderTextOnPath(SkPaint* paint, const Rect* clip, const char *text, uint32_t startIndex,
- uint32_t len, int numGlyphs, SkPath* path, float hOffset, float vOffset, Rect* bounds,
- Functor* functor);
+ bool renderTextOnPath(const SkPaint* paint, const Rect* clip, const char *text,
+ uint32_t startIndex, uint32_t len, int numGlyphs, const SkPath* path,
+ float hOffset, float vOffset, Rect* bounds, Functor* functor);
struct DropShadow {
DropShadow() { };
@@ -128,7 +128,7 @@
// After renderDropShadow returns, the called owns the memory in DropShadow.image
// and is responsible for releasing it when it's done with it
- DropShadow renderDropShadow(SkPaint* paint, const char *text, uint32_t startIndex,
+ DropShadow renderDropShadow(const SkPaint* paint, const char *text, uint32_t startIndex,
uint32_t len, int numGlyphs, uint32_t radius, const float* positions);
void setTextureFiltering(bool linearFiltering) {
diff --git a/libs/hwui/OpenGLRenderer.cpp b/libs/hwui/OpenGLRenderer.cpp
index 545d3b6..22cd2d4 100644
--- a/libs/hwui/OpenGLRenderer.cpp
+++ b/libs/hwui/OpenGLRenderer.cpp
@@ -1547,7 +1547,7 @@
* style, and tessellated AA ramp
*/
bool OpenGLRenderer::quickRejectSetupScissor(float left, float top, float right, float bottom,
- SkPaint* paint) {
+ const SkPaint* paint) {
bool clipRequired = false;
bool snapOut = paint && paint->isAntiAlias();
@@ -1895,7 +1895,7 @@
return DrawGlInfo::kStatusDone;
}
-void OpenGLRenderer::drawAlphaBitmap(Texture* texture, float left, float top, SkPaint* paint) {
+void OpenGLRenderer::drawAlphaBitmap(Texture* texture, float left, float top, const SkPaint* paint) {
int alpha;
SkXfermode::Mode mode;
getAlphaAndMode(paint, &alpha, &mode);
@@ -1930,8 +1930,9 @@
* will not set the scissor enable or dirty the current layer, if any.
* The caller is responsible for properly dirtying the current layer.
*/
-status_t OpenGLRenderer::drawBitmaps(SkBitmap* bitmap, AssetAtlas::Entry* entry, int bitmapCount,
- TextureVertex* vertices, bool pureTranslate, const Rect& bounds, SkPaint* paint) {
+status_t OpenGLRenderer::drawBitmaps(const SkBitmap* bitmap, AssetAtlas::Entry* entry,
+ int bitmapCount, TextureVertex* vertices, bool pureTranslate,
+ const Rect& bounds, const SkPaint* paint) {
mCaches.activeTexture(0);
Texture* texture = entry ? entry->texture : mCaches.textureCache.get(bitmap);
if (!texture) return DrawGlInfo::kStatusDone;
@@ -1965,7 +1966,8 @@
return DrawGlInfo::kStatusDrew;
}
-status_t OpenGLRenderer::drawBitmap(SkBitmap* bitmap, float left, float top, SkPaint* paint) {
+status_t OpenGLRenderer::drawBitmap(const SkBitmap* bitmap, float left, float top,
+ const SkPaint* paint) {
const float right = left + bitmap->width();
const float bottom = top + bitmap->height();
@@ -1987,7 +1989,8 @@
return DrawGlInfo::kStatusDrew;
}
-status_t OpenGLRenderer::drawBitmap(SkBitmap* bitmap, SkMatrix* matrix, SkPaint* paint) {
+status_t OpenGLRenderer::drawBitmap(const SkBitmap* bitmap, const SkMatrix* matrix,
+ const SkPaint* paint) {
Rect r(0.0f, 0.0f, bitmap->width(), bitmap->height());
const mat4 transform(*matrix);
transform.mapRect(r);
@@ -2015,7 +2018,8 @@
return DrawGlInfo::kStatusDrew;
}
-status_t OpenGLRenderer::drawBitmapData(SkBitmap* bitmap, float left, float top, SkPaint* paint) {
+status_t OpenGLRenderer::drawBitmapData(const SkBitmap* bitmap, float left, float top,
+ const SkPaint* paint) {
const float right = left + bitmap->width();
const float bottom = top + bitmap->height();
@@ -2036,8 +2040,8 @@
return DrawGlInfo::kStatusDrew;
}
-status_t OpenGLRenderer::drawBitmapMesh(SkBitmap* bitmap, int meshWidth, int meshHeight,
- float* vertices, int* colors, SkPaint* paint) {
+status_t OpenGLRenderer::drawBitmapMesh(const SkBitmap* bitmap, int meshWidth, int meshHeight,
+ const float* vertices, const int* colors, const SkPaint* paint) {
if (!vertices || currentSnapshot()->isIgnored()) {
return DrawGlInfo::kStatusDone;
}
@@ -2059,8 +2063,9 @@
bool cleanupColors = false;
if (!colors) {
uint32_t colorsCount = (meshWidth + 1) * (meshHeight + 1);
- colors = new int[colorsCount];
- memset(colors, 0xff, colorsCount * sizeof(int));
+ int* newColors = new int[colorsCount];
+ memset(newColors, 0xff, colorsCount * sizeof(int));
+ colors = newColors;
cleanupColors = true;
}
@@ -2155,10 +2160,10 @@
return DrawGlInfo::kStatusDrew;
}
-status_t OpenGLRenderer::drawBitmap(SkBitmap* bitmap,
+status_t OpenGLRenderer::drawBitmap(const SkBitmap* bitmap,
float srcLeft, float srcTop, float srcRight, float srcBottom,
float dstLeft, float dstTop, float dstRight, float dstBottom,
- SkPaint* paint) {
+ const SkPaint* paint) {
if (quickRejectSetupScissor(dstLeft, dstTop, dstRight, dstBottom)) {
return DrawGlInfo::kStatusDone;
}
@@ -2247,8 +2252,8 @@
return DrawGlInfo::kStatusDrew;
}
-status_t OpenGLRenderer::drawPatch(SkBitmap* bitmap, Res_png_9patch* patch,
- float left, float top, float right, float bottom, SkPaint* paint) {
+status_t OpenGLRenderer::drawPatch(const SkBitmap* bitmap, const Res_png_9patch* patch,
+ float left, float top, float right, float bottom, const SkPaint* paint) {
if (quickRejectSetupScissor(left, top, right, bottom)) {
return DrawGlInfo::kStatusDone;
}
@@ -2260,8 +2265,9 @@
return drawPatch(bitmap, mesh, entry, left, top, right, bottom, paint);
}
-status_t OpenGLRenderer::drawPatch(SkBitmap* bitmap, const Patch* mesh, AssetAtlas::Entry* entry,
- float left, float top, float right, float bottom, SkPaint* paint) {
+status_t OpenGLRenderer::drawPatch(const SkBitmap* bitmap, const Patch* mesh,
+ AssetAtlas::Entry* entry, float left, float top, float right, float bottom,
+ const SkPaint* paint) {
if (quickRejectSetupScissor(left, top, right, bottom)) {
return DrawGlInfo::kStatusDone;
}
@@ -2323,8 +2329,8 @@
* will not set the scissor enable or dirty the current layer, if any.
* The caller is responsible for properly dirtying the current layer.
*/
-status_t OpenGLRenderer::drawPatches(SkBitmap* bitmap, AssetAtlas::Entry* entry,
- TextureVertex* vertices, uint32_t indexCount, SkPaint* paint) {
+status_t OpenGLRenderer::drawPatches(const SkBitmap* bitmap, AssetAtlas::Entry* entry,
+ TextureVertex* vertices, uint32_t indexCount, const SkPaint* paint) {
mCaches.activeTexture(0);
Texture* texture = entry ? entry->texture : mCaches.textureCache.get(bitmap);
if (!texture) return DrawGlInfo::kStatusDone;
@@ -2344,7 +2350,7 @@
return DrawGlInfo::kStatusDrew;
}
-status_t OpenGLRenderer::drawVertexBuffer(const VertexBuffer& vertexBuffer, SkPaint* paint,
+status_t OpenGLRenderer::drawVertexBuffer(const VertexBuffer& vertexBuffer, const SkPaint* paint,
bool useOffset) {
// not missing call to quickReject/dirtyLayer, always done at a higher level
@@ -2404,7 +2410,7 @@
*
* Doesn't yet support joins, caps, or path effects.
*/
-status_t OpenGLRenderer::drawConvexPath(const SkPath& path, SkPaint* paint) {
+status_t OpenGLRenderer::drawConvexPath(const SkPath& path, const SkPaint* paint) {
VertexBuffer vertexBuffer;
// TODO: try clipping large paths to viewport
PathTessellator::tessellatePath(path, paint, *currentTransform(), vertexBuffer);
@@ -2429,7 +2435,7 @@
* TODO: try using a fixed input buffer for non-capped lines as in text rendering. this may reduce
* memory transfer by removing need for degenerate vertices.
*/
-status_t OpenGLRenderer::drawLines(float* points, int count, SkPaint* paint) {
+status_t OpenGLRenderer::drawLines(const float* points, int count, const SkPaint* paint) {
if (currentSnapshot()->isIgnored() || count < 4) return DrawGlInfo::kStatusDone;
count &= ~0x3; // round down to nearest four
@@ -2449,7 +2455,7 @@
return drawVertexBuffer(buffer, paint, useOffset);
}
-status_t OpenGLRenderer::drawPoints(float* points, int count, SkPaint* paint) {
+status_t OpenGLRenderer::drawPoints(const float* points, int count, const SkPaint* paint) {
if (currentSnapshot()->isIgnored() || count < 2) return DrawGlInfo::kStatusDone;
count &= ~0x1; // round down to nearest two
@@ -2482,7 +2488,7 @@
}
status_t OpenGLRenderer::drawShape(float left, float top, const PathTexture* texture,
- SkPaint* paint) {
+ const SkPaint* paint) {
if (!texture) return DrawGlInfo::kStatusDone;
const AutoTexture autoCleanup(texture);
@@ -2495,7 +2501,7 @@
}
status_t OpenGLRenderer::drawRoundRect(float left, float top, float right, float bottom,
- float rx, float ry, SkPaint* p) {
+ float rx, float ry, const SkPaint* p) {
if (currentSnapshot()->isIgnored() || quickRejectSetupScissor(left, top, right, bottom, p) ||
(p->getAlpha() == 0 && getXfermode(p->getXfermode()) != SkXfermode::kClear_Mode)) {
return DrawGlInfo::kStatusDone;
@@ -2520,7 +2526,7 @@
return drawConvexPath(path, p);
}
-status_t OpenGLRenderer::drawCircle(float x, float y, float radius, SkPaint* p) {
+status_t OpenGLRenderer::drawCircle(float x, float y, float radius, const SkPaint* p) {
if (currentSnapshot()->isIgnored() || quickRejectSetupScissor(x - radius, y - radius,
x + radius, y + radius, p) ||
(p->getAlpha() == 0 && getXfermode(p->getXfermode()) != SkXfermode::kClear_Mode)) {
@@ -2542,7 +2548,7 @@
}
status_t OpenGLRenderer::drawOval(float left, float top, float right, float bottom,
- SkPaint* p) {
+ const SkPaint* p) {
if (currentSnapshot()->isIgnored() || quickRejectSetupScissor(left, top, right, bottom, p) ||
(p->getAlpha() == 0 && getXfermode(p->getXfermode()) != SkXfermode::kClear_Mode)) {
return DrawGlInfo::kStatusDone;
@@ -2564,7 +2570,7 @@
}
status_t OpenGLRenderer::drawArc(float left, float top, float right, float bottom,
- float startAngle, float sweepAngle, bool useCenter, SkPaint* p) {
+ float startAngle, float sweepAngle, bool useCenter, const SkPaint* p) {
if (currentSnapshot()->isIgnored() || quickRejectSetupScissor(left, top, right, bottom, p) ||
(p->getAlpha() == 0 && getXfermode(p->getXfermode()) != SkXfermode::kClear_Mode)) {
return DrawGlInfo::kStatusDone;
@@ -2601,7 +2607,8 @@
// See SkPaintDefaults.h
#define SkPaintDefaults_MiterLimit SkIntToScalar(4)
-status_t OpenGLRenderer::drawRect(float left, float top, float right, float bottom, SkPaint* p) {
+status_t OpenGLRenderer::drawRect(float left, float top, float right, float bottom,
+ const SkPaint* p) {
if (currentSnapshot()->isIgnored() || quickRejectSetupScissor(left, top, right, bottom, p) ||
(p->getAlpha() == 0 && getXfermode(p->getXfermode()) != SkXfermode::kClear_Mode)) {
return DrawGlInfo::kStatusDone;
@@ -2636,9 +2643,9 @@
}
}
-void OpenGLRenderer::drawTextShadow(SkPaint* paint, const char* text, int bytesCount, int count,
- const float* positions, FontRenderer& fontRenderer, int alpha, SkXfermode::Mode mode,
- float x, float y) {
+void OpenGLRenderer::drawTextShadow(const SkPaint* paint, const char* text,
+ int bytesCount, int count, const float* positions,
+ FontRenderer& fontRenderer, int alpha, SkXfermode::Mode mode, float x, float y) {
mCaches.activeTexture(0);
// NOTE: The drop shadow will not perform gamma correction
@@ -2684,7 +2691,7 @@
}
status_t OpenGLRenderer::drawPosText(const char* text, int bytesCount, int count,
- const float* positions, SkPaint* paint) {
+ const float* positions, const SkPaint* paint) {
if (text == NULL || count == 0 || currentSnapshot()->isIgnored() || canSkipText(paint)) {
return DrawGlInfo::kStatusDone;
}
@@ -2759,7 +2766,7 @@
}
status_t OpenGLRenderer::drawText(const char* text, int bytesCount, int count, float x, float y,
- const float* positions, SkPaint* paint, float totalAdvance, const Rect& bounds,
+ const float* positions, const SkPaint* paint, float totalAdvance, const Rect& bounds,
DrawOpMode drawOpMode) {
if (drawOpMode == kDrawOpMode_Immediate) {
@@ -2845,8 +2852,8 @@
return DrawGlInfo::kStatusDrew;
}
-status_t OpenGLRenderer::drawTextOnPath(const char* text, int bytesCount, int count, SkPath* path,
- float hOffset, float vOffset, SkPaint* paint) {
+status_t OpenGLRenderer::drawTextOnPath(const char* text, int bytesCount, int count,
+ const SkPath* path, float hOffset, float vOffset, const SkPaint* paint) {
if (text == NULL || count == 0 || currentSnapshot()->isIgnored() || canSkipText(paint)) {
return DrawGlInfo::kStatusDone;
}
@@ -2879,7 +2886,7 @@
return DrawGlInfo::kStatusDrew;
}
-status_t OpenGLRenderer::drawPath(SkPath* path, SkPaint* paint) {
+status_t OpenGLRenderer::drawPath(const SkPath* path, const SkPaint* paint) {
if (currentSnapshot()->isIgnored()) return DrawGlInfo::kStatusDone;
mCaches.activeTexture(0);
@@ -3056,7 +3063,7 @@
mDrawModifiers.mPaintFilterSetBits = setBits & SkPaint::kAllFlags;
}
-SkPaint* OpenGLRenderer::filterPaint(SkPaint* paint) {
+const SkPaint* OpenGLRenderer::filterPaint(const SkPaint* paint) {
if (CC_LIKELY(!mDrawModifiers.mHasDrawFilter || !paint)) {
return paint;
}
@@ -3074,7 +3081,7 @@
// Drawing implementation
///////////////////////////////////////////////////////////////////////////////
-Texture* OpenGLRenderer::getTexture(SkBitmap* bitmap) {
+Texture* OpenGLRenderer::getTexture(const SkBitmap* bitmap) {
Texture* texture = mCaches.assetAtlas.getEntryTexture(bitmap);
if (!texture) {
return mCaches.textureCache.get(bitmap);
@@ -3083,7 +3090,7 @@
}
void OpenGLRenderer::drawPathTexture(const PathTexture* texture,
- float x, float y, SkPaint* paint) {
+ float x, float y, const SkPaint* paint) {
if (quickRejectSetupScissor(x, y, x + texture->width, y + texture->height)) {
return;
}
@@ -3115,7 +3122,8 @@
#define kStdUnderline_Offset (1.0f / 9.0f)
#define kStdUnderline_Thickness (1.0f / 18.0f)
-void OpenGLRenderer::drawTextDecorations(float underlineWidth, float x, float y, SkPaint* paint) {
+void OpenGLRenderer::drawTextDecorations(float underlineWidth, float x, float y,
+ const SkPaint* paint) {
// Handle underline and strike-through
uint32_t flags = paint->getFlags();
if (flags & (SkPaint::kUnderlineText_Flag | SkPaint::kStrikeThruText_Flag)) {
@@ -3159,7 +3167,7 @@
}
}
-status_t OpenGLRenderer::drawRects(const float* rects, int count, SkPaint* paint) {
+status_t OpenGLRenderer::drawRects(const float* rects, int count, const SkPaint* paint) {
if (currentSnapshot()->isIgnored()) {
return DrawGlInfo::kStatusDone;
}
@@ -3275,7 +3283,7 @@
}
void OpenGLRenderer::drawTextureRect(float left, float top, float right, float bottom,
- Texture* texture, SkPaint* paint) {
+ Texture* texture, const SkPaint* paint) {
int alpha;
SkXfermode::Mode mode;
getAlphaAndMode(paint, &alpha, &mode);
@@ -3464,7 +3472,7 @@
TextureVertex::setUV(v++, u2, v2);
}
-void OpenGLRenderer::getAlphaAndMode(SkPaint* paint, int* alpha, SkXfermode::Mode* mode) const {
+void OpenGLRenderer::getAlphaAndMode(const SkPaint* paint, int* alpha, SkXfermode::Mode* mode) const {
getAlphaAndModeDirect(paint, alpha, mode);
if (mDrawModifiers.mOverrideLayerAlpha < 1.0f) {
// if drawing a layer, ignore the paint's alpha
diff --git a/libs/hwui/OpenGLRenderer.h b/libs/hwui/OpenGLRenderer.h
index ceb0dfd..fb780ce 100644
--- a/libs/hwui/OpenGLRenderer.h
+++ b/libs/hwui/OpenGLRenderer.h
@@ -172,41 +172,46 @@
virtual status_t drawDisplayList(DisplayList* displayList, Rect& dirty, int32_t replayFlags);
virtual status_t drawLayer(Layer* layer, float x, float y);
- virtual status_t drawBitmap(SkBitmap* bitmap, float left, float top, SkPaint* paint);
- status_t drawBitmaps(SkBitmap* bitmap, AssetAtlas::Entry* entry, int bitmapCount,
- TextureVertex* vertices, bool pureTranslate, const Rect& bounds, SkPaint* paint);
- virtual status_t drawBitmap(SkBitmap* bitmap, SkMatrix* matrix, SkPaint* paint);
- virtual status_t drawBitmap(SkBitmap* bitmap, float srcLeft, float srcTop,
+ virtual status_t drawBitmap(const SkBitmap* bitmap, float left, float top,
+ const SkPaint* paint);
+ status_t drawBitmaps(const SkBitmap* bitmap, AssetAtlas::Entry* entry, int bitmapCount,
+ TextureVertex* vertices, bool pureTranslate, const Rect& bounds, const SkPaint* paint);
+ virtual status_t drawBitmap(const SkBitmap* bitmap, const SkMatrix* matrix,
+ const SkPaint* paint);
+ virtual status_t drawBitmap(const SkBitmap* bitmap, float srcLeft, float srcTop,
float srcRight, float srcBottom, float dstLeft, float dstTop,
- float dstRight, float dstBottom, SkPaint* paint);
- virtual status_t drawBitmapData(SkBitmap* bitmap, float left, float top, SkPaint* paint);
- virtual status_t drawBitmapMesh(SkBitmap* bitmap, int meshWidth, int meshHeight,
- float* vertices, int* colors, SkPaint* paint);
- status_t drawPatches(SkBitmap* bitmap, AssetAtlas::Entry* entry,
- TextureVertex* vertices, uint32_t indexCount, SkPaint* paint);
- virtual status_t drawPatch(SkBitmap* bitmap, Res_png_9patch* patch,
- float left, float top, float right, float bottom, SkPaint* paint);
- status_t drawPatch(SkBitmap* bitmap, const Patch* mesh, AssetAtlas::Entry* entry,
- float left, float top, float right, float bottom, SkPaint* paint);
+ float dstRight, float dstBottom, const SkPaint* paint);
+ virtual status_t drawBitmapData(const SkBitmap* bitmap, float left, float top,
+ const SkPaint* paint);
+ virtual status_t drawBitmapMesh(const SkBitmap* bitmap, int meshWidth, int meshHeight,
+ const float* vertices, const int* colors, const SkPaint* paint);
+ status_t drawPatches(const SkBitmap* bitmap, AssetAtlas::Entry* entry,
+ TextureVertex* vertices, uint32_t indexCount, const SkPaint* paint);
+ virtual status_t drawPatch(const SkBitmap* bitmap, const Res_png_9patch* patch,
+ float left, float top, float right, float bottom, const SkPaint* paint);
+ status_t drawPatch(const SkBitmap* bitmap, const Patch* mesh, AssetAtlas::Entry* entry,
+ float left, float top, float right, float bottom, const SkPaint* paint);
virtual status_t drawColor(int color, SkXfermode::Mode mode);
- virtual status_t drawRect(float left, float top, float right, float bottom, SkPaint* paint);
+ virtual status_t drawRect(float left, float top, float right, float bottom,
+ const SkPaint* paint);
virtual status_t drawRoundRect(float left, float top, float right, float bottom,
- float rx, float ry, SkPaint* paint);
- virtual status_t drawCircle(float x, float y, float radius, SkPaint* paint);
- virtual status_t drawOval(float left, float top, float right, float bottom, SkPaint* paint);
+ float rx, float ry, const SkPaint* paint);
+ virtual status_t drawCircle(float x, float y, float radius, const SkPaint* paint);
+ virtual status_t drawOval(float left, float top, float right, float bottom,
+ const SkPaint* paint);
virtual status_t drawArc(float left, float top, float right, float bottom,
- float startAngle, float sweepAngle, bool useCenter, SkPaint* paint);
- virtual status_t drawPath(SkPath* path, SkPaint* paint);
- virtual status_t drawLines(float* points, int count, SkPaint* paint);
- virtual status_t drawPoints(float* points, int count, SkPaint* paint);
- virtual status_t drawTextOnPath(const char* text, int bytesCount, int count, SkPath* path,
- float hOffset, float vOffset, SkPaint* paint);
+ float startAngle, float sweepAngle, bool useCenter, const SkPaint* paint);
+ virtual status_t drawPath(const SkPath* path, const SkPaint* paint);
+ virtual status_t drawLines(const float* points, int count, const SkPaint* paint);
+ virtual status_t drawPoints(const float* points, int count, const SkPaint* paint);
+ virtual status_t drawTextOnPath(const char* text, int bytesCount, int count, const SkPath* path,
+ float hOffset, float vOffset, const SkPaint* paint);
virtual status_t drawPosText(const char* text, int bytesCount, int count,
- const float* positions, SkPaint* paint);
+ const float* positions, const SkPaint* paint);
virtual status_t drawText(const char* text, int bytesCount, int count, float x, float y,
- const float* positions, SkPaint* paint, float totalAdvance, const Rect& bounds,
+ const float* positions, const SkPaint* paint, float totalAdvance, const Rect& bounds,
DrawOpMode drawOpMode = kDrawOpMode_Immediate);
- virtual status_t drawRects(const float* rects, int count, SkPaint* paint);
+ virtual status_t drawRects(const float* rects, int count, const SkPaint* paint);
status_t drawShadow(const mat4& casterTransform, float casterAlpha,
float width, float height);
@@ -226,7 +231,7 @@
// If this value is set to < 1.0, it overrides alpha set on layer (see drawBitmap, drawLayer)
void setOverrideLayerAlpha(float alpha) { mDrawModifiers.mOverrideLayerAlpha = alpha; }
- SkPaint* filterPaint(SkPaint* paint);
+ const SkPaint* filterPaint(const SkPaint* paint);
/**
* Store the current display state (most importantly, the current clip and transform), and
@@ -292,12 +297,12 @@
* @param alpha Where to store the resulting alpha
* @param mode Where to store the resulting xfermode
*/
- static inline void getAlphaAndModeDirect(SkPaint* paint, int* alpha, SkXfermode::Mode* mode) {
+ static inline void getAlphaAndModeDirect(const SkPaint* paint, int* alpha, SkXfermode::Mode* mode) {
*mode = getXfermodeDirect(paint);
*alpha = getAlphaDirect(paint);
}
- static inline SkXfermode::Mode getXfermodeDirect(SkPaint* paint) {
+ static inline SkXfermode::Mode getXfermodeDirect(const SkPaint* paint) {
if (!paint) return SkXfermode::kSrcOver_Mode;
return getXfermode(paint->getXfermode());
}
@@ -370,8 +375,8 @@
void attachStencilBufferToLayer(Layer* layer);
bool quickRejectSetupScissor(float left, float top, float right, float bottom,
- SkPaint* paint = NULL);
- bool quickRejectSetupScissor(const Rect& bounds, SkPaint* paint = NULL) {
+ const SkPaint* paint = NULL);
+ bool quickRejectSetupScissor(const Rect& bounds, const SkPaint* paint = NULL) {
return quickRejectSetupScissor(bounds.left, bounds.top,
bounds.right, bounds.bottom, paint);
}
@@ -430,7 +435,7 @@
* @param alpha Where to store the resulting alpha
* @param mode Where to store the resulting xfermode
*/
- inline void getAlphaAndMode(SkPaint* paint, int* alpha, SkXfermode::Mode* mode) const;
+ inline void getAlphaAndMode(const SkPaint* paint, int* alpha, SkXfermode::Mode* mode) const;
/**
* Gets the alpha from a layer, accounting for snapshot alpha and overrideLayerAlpha
@@ -624,7 +629,7 @@
* @param texture The texture reprsenting the shape
* @param paint The paint to draw the shape with
*/
- status_t drawShape(float left, float top, const PathTexture* texture, SkPaint* paint);
+ status_t drawShape(float left, float top, const PathTexture* texture, const SkPaint* paint);
/**
* Draws the specified texture as an alpha bitmap. Alpha bitmaps obey
@@ -635,7 +640,7 @@
* @param top The y coordinate of the bitmap
* @param paint The paint to render with
*/
- void drawAlphaBitmap(Texture* texture, float left, float top, SkPaint* paint);
+ void drawAlphaBitmap(Texture* texture, float left, float top, const SkPaint* paint);
/**
* Renders a strip of polygons with the specified paint, used for tessellated geometry.
@@ -644,7 +649,7 @@
* @param paint The paint to render with
* @param useOffset Offset the vertexBuffer (used in drawing non-AA lines)
*/
- status_t drawVertexBuffer(const VertexBuffer& vertexBuffer, SkPaint* paint,
+ status_t drawVertexBuffer(const VertexBuffer& vertexBuffer, const SkPaint* paint,
bool useOffset = false);
/**
@@ -653,7 +658,7 @@
* @param path The hull of the path to draw
* @param paint The paint to render with
*/
- status_t drawConvexPath(const SkPath& path, SkPaint* paint);
+ status_t drawConvexPath(const SkPath& path, const SkPaint* paint);
/**
* Draws a textured rectangle with the specified texture. The specified coordinates
@@ -683,7 +688,7 @@
* @param paint The paint containing the alpha, blending mode, etc.
*/
void drawTextureRect(float left, float top, float right, float bottom,
- Texture* texture, SkPaint* paint);
+ Texture* texture, const SkPaint* paint);
/**
* Draws a textured mesh with the specified texture. If the indices are omitted,
@@ -742,7 +747,7 @@
* @param y The y coordinate where the text will be drawn
* @param paint The paint to draw the text with
*/
- void drawTextDecorations(float totalAdvance, float x, float y, SkPaint* paint);
+ void drawTextDecorations(float totalAdvance, float x, float y, const SkPaint* paint);
/**
* Draws shadow layer on text (with optional positions).
@@ -758,7 +763,7 @@
* @param x The x coordinate where the shadow will be drawn
* @param y The y coordinate where the shadow will be drawn
*/
- void drawTextShadow(SkPaint* paint, const char* text, int bytesCount, int count,
+ void drawTextShadow(const SkPaint* paint, const char* text, int bytesCount, int count,
const float* positions, FontRenderer& fontRenderer, int alpha, SkXfermode::Mode mode,
float x, float y);
@@ -771,7 +776,7 @@
* @param y The y coordinate where the texture will be drawn
* @param paint The paint to draw the texture with
*/
- void drawPathTexture(const PathTexture* texture, float x, float y, SkPaint* paint);
+ void drawPathTexture(const PathTexture* texture, float x, float y, const SkPaint* paint);
/**
* Resets the texture coordinates stored in mMeshVertices. Setting the values
@@ -930,7 +935,7 @@
* come from the texture cache or an atlas. If this method returns
* NULL, the texture could not be found and/or allocated.
*/
- Texture* getTexture(SkBitmap* bitmap);
+ Texture* getTexture(const SkBitmap* bitmap);
// Matrix used for view/projection in shaders
mat4 mViewProjMatrix;
diff --git a/libs/hwui/PathCache.cpp b/libs/hwui/PathCache.cpp
index 5df6408..9459885 100644
--- a/libs/hwui/PathCache.cpp
+++ b/libs/hwui/PathCache.cpp
@@ -51,7 +51,7 @@
memset(&shape, 0, sizeof(Shape));
}
-PathDescription::PathDescription(ShapeType type, SkPaint* paint):
+PathDescription::PathDescription(ShapeType type, const SkPaint* paint):
type(type),
join(paint->getStrokeJoin()),
cap(paint->getStrokeCap()),
@@ -82,7 +82,7 @@
// Utilities
///////////////////////////////////////////////////////////////////////////////
-bool PathCache::canDrawAsConvexPath(SkPath* path, SkPaint* paint) {
+bool PathCache::canDrawAsConvexPath(SkPath* path, const SkPaint* paint) {
// NOTE: This should only be used after PathTessellator handles joins properly
return paint->getPathEffect() == NULL && path->getConvexity() == SkPath::kConvex_Convexity;
}
@@ -413,7 +413,7 @@
* in the cache. The source path is also used to reclaim garbage when a
* Dalvik Path object is collected.
*/
-static SkPath* getSourcePath(SkPath* path) {
+static const SkPath* getSourcePath(const SkPath* path) {
const SkPath* sourcePath = path->getSourcePath();
if (sourcePath && sourcePath->getGenerationID() == path->getGenerationID()) {
return const_cast<SkPath*>(sourcePath);
@@ -421,7 +421,7 @@
return path;
}
-PathTexture* PathCache::get(SkPath* path, SkPaint* paint) {
+PathTexture* PathCache::get(const SkPath* path, const SkPaint* paint) {
path = getSourcePath(path);
PathDescription entry(kShapePath, paint);
@@ -459,7 +459,7 @@
return texture;
}
-void PathCache::precache(SkPath* path, SkPaint* paint) {
+void PathCache::precache(const SkPath* path, const SkPaint* paint) {
if (!Caches::getInstance().tasks.canRunTasks()) {
return;
}
@@ -507,7 +507,7 @@
///////////////////////////////////////////////////////////////////////////////
PathTexture* PathCache::getRoundRect(float width, float height,
- float rx, float ry, SkPaint* paint) {
+ float rx, float ry, const SkPaint* paint) {
PathDescription entry(kShapeRoundRect, paint);
entry.shape.roundRect.mWidth = width;
entry.shape.roundRect.mHeight = height;
@@ -532,7 +532,7 @@
// Circles
///////////////////////////////////////////////////////////////////////////////
-PathTexture* PathCache::getCircle(float radius, SkPaint* paint) {
+PathTexture* PathCache::getCircle(float radius, const SkPaint* paint) {
PathDescription entry(kShapeCircle, paint);
entry.shape.circle.mRadius = radius;
@@ -552,7 +552,7 @@
// Ovals
///////////////////////////////////////////////////////////////////////////////
-PathTexture* PathCache::getOval(float width, float height, SkPaint* paint) {
+PathTexture* PathCache::getOval(float width, float height, const SkPaint* paint) {
PathDescription entry(kShapeOval, paint);
entry.shape.oval.mWidth = width;
entry.shape.oval.mHeight = height;
@@ -575,7 +575,7 @@
// Rects
///////////////////////////////////////////////////////////////////////////////
-PathTexture* PathCache::getRect(float width, float height, SkPaint* paint) {
+PathTexture* PathCache::getRect(float width, float height, const SkPaint* paint) {
PathDescription entry(kShapeRect, paint);
entry.shape.rect.mWidth = width;
entry.shape.rect.mHeight = height;
@@ -599,7 +599,7 @@
///////////////////////////////////////////////////////////////////////////////
PathTexture* PathCache::getArc(float width, float height,
- float startAngle, float sweepAngle, bool useCenter, SkPaint* paint) {
+ float startAngle, float sweepAngle, bool useCenter, const SkPaint* paint) {
PathDescription entry(kShapeArc, paint);
entry.shape.arc.mWidth = width;
entry.shape.arc.mHeight = height;
diff --git a/libs/hwui/PathCache.h b/libs/hwui/PathCache.h
index 721e669..847853a 100644
--- a/libs/hwui/PathCache.h
+++ b/libs/hwui/PathCache.h
@@ -116,7 +116,7 @@
SkPathEffect* pathEffect;
union Shape {
struct Path {
- SkPath* mPath;
+ const SkPath* mPath;
} path;
struct RoundRect {
float mWidth;
@@ -145,7 +145,7 @@
} shape;
PathDescription();
- PathDescription(ShapeType shapeType, SkPaint* paint);
+ PathDescription(ShapeType shapeType, const SkPaint* paint);
hash_t hash() const;
@@ -207,13 +207,13 @@
*/
uint32_t getSize();
- PathTexture* getRoundRect(float width, float height, float rx, float ry, SkPaint* paint);
- PathTexture* getCircle(float radius, SkPaint* paint);
- PathTexture* getOval(float width, float height, SkPaint* paint);
- PathTexture* getRect(float width, float height, SkPaint* paint);
+ PathTexture* getRoundRect(float width, float height, float rx, float ry, const SkPaint* paint);
+ PathTexture* getCircle(float radius, const SkPaint* paint);
+ PathTexture* getOval(float width, float height, const SkPaint* paint);
+ PathTexture* getRect(float width, float height, const SkPaint* paint);
PathTexture* getArc(float width, float height, float startAngle, float sweepAngle,
- bool useCenter, SkPaint* paint);
- PathTexture* get(SkPath* path, SkPaint* paint);
+ bool useCenter, const SkPaint* paint);
+ PathTexture* get(const SkPath* path, const SkPaint* paint);
/**
* Removes the specified path. This is meant to be called from threads
@@ -239,9 +239,9 @@
/**
* Precaches the specified path using background threads.
*/
- void precache(SkPath* path, SkPaint* paint);
+ void precache(const SkPath* path, const SkPaint* paint);
- static bool canDrawAsConvexPath(SkPath* path, SkPaint* paint);
+ static bool canDrawAsConvexPath(SkPath* path, const SkPaint* paint);
static void computePathBounds(const SkPath* path, const SkPaint* paint,
float& left, float& top, float& offset, uint32_t& width, uint32_t& height);
static void computeBounds(const SkRect& bounds, const SkPaint* paint,
@@ -292,7 +292,7 @@
class PathTask: public Task<SkBitmap*> {
public:
- PathTask(SkPath* path, SkPaint* paint, PathTexture* texture):
+ PathTask(const SkPath* path, const SkPaint* paint, PathTexture* texture):
path(path), paint(paint), texture(texture) {
}
@@ -300,8 +300,8 @@
delete future()->get();
}
- SkPath* path;
- SkPaint* paint;
+ const SkPath* path;
+ const SkPaint* paint;
PathTexture* texture;
};
diff --git a/libs/hwui/PathTessellator.cpp b/libs/hwui/PathTessellator.cpp
index e366a04..c6ce67c 100644
--- a/libs/hwui/PathTessellator.cpp
+++ b/libs/hwui/PathTessellator.cpp
@@ -805,7 +805,7 @@
dstBuffer.createDegenerateSeparators<TYPE>(verticesPerPoint);
}
-void PathTessellator::tessellatePoints(const float* points, int count, SkPaint* paint,
+void PathTessellator::tessellatePoints(const float* points, int count, const SkPaint* paint,
const mat4& transform, SkRect& bounds, VertexBuffer& vertexBuffer) {
const PaintInfo paintInfo(paint, transform);
@@ -845,7 +845,7 @@
}
-void PathTessellator::tessellateLines(const float* points, int count, SkPaint* paint,
+void PathTessellator::tessellateLines(const float* points, int count, const SkPaint* paint,
const mat4& transform, SkRect& bounds, VertexBuffer& vertexBuffer) {
ATRACE_CALL();
const PaintInfo paintInfo(paint, transform);
diff --git a/libs/hwui/PathTessellator.h b/libs/hwui/PathTessellator.h
index 24f20bc..e43b101 100644
--- a/libs/hwui/PathTessellator.h
+++ b/libs/hwui/PathTessellator.h
@@ -34,10 +34,10 @@
static void tessellatePath(const SkPath& path, const SkPaint* paint,
const mat4& transform, VertexBuffer& vertexBuffer);
- static void tessellatePoints(const float* points, int count, SkPaint* paint,
+ static void tessellatePoints(const float* points, int count, const SkPaint* paint,
const mat4& transform, SkRect& bounds, VertexBuffer& vertexBuffer);
- static void tessellateLines(const float* points, int count, SkPaint* paint,
+ static void tessellateLines(const float* points, int count, const SkPaint* paint,
const mat4& transform, SkRect& bounds, VertexBuffer& vertexBuffer);
private:
diff --git a/libs/hwui/Renderer.h b/libs/hwui/Renderer.h
index 3f57873..38e1c91 100644
--- a/libs/hwui/Renderer.h
+++ b/libs/hwui/Renderer.h
@@ -190,16 +190,16 @@
virtual void scale(float sx, float sy) = 0;
virtual void skew(float sx, float sy) = 0;
- virtual void setMatrix(SkMatrix* matrix) = 0;
- virtual void concatMatrix(SkMatrix* matrix) = 0;
+ virtual void setMatrix(const SkMatrix* matrix) = 0;
+ virtual void concatMatrix(const SkMatrix* matrix) = 0;
// clip
virtual const Rect& getClipBounds() 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(SkPath* path, SkRegion::Op op) = 0;
- virtual bool clipRegion(SkRegion* region, 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 - should be implemented with SkPaint inspection
virtual void resetShader() = 0;
@@ -220,38 +220,43 @@
virtual status_t drawColor(int color, SkXfermode::Mode mode) = 0;
// Bitmap-based
- virtual status_t drawBitmap(SkBitmap* bitmap, float left, float top, SkPaint* paint) = 0;
- virtual status_t drawBitmap(SkBitmap* bitmap, SkMatrix* matrix, SkPaint* paint) = 0;
- virtual status_t drawBitmap(SkBitmap* bitmap, float srcLeft, float srcTop,
+ virtual status_t drawBitmap(const SkBitmap* bitmap, float left, float top,
+ const SkPaint* paint) = 0;
+ virtual status_t drawBitmap(const SkBitmap* bitmap, const SkMatrix* matrix,
+ const SkPaint* paint) = 0;
+ virtual status_t drawBitmap(const SkBitmap* bitmap, float srcLeft, float srcTop,
float srcRight, float srcBottom, float dstLeft, float dstTop,
- float dstRight, float dstBottom, SkPaint* paint) = 0;
- virtual status_t drawBitmapData(SkBitmap* bitmap, float left, float top, SkPaint* paint) = 0;
- virtual status_t drawBitmapMesh(SkBitmap* bitmap, int meshWidth, int meshHeight,
- float* vertices, int* colors, SkPaint* paint) = 0;
- virtual status_t drawPatch(SkBitmap* bitmap, Res_png_9patch* patch,
- float left, float top, float right, float bottom, SkPaint* paint) = 0;
+ float dstRight, float dstBottom, const SkPaint* paint) = 0;
+ virtual status_t drawBitmapData(const SkBitmap* bitmap, float left, float top,
+ const SkPaint* paint) = 0;
+ virtual status_t drawBitmapMesh(const SkBitmap* bitmap, int meshWidth, int meshHeight,
+ const float* vertices, const int* colors, const SkPaint* paint) = 0;
+ virtual status_t drawPatch(const SkBitmap* bitmap, const Res_png_9patch* patch,
+ float left, float top, float right, float bottom, const SkPaint* paint) = 0;
// Shapes
- virtual status_t drawRect(float left, float top, float right, float bottom, SkPaint* paint) = 0;
- virtual status_t drawRects(const float* rects, int count, SkPaint* paint) = 0;
+ virtual status_t drawRect(float left, float top, float right, float bottom,
+ const SkPaint* paint) = 0;
+ virtual status_t drawRects(const float* rects, int count, const SkPaint* paint) = 0;
virtual status_t drawRoundRect(float left, float top, float right, float bottom,
- float rx, float ry, SkPaint* paint) = 0;
- virtual status_t drawCircle(float x, float y, float radius, SkPaint* paint) = 0;
- virtual status_t drawOval(float left, float top, float right, float bottom, SkPaint* paint) = 0;
+ float rx, float ry, const SkPaint* paint) = 0;
+ virtual status_t drawCircle(float x, float y, float radius, const SkPaint* paint) = 0;
+ virtual status_t drawOval(float left, float top, float right, float bottom,
+ const SkPaint* paint) = 0;
virtual status_t drawArc(float left, float top, float right, float bottom,
- float startAngle, float sweepAngle, bool useCenter, SkPaint* paint) = 0;
- virtual status_t drawPath(SkPath* path, SkPaint* paint) = 0;
- virtual status_t drawLines(float* points, int count, SkPaint* paint) = 0;
- virtual status_t drawPoints(float* points, int count, SkPaint* paint) = 0;
+ float startAngle, float sweepAngle, bool useCenter, const SkPaint* paint) = 0;
+ virtual status_t drawPath(const SkPath* path, const SkPaint* paint) = 0;
+ virtual status_t drawLines(const float* points, int count, const SkPaint* paint) = 0;
+ virtual status_t drawPoints(const float* points, int count, const SkPaint* paint) = 0;
// Text
virtual status_t drawText(const char* text, int bytesCount, int count, float x, float y,
- const float* positions, SkPaint* paint, float totalAdvance, const Rect& bounds,
+ const float* positions, const SkPaint* paint, float totalAdvance, const Rect& bounds,
DrawOpMode drawOpMode = kDrawOpMode_Immediate) = 0;
- virtual status_t drawTextOnPath(const char* text, int bytesCount, int count, SkPath* path,
- float hOffset, float vOffset, SkPaint* paint) = 0;
+ virtual status_t drawTextOnPath(const char* text, int bytesCount, int count, const SkPath* path,
+ float hOffset, float vOffset, const SkPaint* paint) = 0;
virtual status_t drawPosText(const char* text, int bytesCount, int count,
- const float* positions, SkPaint* paint) = 0;
+ const float* positions, const SkPaint* paint) = 0;
// ----------------------------------------------------------------------------
// Canvas draw operations - special
diff --git a/libs/hwui/ResourceCache.cpp b/libs/hwui/ResourceCache.cpp
index 3f77021..e58857c 100644
--- a/libs/hwui/ResourceCache.cpp
+++ b/libs/hwui/ResourceCache.cpp
@@ -40,7 +40,7 @@
ResourceCache::ResourceCache() {
Mutex::Autolock _l(mLock);
- mCache = new KeyedVector<void*, ResourceReference*>();
+ mCache = new KeyedVector<const void*, ResourceReference*>();
}
ResourceCache::~ResourceCache() {
@@ -61,13 +61,13 @@
incrementRefcountLocked(resource, resourceType);
}
-void ResourceCache::incrementRefcount(SkBitmap* bitmapResource) {
+void ResourceCache::incrementRefcount(const SkBitmap* bitmapResource) {
bitmapResource->pixelRef()->globalRef();
SkSafeRef(bitmapResource->getColorTable());
incrementRefcount((void*) bitmapResource, kBitmap);
}
-void ResourceCache::incrementRefcount(SkPath* pathResource) {
+void ResourceCache::incrementRefcount(const SkPath* pathResource) {
incrementRefcount((void*) pathResource, kPath);
}
@@ -81,7 +81,7 @@
incrementRefcount((void*) filterResource, kColorFilter);
}
-void ResourceCache::incrementRefcount(Res_png_9patch* patchResource) {
+void ResourceCache::incrementRefcount(const Res_png_9patch* patchResource) {
incrementRefcount((void*) patchResource, kNinePatch);
}
@@ -99,13 +99,13 @@
ref->refCount++;
}
-void ResourceCache::incrementRefcountLocked(SkBitmap* bitmapResource) {
+void ResourceCache::incrementRefcountLocked(const SkBitmap* bitmapResource) {
bitmapResource->pixelRef()->globalRef();
SkSafeRef(bitmapResource->getColorTable());
incrementRefcountLocked((void*) bitmapResource, kBitmap);
}
-void ResourceCache::incrementRefcountLocked(SkPath* pathResource) {
+void ResourceCache::incrementRefcountLocked(const SkPath* pathResource) {
incrementRefcountLocked((void*) pathResource, kPath);
}
@@ -119,7 +119,7 @@
incrementRefcountLocked((void*) filterResource, kColorFilter);
}
-void ResourceCache::incrementRefcountLocked(Res_png_9patch* patchResource) {
+void ResourceCache::incrementRefcountLocked(const Res_png_9patch* patchResource) {
incrementRefcountLocked((void*) patchResource, kNinePatch);
}
@@ -132,13 +132,13 @@
decrementRefcountLocked(resource);
}
-void ResourceCache::decrementRefcount(SkBitmap* bitmapResource) {
+void ResourceCache::decrementRefcount(const SkBitmap* bitmapResource) {
bitmapResource->pixelRef()->globalUnref();
SkSafeUnref(bitmapResource->getColorTable());
decrementRefcount((void*) bitmapResource);
}
-void ResourceCache::decrementRefcount(SkPath* pathResource) {
+void ResourceCache::decrementRefcount(const SkPath* pathResource) {
decrementRefcount((void*) pathResource);
}
@@ -152,7 +152,7 @@
decrementRefcount((void*) filterResource);
}
-void ResourceCache::decrementRefcount(Res_png_9patch* patchResource) {
+void ResourceCache::decrementRefcount(const Res_png_9patch* patchResource) {
decrementRefcount((void*) patchResource);
}
@@ -173,13 +173,13 @@
}
}
-void ResourceCache::decrementRefcountLocked(SkBitmap* bitmapResource) {
+void ResourceCache::decrementRefcountLocked(const SkBitmap* bitmapResource) {
bitmapResource->pixelRef()->globalUnref();
SkSafeUnref(bitmapResource->getColorTable());
decrementRefcountLocked((void*) bitmapResource);
}
-void ResourceCache::decrementRefcountLocked(SkPath* pathResource) {
+void ResourceCache::decrementRefcountLocked(const SkPath* pathResource) {
decrementRefcountLocked((void*) pathResource);
}
@@ -193,7 +193,7 @@
decrementRefcountLocked((void*) filterResource);
}
-void ResourceCache::decrementRefcountLocked(Res_png_9patch* patchResource) {
+void ResourceCache::decrementRefcountLocked(const Res_png_9patch* patchResource) {
decrementRefcountLocked((void*) patchResource);
}
@@ -223,12 +223,12 @@
}
}
-void ResourceCache::destructor(SkBitmap* resource) {
+void ResourceCache::destructor(const SkBitmap* resource) {
Mutex::Autolock _l(mLock);
destructorLocked(resource);
}
-void ResourceCache::destructorLocked(SkBitmap* resource) {
+void ResourceCache::destructorLocked(const SkBitmap* resource) {
ssize_t index = mCache->indexOfKey(resource);
ResourceReference* ref = index >= 0 ? mCache->valueAt(index) : NULL;
if (ref == NULL) {
@@ -345,7 +345,7 @@
* This method should only be called while the mLock mutex is held (that mutex is grabbed
* by the various destructor() and recycle() methods which call this method).
*/
-void ResourceCache::deleteResourceReferenceLocked(void* resource, ResourceReference* ref) {
+void ResourceCache::deleteResourceReferenceLocked(const void* resource, ResourceReference* ref) {
if (ref->recycled && ref->resourceType == kBitmap) {
((SkBitmap*) resource)->setPixels(NULL, NULL);
}
diff --git a/libs/hwui/ResourceCache.h b/libs/hwui/ResourceCache.h
index ea0c1b5..c06b09b 100644
--- a/libs/hwui/ResourceCache.h
+++ b/libs/hwui/ResourceCache.h
@@ -70,42 +70,42 @@
void lock();
void unlock();
- void incrementRefcount(SkPath* resource);
- void incrementRefcount(SkBitmap* resource);
+ void incrementRefcount(const SkPath* resource);
+ void incrementRefcount(const SkBitmap* resource);
void incrementRefcount(SkiaShader* resource);
void incrementRefcount(SkiaColorFilter* resource);
- void incrementRefcount(Res_png_9patch* resource);
+ void incrementRefcount(const Res_png_9patch* resource);
void incrementRefcount(Layer* resource);
- void incrementRefcountLocked(SkPath* resource);
- void incrementRefcountLocked(SkBitmap* resource);
+ void incrementRefcountLocked(const SkPath* resource);
+ void incrementRefcountLocked(const SkBitmap* resource);
void incrementRefcountLocked(SkiaShader* resource);
void incrementRefcountLocked(SkiaColorFilter* resource);
- void incrementRefcountLocked(Res_png_9patch* resource);
+ void incrementRefcountLocked(const Res_png_9patch* resource);
void incrementRefcountLocked(Layer* resource);
- void decrementRefcount(SkBitmap* resource);
- void decrementRefcount(SkPath* resource);
+ void decrementRefcount(const SkBitmap* resource);
+ void decrementRefcount(const SkPath* resource);
void decrementRefcount(SkiaShader* resource);
void decrementRefcount(SkiaColorFilter* resource);
- void decrementRefcount(Res_png_9patch* resource);
+ void decrementRefcount(const Res_png_9patch* resource);
void decrementRefcount(Layer* resource);
- void decrementRefcountLocked(SkBitmap* resource);
- void decrementRefcountLocked(SkPath* resource);
+ void decrementRefcountLocked(const SkBitmap* resource);
+ void decrementRefcountLocked(const SkPath* resource);
void decrementRefcountLocked(SkiaShader* resource);
void decrementRefcountLocked(SkiaColorFilter* resource);
- void decrementRefcountLocked(Res_png_9patch* resource);
+ void decrementRefcountLocked(const Res_png_9patch* resource);
void decrementRefcountLocked(Layer* resource);
void destructor(SkPath* resource);
- void destructor(SkBitmap* resource);
+ void destructor(const SkBitmap* resource);
void destructor(SkiaShader* resource);
void destructor(SkiaColorFilter* resource);
void destructor(Res_png_9patch* resource);
void destructorLocked(SkPath* resource);
- void destructorLocked(SkBitmap* resource);
+ void destructorLocked(const SkBitmap* resource);
void destructorLocked(SkiaShader* resource);
void destructorLocked(SkiaColorFilter* resource);
void destructorLocked(Res_png_9patch* resource);
@@ -114,7 +114,7 @@
bool recycleLocked(SkBitmap* resource);
private:
- void deleteResourceReferenceLocked(void* resource, ResourceReference* ref);
+ void deleteResourceReferenceLocked(const void* resource, ResourceReference* ref);
void incrementRefcount(void* resource, ResourceType resourceType);
void incrementRefcountLocked(void* resource, ResourceType resourceType);
@@ -131,7 +131,7 @@
*/
mutable Mutex mLock;
- KeyedVector<void*, ResourceReference*>* mCache;
+ KeyedVector<const void*, ResourceReference*>* mCache;
};
}; // namespace uirenderer
diff --git a/libs/hwui/StatefulBaseRenderer.cpp b/libs/hwui/StatefulBaseRenderer.cpp
index 2932037..05f6cf8 100644
--- a/libs/hwui/StatefulBaseRenderer.cpp
+++ b/libs/hwui/StatefulBaseRenderer.cpp
@@ -114,7 +114,7 @@
mSnapshot->transform->skew(sx, sy);
}
-void StatefulBaseRenderer::setMatrix(SkMatrix* matrix) {
+void StatefulBaseRenderer::setMatrix(const SkMatrix* matrix) {
if (matrix) {
mSnapshot->transform->load(*matrix);
} else {
@@ -126,7 +126,7 @@
mSnapshot->transform->load(matrix);
}
-void StatefulBaseRenderer::concatMatrix(SkMatrix* matrix) {
+void StatefulBaseRenderer::concatMatrix(const SkMatrix* matrix) {
mat4 transform(*matrix);
mSnapshot->transform->multiply(transform);
}
@@ -151,7 +151,7 @@
return StatefulBaseRenderer::clipPath(&path, op);
}
-bool StatefulBaseRenderer::clipPath(SkPath* path, SkRegion::Op op) {
+bool StatefulBaseRenderer::clipPath(const SkPath* path, SkRegion::Op op) {
SkMatrix transform;
currentTransform()->copyTo(transform);
@@ -177,7 +177,7 @@
return !mSnapshot->clipRect->isEmpty();
}
-bool StatefulBaseRenderer::clipRegion(SkRegion* region, SkRegion::Op op) {
+bool StatefulBaseRenderer::clipRegion(const SkRegion* region, SkRegion::Op op) {
mDirtyClip |= mSnapshot->clipRegionTransformed(*region, op);
return !mSnapshot->clipRect->isEmpty();
}
diff --git a/libs/hwui/StatefulBaseRenderer.h b/libs/hwui/StatefulBaseRenderer.h
index 20eca22..bf34bec 100644
--- a/libs/hwui/StatefulBaseRenderer.h
+++ b/libs/hwui/StatefulBaseRenderer.h
@@ -69,9 +69,9 @@
virtual void scale(float sx, float sy);
virtual void skew(float sx, float sy);
- virtual void setMatrix(SkMatrix* matrix);
+ virtual void setMatrix(const SkMatrix* matrix);
void setMatrix(const Matrix4& matrix); // internal only convenience method
- virtual void concatMatrix(SkMatrix* matrix);
+ virtual void concatMatrix(const SkMatrix* matrix);
void concatMatrix(const Matrix4& matrix); // internal only convenience method
// Clip
@@ -79,8 +79,8 @@
virtual bool quickRejectConservative(float left, float top, float right, float bottom) const;
virtual bool clipRect(float left, float top, float right, float bottom, SkRegion::Op op);
- virtual bool clipPath(SkPath* path, SkRegion::Op op);
- virtual bool clipRegion(SkRegion* region, SkRegion::Op op);
+ virtual bool clipPath(const SkPath* path, SkRegion::Op op);
+ virtual bool clipRegion(const SkRegion* region, SkRegion::Op op);
protected:
int getWidth() { return mWidth; }
diff --git a/libs/hwui/TextDropShadowCache.cpp b/libs/hwui/TextDropShadowCache.cpp
index 6f27b36..4eec462 100644
--- a/libs/hwui/TextDropShadowCache.cpp
+++ b/libs/hwui/TextDropShadowCache.cpp
@@ -168,7 +168,7 @@
mCache.clear();
}
-ShadowTexture* TextDropShadowCache::get(SkPaint* paint, const char* text, uint32_t len,
+ShadowTexture* TextDropShadowCache::get(const SkPaint* paint, const char* text, uint32_t len,
int numGlyphs, float radius, const float* positions) {
ShadowText entry(paint, radius, len, text, positions);
ShadowTexture* texture = mCache.get(entry);
diff --git a/libs/hwui/TextDropShadowCache.h b/libs/hwui/TextDropShadowCache.h
index 04d7357..54b930b 100644
--- a/libs/hwui/TextDropShadowCache.h
+++ b/libs/hwui/TextDropShadowCache.h
@@ -38,7 +38,7 @@
}
// len is the number of bytes in text
- ShadowText(SkPaint* paint, float radius, uint32_t len, const char* srcText,
+ ShadowText(const SkPaint* paint, float radius, uint32_t len, const char* srcText,
const float* positions):
len(len), radius(radius), positions(positions) {
// TODO: Propagate this through the API, we should not cast here
@@ -135,7 +135,7 @@
*/
void operator()(ShadowText& text, ShadowTexture*& texture);
- ShadowTexture* get(SkPaint* paint, const char* text, uint32_t len,
+ ShadowTexture* get(const SkPaint* paint, const char* text, uint32_t len,
int numGlyphs, float radius, const float* positions);
/**
diff --git a/libs/hwui/TextureCache.cpp b/libs/hwui/TextureCache.cpp
index 1d4af7f..457ca59 100644
--- a/libs/hwui/TextureCache.cpp
+++ b/libs/hwui/TextureCache.cpp
@@ -34,7 +34,7 @@
///////////////////////////////////////////////////////////////////////////////
TextureCache::TextureCache():
- mCache(LruCache<SkBitmap*, Texture*>::kUnlimitedCapacity),
+ mCache(LruCache<const SkBitmap*, Texture*>::kUnlimitedCapacity),
mSize(0), mMaxSize(MB(DEFAULT_TEXTURE_CACHE_SIZE)),
mFlushRate(DEFAULT_TEXTURE_CACHE_FLUSH_RATE) {
char property[PROPERTY_VALUE_MAX];
@@ -58,7 +58,7 @@
}
TextureCache::TextureCache(uint32_t maxByteSize):
- mCache(LruCache<SkBitmap*, Texture*>::kUnlimitedCapacity),
+ mCache(LruCache<const SkBitmap*, Texture*>::kUnlimitedCapacity),
mSize(0), mMaxSize(maxByteSize) {
init();
}
@@ -103,7 +103,7 @@
// Callbacks
///////////////////////////////////////////////////////////////////////////////
-void TextureCache::operator()(SkBitmap*&, Texture*& texture) {
+void TextureCache::operator()(const SkBitmap*&, Texture*& texture) {
// This will be called already locked
if (texture) {
mSize -= texture->bitmapSize;
@@ -121,7 +121,7 @@
// Caching
///////////////////////////////////////////////////////////////////////////////
-Texture* TextureCache::get(SkBitmap* bitmap) {
+Texture* TextureCache::get(const SkBitmap* bitmap) {
Texture* texture = mCache.get(bitmap);
if (!texture) {
@@ -161,7 +161,7 @@
return texture;
}
-Texture* TextureCache::getTransient(SkBitmap* bitmap) {
+Texture* TextureCache::getTransient(const SkBitmap* bitmap) {
Texture* texture = new Texture();
texture->bitmapSize = bitmap->rowBytes() * bitmap->height();
texture->cleanup = true;
@@ -171,11 +171,11 @@
return texture;
}
-void TextureCache::remove(SkBitmap* bitmap) {
+void TextureCache::remove(const SkBitmap* bitmap) {
mCache.remove(bitmap);
}
-void TextureCache::removeDeferred(SkBitmap* bitmap) {
+void TextureCache::removeDeferred(const SkBitmap* bitmap) {
Mutex::Autolock _l(mLock);
mGarbage.push(bitmap);
}
@@ -209,7 +209,7 @@
}
}
-void TextureCache::generateTexture(SkBitmap* bitmap, Texture* texture, bool regenerate) {
+void TextureCache::generateTexture(const SkBitmap* bitmap, Texture* texture, bool regenerate) {
SkAutoLockPixels alp(*bitmap);
if (!bitmap->readyToDraw()) {
@@ -282,7 +282,7 @@
}
}
-void TextureCache::uploadLoFiTexture(bool resize, SkBitmap* bitmap,
+void TextureCache::uploadLoFiTexture(bool resize, const SkBitmap* bitmap,
uint32_t width, uint32_t height) {
SkBitmap rgbaBitmap;
rgbaBitmap.setConfig(SkBitmap::kARGB_8888_Config, width, height);
diff --git a/libs/hwui/TextureCache.h b/libs/hwui/TextureCache.h
index 57fc19a..e33c60d 100644
--- a/libs/hwui/TextureCache.h
+++ b/libs/hwui/TextureCache.h
@@ -49,7 +49,7 @@
* Any texture added to the cache causing the cache to grow beyond the maximum
* allowed size will also cause the oldest texture to be kicked out.
*/
-class TextureCache: public OnEntryRemoved<SkBitmap*, Texture*> {
+class TextureCache: public OnEntryRemoved<const SkBitmap*, Texture*> {
public:
TextureCache();
TextureCache(uint32_t maxByteSize);
@@ -59,28 +59,28 @@
* Used as a callback when an entry is removed from the cache.
* Do not invoke directly.
*/
- void operator()(SkBitmap*& bitmap, Texture*& texture);
+ void operator()(const SkBitmap*& bitmap, Texture*& texture);
/**
* Returns the texture associated with the specified bitmap. If the texture
* cannot be found in the cache, a new texture is generated.
*/
- Texture* get(SkBitmap* bitmap);
+ Texture* get(const SkBitmap* bitmap);
/**
* Returns the texture associated with the specified bitmap. The generated
* texture is not kept in the cache. The caller must destroy the texture.
*/
- Texture* getTransient(SkBitmap* bitmap);
+ Texture* getTransient(const SkBitmap* bitmap);
/**
* Removes the texture associated with the specified bitmap.
* Upon remove the texture is freed.
*/
- void remove(SkBitmap* bitmap);
+ void remove(const SkBitmap* bitmap);
/**
* Removes the texture associated with the specified bitmap. This is meant
* to be called from threads that are not the EGL context thread.
*/
- void removeDeferred(SkBitmap* bitmap);
+ void removeDeferred(const SkBitmap* bitmap);
/**
* Process deferred removals.
*/
@@ -122,15 +122,15 @@
* @param regenerate If true, the bitmap data is reuploaded into the texture, but
* no new texture is generated.
*/
- void generateTexture(SkBitmap* bitmap, Texture* texture, bool regenerate = false);
+ void generateTexture(const SkBitmap* bitmap, Texture* texture, bool regenerate = false);
- void uploadLoFiTexture(bool resize, SkBitmap* bitmap, uint32_t width, uint32_t height);
+ void uploadLoFiTexture(bool resize, const SkBitmap* bitmap, uint32_t width, uint32_t height);
void uploadToTexture(bool resize, GLenum format, GLsizei stride,
GLsizei width, GLsizei height, GLenum type, const GLvoid * data);
void init();
- LruCache<SkBitmap*, Texture*> mCache;
+ LruCache<const SkBitmap*, Texture*> mCache;
uint32_t mSize;
uint32_t mMaxSize;
@@ -140,7 +140,7 @@
bool mDebugEnabled;
- Vector<SkBitmap*> mGarbage;
+ Vector<const SkBitmap*> mGarbage;
mutable Mutex mLock;
}; // class TextureCache
diff --git a/libs/hwui/font/Font.cpp b/libs/hwui/font/Font.cpp
index 12a9c23..b0945c6 100644
--- a/libs/hwui/font/Font.cpp
+++ b/libs/hwui/font/Font.cpp
@@ -267,7 +267,7 @@
glyph->mCacheTexture);
}
-CachedGlyphInfo* Font::getCachedGlyph(SkPaint* paint, glyph_t textUnit, bool precaching) {
+CachedGlyphInfo* Font::getCachedGlyph(const SkPaint* paint, glyph_t textUnit, bool precaching) {
CachedGlyphInfo* cachedGlyph = mCachedGlyphs.valueFor(textUnit);
if (cachedGlyph) {
// Is the glyph still in texture cache?
@@ -283,14 +283,14 @@
return cachedGlyph;
}
-void Font::render(SkPaint* paint, const char *text, uint32_t start, uint32_t len,
+void Font::render(const SkPaint* paint, const char *text, uint32_t start, uint32_t len,
int numGlyphs, int x, int y, const float* positions) {
render(paint, text, start, len, numGlyphs, x, y, FRAMEBUFFER, NULL,
0, 0, NULL, positions);
}
-void Font::render(SkPaint* paint, const char *text, uint32_t start, uint32_t len,
- int numGlyphs, SkPath* path, float hOffset, float vOffset) {
+void Font::render(const SkPaint* paint, const char *text, uint32_t start, uint32_t len,
+ int numGlyphs, const SkPath* path, float hOffset, float vOffset) {
if (numGlyphs == 0 || text == NULL || len == 0) {
return;
}
@@ -339,7 +339,7 @@
}
}
-void Font::measure(SkPaint* paint, const char* text, uint32_t start, uint32_t len,
+void Font::measure(const SkPaint* paint, const char* text, uint32_t start, uint32_t len,
int numGlyphs, Rect *bounds, const float* positions) {
if (bounds == NULL) {
ALOGE("No return rectangle provided to measure text");
@@ -349,7 +349,7 @@
render(paint, text, start, len, numGlyphs, 0, 0, MEASURE, NULL, 0, 0, bounds, positions);
}
-void Font::precache(SkPaint* paint, const char* text, int numGlyphs) {
+void Font::precache(const SkPaint* paint, const char* text, int numGlyphs) {
ATRACE_NAME("precacheText");
if (numGlyphs == 0 || text == NULL) {
@@ -370,7 +370,7 @@
}
}
-void Font::render(SkPaint* paint, const char* text, uint32_t start, uint32_t len,
+void Font::render(const SkPaint* paint, const char* text, uint32_t start, uint32_t len,
int numGlyphs, int x, int y, RenderMode mode, uint8_t *bitmap,
uint32_t bitmapW, uint32_t bitmapH, Rect* bounds, const float* positions) {
if (numGlyphs == 0 || text == NULL || len == 0) {
@@ -416,8 +416,8 @@
}
}
-void Font::updateGlyphCache(SkPaint* paint, const SkGlyph& skiaGlyph, SkGlyphCache* skiaGlyphCache,
- CachedGlyphInfo* glyph, bool precaching) {
+void Font::updateGlyphCache(const SkPaint* paint, const SkGlyph& skiaGlyph,
+ SkGlyphCache* skiaGlyphCache, CachedGlyphInfo* glyph, bool precaching) {
glyph->mAdvanceX = skiaGlyph.fAdvanceX;
glyph->mAdvanceY = skiaGlyph.fAdvanceY;
glyph->mBitmapLeft = skiaGlyph.fLeft;
@@ -460,7 +460,7 @@
}
}
-CachedGlyphInfo* Font::cacheGlyph(SkPaint* paint, glyph_t glyph, bool precaching) {
+CachedGlyphInfo* Font::cacheGlyph(const SkPaint* paint, glyph_t glyph, bool precaching) {
CachedGlyphInfo* newGlyph = new CachedGlyphInfo();
mCachedGlyphs.add(glyph, newGlyph);
diff --git a/libs/hwui/font/Font.h b/libs/hwui/font/Font.h
index f68b430..02197bc 100644
--- a/libs/hwui/font/Font.h
+++ b/libs/hwui/font/Font.h
@@ -77,11 +77,11 @@
~Font();
- void render(SkPaint* paint, const char* text, uint32_t start, uint32_t len,
+ void render(const SkPaint* paint, const char* text, uint32_t start, uint32_t len,
int numGlyphs, int x, int y, const float* positions);
- void render(SkPaint* paint, const char* text, uint32_t start, uint32_t len,
- int numGlyphs, SkPath* path, float hOffset, float vOffset);
+ void render(const SkPaint* paint, const char* text, uint32_t start, uint32_t len,
+ int numGlyphs, const SkPath* path, float hOffset, float vOffset);
const Font::FontDescription& getDescription() const {
return mDescription;
@@ -106,20 +106,20 @@
MEASURE,
};
- void precache(SkPaint* paint, const char* text, int numGlyphs);
+ void precache(const SkPaint* paint, const char* text, int numGlyphs);
- void render(SkPaint* paint, const char *text, uint32_t start, uint32_t len,
+ void render(const SkPaint* paint, const char *text, uint32_t start, uint32_t len,
int numGlyphs, int x, int y, RenderMode mode, uint8_t *bitmap,
uint32_t bitmapW, uint32_t bitmapH, Rect *bounds, const float* positions);
- void measure(SkPaint* paint, const char* text, uint32_t start, uint32_t len,
+ void measure(const SkPaint* paint, const char* text, uint32_t start, uint32_t len,
int numGlyphs, Rect *bounds, const float* positions);
void invalidateTextureCache(CacheTexture* cacheTexture = NULL);
- CachedGlyphInfo* cacheGlyph(SkPaint* paint, glyph_t glyph, bool precaching);
- void updateGlyphCache(SkPaint* paint, const SkGlyph& skiaGlyph, SkGlyphCache* skiaGlyphCache,
- CachedGlyphInfo* glyph, bool precaching);
+ CachedGlyphInfo* cacheGlyph(const SkPaint* paint, glyph_t glyph, bool precaching);
+ void updateGlyphCache(const SkPaint* paint, const SkGlyph& skiaGlyph,
+ SkGlyphCache* skiaGlyphCache, CachedGlyphInfo* glyph, bool precaching);
void measureCachedGlyph(CachedGlyphInfo* glyph, int x, int y,
uint8_t *bitmap, uint32_t bitmapW, uint32_t bitmapH,
@@ -136,7 +136,8 @@
void drawCachedGlyph(CachedGlyphInfo* glyph, float x, float hOffset, float vOffset,
SkPathMeasure& measure, SkPoint* position, SkVector* tangent);
- CachedGlyphInfo* getCachedGlyph(SkPaint* paint, glyph_t textUnit, bool precaching = false);
+ CachedGlyphInfo* getCachedGlyph(const SkPaint* paint, glyph_t textUnit,
+ bool precaching = false);
FontRenderer* mState;
FontDescription mDescription;