Add overrides and switch to nullptr keyword

Changes generated with clang-modernize.

Additionally, fixed some struct-vs-class usage to make clang happy.

Change-Id: Ic6ef2427401ff1e794d26f21f7b44868fc75fb72
This commit is contained in:
Chris Craik
2014-12-22 14:28:49 -08:00
parent 07adacf499
commit e84a208317
32 changed files with 262 additions and 247 deletions

View File

@@ -106,7 +106,7 @@ public:
friend class AssetAtlas;
};
AssetAtlas(): mTexture(NULL), mImage(NULL),
AssetAtlas(): mTexture(nullptr), mImage(nullptr),
mBlendKey(true), mOpaqueKey(false) { }
~AssetAtlas() { terminate(); }

View File

@@ -161,7 +161,7 @@ public:
int getHeight() { return mHeight; }
inline const Snapshot* currentSnapshot() const {
return mSnapshot != NULL ? mSnapshot.get() : mFirstSnapshot.get();
return mSnapshot != nullptr ? mSnapshot.get() : mFirstSnapshot.get();
}
inline Snapshot* writableSnapshot() { return mSnapshot.get(); }
inline const Snapshot* firstSnapshot() const { return mFirstSnapshot.get(); }

View File

@@ -69,7 +69,7 @@ public:
class OpStatePair {
public:
OpStatePair()
: op(NULL), state(NULL) {}
: op(nullptr), state(nullptr) {}
OpStatePair(DrawOp* newOp, const DeferredDisplayState* newState)
: op(newOp), state(newState) {}
OpStatePair(const OpStatePair& other)

View File

@@ -74,48 +74,51 @@ public:
// ----------------------------------------------------------------------------
// Frame state operations
// ----------------------------------------------------------------------------
virtual void prepareDirty(float left, float top, float right, float bottom, bool opaque);
virtual void prepare(bool opaque) {
virtual void prepareDirty(float left, float top, float right,
float bottom, bool opaque) override;
virtual void prepare(bool opaque) override {
prepareDirty(0.0f, 0.0f, mState.getWidth(), mState.getHeight(), opaque);
}
virtual bool finish();
virtual bool finish() override;
virtual void interrupt();
virtual void resume();
// ----------------------------------------------------------------------------
// Canvas state operations
// ----------------------------------------------------------------------------
virtual void setViewport(int width, int height) { mState.setViewport(width, height); }
virtual void setViewport(int width, int height) override { mState.setViewport(width, height); }
// Save (layer)
virtual int getSaveCount() const { return mState.getSaveCount(); }
virtual int save(int flags);
virtual void restore();
virtual void restoreToCount(int saveCount);
virtual int getSaveCount() const override { return mState.getSaveCount(); }
virtual int save(int flags) override;
virtual void restore() override;
virtual void restoreToCount(int saveCount) override;
virtual int saveLayer(float left, float top, float right, float bottom,
const SkPaint* paint, int flags);
const SkPaint* paint, int flags) override;
// Matrix
virtual void getMatrix(SkMatrix* outMatrix) const { mState.getMatrix(outMatrix); }
virtual void getMatrix(SkMatrix* outMatrix) const override { mState.getMatrix(outMatrix); }
virtual void translate(float dx, float dy, float dz = 0.0f);
virtual void rotate(float degrees);
virtual void scale(float sx, float sy);
virtual void skew(float sx, float sy);
virtual void translate(float dx, float dy, float dz = 0.0f) override;
virtual void rotate(float degrees) override;
virtual void scale(float sx, float sy) override;
virtual void skew(float sx, float sy) override;
virtual void setMatrix(const SkMatrix& matrix);
virtual void concatMatrix(const SkMatrix& matrix);
virtual void setMatrix(const SkMatrix& matrix) override;
virtual void concatMatrix(const SkMatrix& matrix) override;
// Clip
virtual bool clipRect(float left, float top, float right, float bottom, SkRegion::Op op);
virtual bool clipPath(const SkPath* path, SkRegion::Op op);
virtual bool clipRegion(const SkRegion* region, SkRegion::Op op);
virtual bool clipRect(float left, float top, float right, float bottom,
SkRegion::Op op) override;
virtual bool clipPath(const SkPath* path, SkRegion::Op op) override;
virtual bool clipRegion(const SkRegion* region, SkRegion::Op op) override;
// Misc
virtual void setDrawFilter(SkDrawFilter* filter);
virtual const Rect& getLocalClipBounds() const { return mState.getLocalClipBounds(); }
virtual void setDrawFilter(SkDrawFilter* filter) override;
virtual const Rect& getLocalClipBounds() const override { return mState.getLocalClipBounds(); }
const Rect& getRenderTargetClipBounds() const { return mState.getRenderTargetClipBounds(); }
virtual bool quickRejectConservative(float left, float top, float right, float bottom) const {
virtual bool quickRejectConservative(float left, float top,
float right, float bottom) const override {
return mState.quickRejectConservative(left, top, right, bottom);
}
@@ -126,57 +129,57 @@ public:
// ----------------------------------------------------------------------------
// Canvas draw operations
// ----------------------------------------------------------------------------
virtual void drawColor(int color, SkXfermode::Mode mode);
virtual void drawColor(int color, SkXfermode::Mode mode) override;
// Bitmap-based
virtual void drawBitmap(const SkBitmap* bitmap, const SkPaint* paint);
virtual void drawBitmap(const SkBitmap* bitmap, const SkPaint* paint) override;
virtual void drawBitmap(const SkBitmap* bitmap, float srcLeft, float srcTop,
float srcRight, float srcBottom, float dstLeft, float dstTop,
float dstRight, float dstBottom, const SkPaint* paint);
virtual void drawBitmapData(const SkBitmap* bitmap, const SkPaint* paint);
float dstRight, float dstBottom, const SkPaint* paint) override;
virtual void drawBitmapData(const SkBitmap* bitmap, const SkPaint* paint) override;
virtual void drawBitmapMesh(const SkBitmap* bitmap, int meshWidth, int meshHeight,
const float* vertices, const int* colors, const SkPaint* paint);
const float* vertices, const int* colors, const SkPaint* paint) override;
virtual void drawPatch(const SkBitmap* bitmap, const Res_png_9patch* patch,
float left, float top, float right, float bottom, const SkPaint* paint);
float left, float top, float right, float bottom, const SkPaint* paint) override;
// Shapes
virtual void drawRect(float left, float top, float right, float bottom,
const SkPaint* paint);
virtual void drawRects(const float* rects, int count, const SkPaint* paint);
const SkPaint* paint) override;
virtual void drawRects(const float* rects, int count, const SkPaint* paint) override;
virtual void drawRoundRect(float left, float top, float right, float bottom,
float rx, float ry, const SkPaint* paint);
float rx, float ry, const SkPaint* paint) override;
virtual void drawRoundRect(CanvasPropertyPrimitive* left, CanvasPropertyPrimitive* top,
CanvasPropertyPrimitive* right, CanvasPropertyPrimitive* bottom,
CanvasPropertyPrimitive* rx, CanvasPropertyPrimitive* ry,
CanvasPropertyPaint* paint);
virtual void drawCircle(float x, float y, float radius, const SkPaint* paint);
virtual void drawCircle(float x, float y, float radius, const SkPaint* paint) override;
virtual void drawCircle(CanvasPropertyPrimitive* x, CanvasPropertyPrimitive* y,
CanvasPropertyPrimitive* radius, CanvasPropertyPaint* paint);
virtual void drawOval(float left, float top, float right, float bottom,
const SkPaint* paint);
const SkPaint* paint) override;
virtual void drawArc(float left, float top, float right, float bottom,
float startAngle, float sweepAngle, bool useCenter, const SkPaint* paint);
virtual void drawPath(const SkPath* path, const SkPaint* paint);
virtual void drawLines(const float* points, int count, const SkPaint* paint);
virtual void drawPoints(const float* points, int count, const SkPaint* paint);
float startAngle, float sweepAngle, bool useCenter, const SkPaint* paint) override;
virtual void drawPath(const SkPath* path, const SkPaint* paint) override;
virtual void drawLines(const float* points, int count, const SkPaint* paint) override;
virtual void drawPoints(const float* points, int count, const SkPaint* paint) override;
// Text
virtual void drawText(const char* text, int bytesCount, int count, float x, float y,
const float* positions, const SkPaint* paint, float totalAdvance, const Rect& bounds,
DrawOpMode drawOpMode = kDrawOpMode_Immediate);
DrawOpMode drawOpMode = kDrawOpMode_Immediate) override;
virtual void drawTextOnPath(const char* text, int bytesCount, int count, const SkPath* path,
float hOffset, float vOffset, const SkPaint* paint);
float hOffset, float vOffset, const SkPaint* paint) override;
virtual void drawPosText(const char* text, int bytesCount, int count,
const float* positions, const SkPaint* paint);
const float* positions, const SkPaint* paint) override;
// ----------------------------------------------------------------------------
// Canvas draw operations - special
// ----------------------------------------------------------------------------
virtual void drawLayer(DeferredLayerUpdater* layerHandle, float x, float y);
virtual void drawRenderNode(RenderNode* renderNode, Rect& dirty, int32_t replayFlags);
virtual void drawRenderNode(RenderNode* renderNode, Rect& dirty, int32_t replayFlags) override;
// TODO: rename for consistency
virtual void callDrawGLFunction(Functor* functor, Rect& dirty);
virtual void callDrawGLFunction(Functor* functor, Rect& dirty) override;
void setHighContrastText(bool highContrastText) {
mHighContrastText = highContrastText;
@@ -185,9 +188,9 @@ public:
// ----------------------------------------------------------------------------
// CanvasState callbacks
// ----------------------------------------------------------------------------
virtual void onViewportInitialized() { }
virtual void onSnapshotRestored(const Snapshot& removed, const Snapshot& restored) { }
virtual GLuint onGetTargetFbo() const { return -1; }
virtual void onViewportInitialized() override { }
virtual void onSnapshotRestored(const Snapshot& removed, const Snapshot& restored) override { }
virtual GLuint onGetTargetFbo() const override { return -1; }
private:
@@ -217,7 +220,7 @@ private:
template<class T>
inline const T* refBuffer(const T* srcBuffer, int32_t count) {
if (!srcBuffer) return NULL;
if (!srcBuffer) return nullptr;
T* dstBuffer = (T*) mDisplayListData->allocator.alloc(count * sizeof(T));
memcpy(dstBuffer, srcBuffer, count * sizeof(T));
@@ -229,10 +232,10 @@ private:
}
inline const SkPath* refPath(const SkPath* path) {
if (!path) return NULL;
if (!path) return nullptr;
const SkPath* pathCopy = mPathMap.valueFor(path);
if (pathCopy == NULL || pathCopy->getGenerationID() != path->getGenerationID()) {
if (pathCopy == nullptr || pathCopy->getGenerationID() != path->getGenerationID()) {
SkPath* newPathCopy = new SkPath(*path);
newPathCopy->setSourcePath(path);
@@ -249,7 +252,7 @@ private:
}
inline const SkPaint* refPaint(const SkPaint* paint) {
if (!paint) return NULL;
if (!paint) return nullptr;
// If there is a draw filter apply it here and store the modified paint
// so that we don't need to modify the paint every time we access it.
@@ -264,7 +267,7 @@ private:
const SkPaint* cachedPaint = mPaintMap.valueFor(key);
// In the unlikely event that 2 unique paints have the same hash we do a
// object equality check to ensure we don't erroneously dedup them.
if (cachedPaint == NULL || *cachedPaint != *paint) {
if (cachedPaint == nullptr || *cachedPaint != *paint) {
cachedPaint = new SkPaint(*paint);
// replaceValueFor() performs an add if the entry doesn't exist
mPaintMap.replaceValueFor(key, cachedPaint);
@@ -275,7 +278,7 @@ private:
}
inline SkPaint* copyPaint(const SkPaint* paint) {
if (!paint) return NULL;
if (!paint) return nullptr;
SkPaint* paintCopy = new SkPaint(*paint);
mDisplayListData->paints.add(paintCopy);
@@ -289,7 +292,7 @@ private:
const SkRegion* regionCopy = mRegionMap.valueFor(region);
// TODO: Add generation ID to SkRegion
if (regionCopy == NULL) {
if (regionCopy == nullptr) {
regionCopy = new SkRegion(*region);
// replaceValueFor() performs an add if the entry doesn't exist
mRegionMap.replaceValueFor(region, regionCopy);

View File

@@ -43,7 +43,7 @@ public:
Fence() {
mDisplay = eglGetDisplay(EGL_DEFAULT_DISPLAY);
if (mDisplay != EGL_NO_DISPLAY) {
mFence = eglCreateSyncKHR(mDisplay, EGL_SYNC_FENCE_KHR, NULL);
mFence = eglCreateSyncKHR(mDisplay, EGL_SYNC_FENCE_KHR, nullptr);
} else {
mFence = EGL_NO_SYNC_KHR;
}

View File

@@ -66,7 +66,7 @@ public:
}
~TextSetupFunctor() { }
status_t operator ()(int what, void* data);
status_t operator ()(int what, void* data) override;
OpenGLRenderer* renderer;
float x;

View File

@@ -59,36 +59,36 @@ public:
delete mRenderer;
}
void clear() {
void clear() override {
delete mRenderer;
mRenderer = NULL;
mRenderer = nullptr;
}
void flush() {
void flush() override {
if (mRenderer) {
mRenderer->flushLargeCaches();
}
}
FontRenderer& getFontRenderer(const SkPaint* paint) {
FontRenderer& getFontRenderer(const SkPaint* paint) override {
if (!mRenderer) {
mRenderer = new FontRenderer;
}
return *mRenderer;
}
uint32_t getFontRendererCount() const {
uint32_t getFontRendererCount() const override {
return 1;
}
uint32_t getFontRendererSize(uint32_t fontRenderer, GLenum format) const {
uint32_t getFontRendererSize(uint32_t fontRenderer, GLenum format) const override {
return mRenderer ? mRenderer->getCacheSize(format) : 0;
}
void describe(ProgramDescription& description, const SkPaint* paint) const;
void setupProgram(ProgramDescription& description, Program* program) const;
void describe(ProgramDescription& description, const SkPaint* paint) const override;
void setupProgram(ProgramDescription& description, Program* program) const override;
void endPrecaching();
void endPrecaching() override;
private:
ShaderGammaFontRenderer(bool multiGamma);
@@ -105,18 +105,18 @@ public:
delete mRenderer;
}
void clear() {
void clear() override {
delete mRenderer;
mRenderer = NULL;
mRenderer = nullptr;
}
void flush() {
void flush() override {
if (mRenderer) {
mRenderer->flushLargeCaches();
}
}
FontRenderer& getFontRenderer(const SkPaint* paint) {
FontRenderer& getFontRenderer(const SkPaint* paint) override {
if (!mRenderer) {
mRenderer = new FontRenderer;
mRenderer->setGammaTable(&mGammaTable[0]);
@@ -124,21 +124,21 @@ public:
return *mRenderer;
}
uint32_t getFontRendererCount() const {
uint32_t getFontRendererCount() const override {
return 1;
}
uint32_t getFontRendererSize(uint32_t fontRenderer, GLenum format) const {
uint32_t getFontRendererSize(uint32_t fontRenderer, GLenum format) const override {
return mRenderer ? mRenderer->getCacheSize(format) : 0;
}
void describe(ProgramDescription& description, const SkPaint* paint) const {
void describe(ProgramDescription& description, const SkPaint* paint) const override {
}
void setupProgram(ProgramDescription& description, Program* program) const {
void setupProgram(ProgramDescription& description, Program* program) const override {
}
void endPrecaching();
void endPrecaching() override;
private:
LookupGammaFontRenderer();
@@ -153,16 +153,16 @@ class Lookup3GammaFontRenderer: public GammaFontRenderer {
public:
~Lookup3GammaFontRenderer();
void clear();
void flush();
void clear() override;
void flush() override;
FontRenderer& getFontRenderer(const SkPaint* paint);
FontRenderer& getFontRenderer(const SkPaint* paint) override;
uint32_t getFontRendererCount() const {
uint32_t getFontRendererCount() const override {
return kGammaCount;
}
uint32_t getFontRendererSize(uint32_t fontRenderer, GLenum format) const {
uint32_t getFontRendererSize(uint32_t fontRenderer, GLenum format) const override {
if (fontRenderer >= kGammaCount) return 0;
FontRenderer* renderer = mRenderers[fontRenderer];
@@ -171,13 +171,13 @@ public:
return renderer->getCacheSize(format);
}
void describe(ProgramDescription& description, const SkPaint* paint) const {
void describe(ProgramDescription& description, const SkPaint* paint) const override {
}
void setupProgram(ProgramDescription& description, Program* program) const {
void setupProgram(ProgramDescription& description, Program* program) const override {
}
void endPrecaching();
void endPrecaching() override;
private:
Lookup3GammaFontRenderer();

View File

@@ -33,8 +33,8 @@ class Texture;
struct GradientCacheEntry {
GradientCacheEntry() {
count = 0;
colors = NULL;
positions = NULL;
colors = nullptr;
positions = nullptr;
}
GradientCacheEntry(uint32_t* colors, float* positions, uint32_t count) {
@@ -118,7 +118,7 @@ public:
* Used as a callback when an entry is removed from the cache.
* Do not invoke directly.
*/
void operator()(GradientCacheEntry& shader, Texture*& texture);
void operator()(GradientCacheEntry& shader, Texture*& texture) override;
/**
* Returns the texture associated with the specified shader.

View File

@@ -96,10 +96,10 @@ public:
private:
struct LayerEntry {
LayerEntry():
mLayer(NULL), mWidth(0), mHeight(0) {
mLayer(nullptr), mWidth(0), mHeight(0) {
}
LayerEntry(const uint32_t layerWidth, const uint32_t layerHeight): mLayer(NULL) {
LayerEntry(const uint32_t layerWidth, const uint32_t layerHeight): mLayer(nullptr) {
mWidth = Layer::computeIdealWidth(layerWidth);
mHeight = Layer::computeIdealHeight(layerHeight);
}

View File

@@ -210,7 +210,7 @@ public:
void decomposeScale(float& sx, float& sy) const;
void dump(const char* label = NULL) const;
void dump(const char* label = nullptr) const;
static const Matrix4& identity();

View File

@@ -680,7 +680,7 @@ int OpenGLRenderer::saveLayerDeferred(float left, float top, float right, float
writableSnapshot()->resetTransform(-bounds.left, -bounds.top, 0.0f);
writableSnapshot()->resetClip(clip.left, clip.top, clip.right, clip.bottom);
writableSnapshot()->initializeViewport(bounds.getWidth(), bounds.getHeight());
writableSnapshot()->roundRectClipState = NULL;
writableSnapshot()->roundRectClipState = nullptr;
}
}
@@ -791,7 +791,7 @@ bool OpenGLRenderer::createLayer(float left, float top, float right, float botto
// Unfortunately some drivers will turn the entire target texture black
// when reading outside of the window.
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, layer->getWidth(), layer->getHeight(),
0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
0, GL_RGBA, GL_UNSIGNED_BYTE, nullptr);
layer->setEmpty(false);
}
@@ -817,7 +817,7 @@ bool OpenGLRenderer::createFboLayer(Layer* layer, Rect& bounds, Rect& clip) {
writableSnapshot()->resetTransform(-bounds.left, -bounds.top, 0.0f);
writableSnapshot()->resetClip(clip.left, clip.top, clip.right, clip.bottom);
writableSnapshot()->initializeViewport(bounds.getWidth(), bounds.getHeight());
writableSnapshot()->roundRectClipState = NULL;
writableSnapshot()->roundRectClipState = nullptr;
endTiling();
debugOverdraw(false, false);
@@ -865,7 +865,7 @@ void OpenGLRenderer::composeLayer(const Snapshot& removed, const Snapshot& resto
bool clipRequired = false;
mState.calculateQuickRejectForScissor(rect.left, rect.top, rect.right, rect.bottom,
&clipRequired, NULL, false); // safely ignore return, should never be rejected
&clipRequired, nullptr, false); // safely ignore return, should never be rejected
mCaches.setScissorEnabled(mScissorOptimizationDisabled || clipRequired);
if (fboLayer) {
@@ -917,10 +917,10 @@ void OpenGLRenderer::composeLayer(const Snapshot& removed, const Snapshot& resto
dirtyClip();
// Failing to add the layer to the cache should happen only if the layer is too large
layer->setConvexMask(NULL);
layer->setConvexMask(nullptr);
if (!mCaches.layerCache.put(layer)) {
LAYER_LOGD("Deleting layer");
layer->decStrong(0);
layer->decStrong(nullptr);
}
}
@@ -1037,14 +1037,14 @@ public:
, mLayer(layer) {
}
virtual bool asACustomShader(void** data) const {
virtual bool asACustomShader(void** data) const override {
if (data) {
*data = static_cast<void*>(mLayer);
}
return true;
}
virtual bool isOpaque() const {
virtual bool isOpaque() const override {
return !mLayer->isBlend();
}
@@ -1053,13 +1053,13 @@ protected:
LOG_ALWAYS_FATAL("LayerShader should never be drawn with raster backend.");
}
virtual void flatten(SkWriteBuffer&) const {
virtual void flatten(SkWriteBuffer&) const override {
LOG_ALWAYS_FATAL("LayerShader should never be flattened.");
}
virtual Factory getFactory() const {
virtual Factory getFactory() const override {
LOG_ALWAYS_FATAL("LayerShader should never be created from a stream.");
return NULL;
return nullptr;
}
private:
// Unowned.
@@ -1092,7 +1092,7 @@ void OpenGLRenderer::composeLayerRegion(Layer* layer, const Rect& rect) {
const SkPath* maskPath = layer->getConvexMask();
DRAW_DOUBLE_STENCIL(drawConvexPath(*maskPath, &paint));
paint.setShader(NULL);
paint.setShader(nullptr);
restore();
return;
@@ -1173,7 +1173,7 @@ void OpenGLRenderer::composeLayerRegion(Layer* layer, const Rect& rect) {
if (numQuads >= gMaxNumberOfQuads) {
DRAW_DOUBLE_STENCIL(glDrawElements(GL_TRIANGLES, numQuads * 6,
GL_UNSIGNED_SHORT, NULL));
GL_UNSIGNED_SHORT, nullptr));
numQuads = 0;
mesh = mCaches.getRegionMesh();
}
@@ -1181,7 +1181,7 @@ void OpenGLRenderer::composeLayerRegion(Layer* layer, const Rect& rect) {
if (numQuads > 0) {
DRAW_DOUBLE_STENCIL(glDrawElements(GL_TRIANGLES, numQuads * 6,
GL_UNSIGNED_SHORT, NULL));
GL_UNSIGNED_SHORT, nullptr));
}
#if DEBUG_LAYERS_AS_REGIONS
@@ -1267,7 +1267,7 @@ void OpenGLRenderer::issueIndexedQuadDraw(Vertex* mesh, GLsizei quadsCount) {
GLsizei drawCount = min(elementsCount, (GLsizei) gMaxNumberOfQuads * 6);
setupDrawIndexedVertices(&mesh[0].x);
glDrawElements(GL_TRIANGLES, drawCount, GL_UNSIGNED_SHORT, NULL);
glDrawElements(GL_TRIANGLES, drawCount, GL_UNSIGNED_SHORT, nullptr);
elementsCount -= drawCount;
// Though there are 4 vertices in a quad, we use 6 indices per
@@ -1408,13 +1408,13 @@ void OpenGLRenderer::restoreDisplayState(const DeferredDisplayState& state, bool
* This method should be called when restoreDisplayState() won't be restoring the clip
*/
void OpenGLRenderer::setupMergedMultiDraw(const Rect* clipRect) {
if (clipRect != NULL) {
if (clipRect != nullptr) {
writableSnapshot()->setClip(clipRect->left, clipRect->top, clipRect->right, clipRect->bottom);
} else {
writableSnapshot()->setClip(0, 0, mState.getWidth(), mState.getHeight());
}
dirtyClip();
mCaches.setScissorEnabled(clipRect != NULL || mScissorOptimizationDisabled);
mCaches.setScissorEnabled(clipRect != nullptr || mScissorOptimizationDisabled);
}
///////////////////////////////////////////////////////////////////////////////
@@ -1643,21 +1643,21 @@ void OpenGLRenderer::setupDrawColor(float r, float g, float b, float a) {
}
void OpenGLRenderer::setupDrawShader(const SkShader* shader) {
if (shader != NULL) {
if (shader != nullptr) {
SkiaShader::describe(&mCaches, mDescription, mExtensions, *shader);
}
}
void OpenGLRenderer::setupDrawColorFilter(const SkColorFilter* filter) {
if (filter == NULL) {
if (filter == nullptr) {
return;
}
SkXfermode::Mode mode;
if (filter->asColorMode(NULL, &mode)) {
if (filter->asColorMode(nullptr, &mode)) {
mDescription.colorOp = ProgramDescription::kColorBlend;
mDescription.colorMode = mode;
} else if (filter->asColorMatrix(NULL)) {
} else if (filter->asColorMatrix(nullptr)) {
mDescription.colorOp = ProgramDescription::kColorMatrix;
}
}
@@ -1724,7 +1724,8 @@ void OpenGLRenderer::setupDrawModelView(ModelViewMode mode, bool offset,
bool dirty = right - left > 0.0f && bottom - top > 0.0f;
const Matrix4& transformMatrix = ignoreTransform ? Matrix4::identity() : *currentTransform();
mCaches.currentProgram->set(writableSnapshot()->getOrthoMatrix(), mModelViewMatrix, transformMatrix, offset);
mCaches.currentProgram->set(writableSnapshot()->getOrthoMatrix(),
mModelViewMatrix, transformMatrix, offset);
if (dirty && mTrackDirtyRegions) {
if (!ignoreTransform) {
dirtyLayer(left, top, right, bottom, *currentTransform());
@@ -1747,7 +1748,7 @@ void OpenGLRenderer::setupDrawPureColorUniforms() {
}
void OpenGLRenderer::setupDrawShaderUniforms(const SkShader* shader, bool ignoreTransform) {
if (shader == NULL) {
if (shader == nullptr) {
return;
}
@@ -1765,7 +1766,7 @@ void OpenGLRenderer::setupDrawShaderUniforms(const SkShader* shader, bool ignore
}
void OpenGLRenderer::setupDrawColorFilterUniforms(const SkColorFilter* filter) {
if (NULL == filter) {
if (nullptr == filter) {
return;
}
@@ -1813,7 +1814,7 @@ void OpenGLRenderer::setupDrawTextGammaUniforms() {
void OpenGLRenderer::setupDrawSimpleMesh() {
bool force = mCaches.bindMeshBuffer();
mCaches.bindPositionVertexPointer(force, 0);
mCaches.bindPositionVertexPointer(force, nullptr);
mCaches.unbindIndicesBuffer();
}
@@ -1933,7 +1934,8 @@ void OpenGLRenderer::drawRenderNode(RenderNode* renderNode, Rect& dirty, int32_t
}
}
void OpenGLRenderer::drawAlphaBitmap(Texture* texture, float left, float top, const SkPaint* paint) {
void OpenGLRenderer::drawAlphaBitmap(Texture* texture, float left, float top,
const SkPaint* paint) {
float x = left;
float y = top;
@@ -1953,7 +1955,7 @@ void OpenGLRenderer::drawAlphaBitmap(Texture* texture, float left, float top, co
// No need to check for a UV mapper on the texture object, only ARGB_8888
// bitmaps get packed in the atlas
drawAlpha8TextureMesh(x, y, x + texture->width, y + texture->height, texture->id,
paint, (GLvoid*) NULL, (GLvoid*) gMeshTextureOffset,
paint, (GLvoid*) nullptr, (GLvoid*) gMeshTextureOffset,
GL_TRIANGLE_STRIP, gMeshCount, ignoreTransform);
}
@@ -2374,14 +2376,16 @@ void OpenGLRenderer::drawVertexBuffer(float translateX, float translateY,
glDrawArrays(GL_TRIANGLE_STRIP, 0, vertexBuffer.getVertexCount());
} else if (mode == VertexBuffer::kOnePolyRingShadow) {
mCaches.bindShadowIndicesBuffer();
glDrawElements(GL_TRIANGLE_STRIP, ONE_POLY_RING_SHADOW_INDEX_COUNT, GL_UNSIGNED_SHORT, 0);
glDrawElements(GL_TRIANGLE_STRIP, ONE_POLY_RING_SHADOW_INDEX_COUNT,
GL_UNSIGNED_SHORT, nullptr);
} else if (mode == VertexBuffer::kTwoPolyRingShadow) {
mCaches.bindShadowIndicesBuffer();
glDrawElements(GL_TRIANGLE_STRIP, TWO_POLY_RING_SHADOW_INDEX_COUNT, GL_UNSIGNED_SHORT, 0);
glDrawElements(GL_TRIANGLE_STRIP, TWO_POLY_RING_SHADOW_INDEX_COUNT,
GL_UNSIGNED_SHORT, nullptr);
} else if (mode == VertexBuffer::kIndices) {
mCaches.unbindIndicesBuffer();
glDrawElements(GL_TRIANGLE_STRIP, vertexBuffer.getIndexCount(), GL_UNSIGNED_SHORT,
vertexBuffer.getIndices());
glDrawElements(GL_TRIANGLE_STRIP, vertexBuffer.getIndexCount(),
GL_UNSIGNED_SHORT, vertexBuffer.getIndices());
}
if (isAA) {
@@ -2491,7 +2495,7 @@ void OpenGLRenderer::drawRoundRect(float left, float top, float right, float bot
return;
}
if (p->getPathEffect() != 0) {
if (p->getPathEffect() != nullptr) {
mCaches.activeTexture(0);
const PathTexture* texture = mCaches.pathCache.getRoundRect(
right - left, bottom - top, rx, ry, p);
@@ -2509,7 +2513,7 @@ void OpenGLRenderer::drawCircle(float x, float y, float radius, const SkPaint* p
|| paintWillNotDraw(*p)) {
return;
}
if (p->getPathEffect() != 0) {
if (p->getPathEffect() != nullptr) {
mCaches.activeTexture(0);
const PathTexture* texture = mCaches.pathCache.getCircle(radius, p);
drawShape(x - radius, y - radius, texture, p);
@@ -2532,7 +2536,7 @@ void OpenGLRenderer::drawOval(float left, float top, float right, float bottom,
return;
}
if (p->getPathEffect() != 0) {
if (p->getPathEffect() != nullptr) {
mCaches.activeTexture(0);
const PathTexture* texture = mCaches.pathCache.getOval(right - left, bottom - top, p);
drawShape(left, top, texture, p);
@@ -2556,7 +2560,7 @@ void OpenGLRenderer::drawArc(float left, float top, float right, float bottom,
}
// TODO: support fills (accounting for concavity if useCenter && sweepAngle > 180)
if (p->getStyle() != SkPaint::kStroke_Style || p->getPathEffect() != 0 || useCenter) {
if (p->getStyle() != SkPaint::kStroke_Style || p->getPathEffect() != nullptr || useCenter) {
mCaches.activeTexture(0);
const PathTexture* texture = mCaches.pathCache.getArc(right - left, bottom - top,
startAngle, sweepAngle, useCenter, p);
@@ -2592,7 +2596,7 @@ void OpenGLRenderer::drawRect(float left, float top, float right, float bottom,
if (p->getStyle() != SkPaint::kFill_Style) {
// only fill style is supported by drawConvexPath, since others have to handle joins
if (p->getPathEffect() != 0 || p->getStrokeJoin() != SkPaint::kMiter_Join ||
if (p->getPathEffect() != nullptr || p->getStrokeJoin() != SkPaint::kMiter_Join ||
p->getStrokeMiter() != SkPaintDefaults_MiterLimit) {
mCaches.activeTexture(0);
const PathTexture* texture =
@@ -2661,7 +2665,7 @@ void OpenGLRenderer::drawTextShadow(const SkPaint* paint, const char* text,
setupDrawPureColorUniforms();
setupDrawColorFilterUniforms(getColorFilter(paint));
setupDrawShaderUniforms(getShader(paint));
setupDrawMesh(NULL, (GLvoid*) gMeshTextureOffset);
setupDrawMesh(nullptr, (GLvoid*) gMeshTextureOffset);
glDrawArrays(GL_TRIANGLE_STRIP, 0, gMeshCount);
}
@@ -2673,7 +2677,7 @@ bool OpenGLRenderer::canSkipText(const SkPaint* paint) const {
void OpenGLRenderer::drawPosText(const char* text, int bytesCount, int count,
const float* positions, const SkPaint* paint) {
if (text == NULL || count == 0 || mState.currentlyIgnored() || canSkipText(paint)) {
if (text == nullptr || count == 0 || mState.currentlyIgnored() || canSkipText(paint)) {
return;
}
@@ -2718,7 +2722,7 @@ void OpenGLRenderer::drawPosText(const char* text, int bytesCount, int count,
TextSetupFunctor functor(this, x, y, pureTranslate, alpha, mode, paint);
if (fontRenderer.renderPosText(paint, clip, text, 0, bytesCount, count, x, y,
positions, hasActiveLayer ? &bounds : NULL, &functor)) {
positions, hasActiveLayer ? &bounds : nullptr, &functor)) {
if (hasActiveLayer) {
if (!pureTranslate) {
currentTransform()->mapRect(bounds);
@@ -2821,7 +2825,7 @@ void OpenGLRenderer::drawText(const char* text, int bytesCount, int count, float
if (drawOpMode == kDrawOpMode_Immediate) {
// The checks for corner-case ignorable text and quick rejection is only done for immediate
// drawing as ops from DeferredDisplayList are already filtered for these
if (text == NULL || count == 0 || mState.currentlyIgnored() || canSkipText(paint) ||
if (text == nullptr || count == 0 || mState.currentlyIgnored() || canSkipText(paint) ||
quickRejectSetupScissor(bounds)) {
return;
}
@@ -2871,7 +2875,7 @@ void OpenGLRenderer::drawText(const char* text, int bytesCount, int count, float
fontRenderer.setTextureFiltering(linearFilter);
// TODO: Implement better clipping for scaled/rotated text
const Rect* clip = !pureTranslate ? NULL : mState.currentClipRect();
const Rect* clip = !pureTranslate ? nullptr : mState.currentClipRect();
Rect layerBounds(FLT_MAX / 2.0f, FLT_MAX / 2.0f, FLT_MIN / 2.0f, FLT_MIN / 2.0f);
bool status;
@@ -2883,10 +2887,10 @@ void OpenGLRenderer::drawText(const char* text, int bytesCount, int count, float
SkPaint paintCopy(*paint);
paintCopy.setTextAlign(SkPaint::kLeft_Align);
status = fontRenderer.renderPosText(&paintCopy, clip, text, 0, bytesCount, count, x, y,
positions, hasActiveLayer ? &layerBounds : NULL, &functor, forceFinish);
positions, hasActiveLayer ? &layerBounds : nullptr, &functor, forceFinish);
} else {
status = fontRenderer.renderPosText(paint, clip, text, 0, bytesCount, count, x, y,
positions, hasActiveLayer ? &layerBounds : NULL, &functor, forceFinish);
positions, hasActiveLayer ? &layerBounds : nullptr, &functor, forceFinish);
}
if ((status || drawOpMode != kDrawOpMode_Immediate) && hasActiveLayer) {
@@ -2903,7 +2907,7 @@ void OpenGLRenderer::drawText(const char* text, int bytesCount, int count, float
void OpenGLRenderer::drawTextOnPath(const char* text, int bytesCount, int count,
const SkPath* path, float hOffset, float vOffset, const SkPaint* paint) {
if (text == NULL || count == 0 || mState.currentlyIgnored() || canSkipText(paint)) {
if (text == nullptr || count == 0 || mState.currentlyIgnored() || canSkipText(paint)) {
return;
}
@@ -2925,7 +2929,7 @@ void OpenGLRenderer::drawTextOnPath(const char* text, int bytesCount, int count,
const bool hasActiveLayer = hasLayer();
if (fontRenderer.renderTextOnPath(paint, clip, text, 0, bytesCount, count, path,
hOffset, vOffset, hasActiveLayer ? &bounds : NULL, &functor)) {
hOffset, vOffset, hasActiveLayer ? &bounds : nullptr, &functor)) {
if (hasActiveLayer) {
currentTransform()->mapRect(bounds);
dirtyLayerUnchecked(bounds, getRegion());
@@ -2956,7 +2960,7 @@ void OpenGLRenderer::drawLayer(Layer* layer, float x, float y) {
return;
}
mat4* transform = NULL;
mat4* transform = nullptr;
if (layer->isTextureLayer()) {
transform = &layer->getTransform();
if (!transform->isIdentity()) {
@@ -2966,8 +2970,9 @@ void OpenGLRenderer::drawLayer(Layer* layer, float x, float y) {
}
bool clipRequired = false;
const bool rejected = mState.calculateQuickRejectForScissor(x, y,
x + layer->layer.getWidth(), y + layer->layer.getHeight(), &clipRequired, NULL, false);
const bool rejected = mState.calculateQuickRejectForScissor(
x, y, x + layer->layer.getWidth(), y + layer->layer.getHeight(),
&clipRequired, nullptr, false);
if (rejected) {
if (transform && !transform->isIdentity()) {
@@ -3021,7 +3026,7 @@ void OpenGLRenderer::drawLayer(Layer* layer, float x, float y) {
setupDrawMeshIndices(&mesh[0].x, &mesh[0].u);
DRAW_DOUBLE_STENCIL_IF(!layer->hasDrawnSinceUpdate,
glDrawElements(GL_TRIANGLES, drawCount, GL_UNSIGNED_SHORT, NULL));
glDrawElements(GL_TRIANGLES, drawCount, GL_UNSIGNED_SHORT, nullptr));
elementsCount -= drawCount;
// Though there are 4 vertices in a quad, we use 6 indices per
@@ -3095,7 +3100,7 @@ void OpenGLRenderer::drawPathTexture(const PathTexture* texture,
setupDrawPureColorUniforms();
setupDrawColorFilterUniforms(getColorFilter(paint));
setupDrawShaderUniforms(getShader(paint));
setupDrawMesh(NULL, (GLvoid*) gMeshTextureOffset);
setupDrawMesh(nullptr, (GLvoid*) gMeshTextureOffset);
glDrawArrays(GL_TRIANGLE_STRIP, 0, gMeshCount);
}
@@ -3283,7 +3288,7 @@ void OpenGLRenderer::drawTextureRect(float left, float top, float right, float b
Texture* texture, const SkPaint* paint) {
texture->setWrap(GL_CLAMP_TO_EDGE, true);
GLvoid* vertices = (GLvoid*) NULL;
GLvoid* vertices = (GLvoid*) nullptr;
GLvoid* texCoords = (GLvoid*) gMeshTextureOffset;
if (texture->uvMapper) {
@@ -3366,7 +3371,7 @@ void OpenGLRenderer::drawIndexedTextureMesh(float left, float top, float right,
setupDrawColorFilterUniforms(getColorFilter(paint));
setupDrawMeshIndices(vertices, texCoords, vbo);
glDrawElements(drawMode, elementsCount, GL_UNSIGNED_SHORT, NULL);
glDrawElements(drawMode, elementsCount, GL_UNSIGNED_SHORT, nullptr);
}
void OpenGLRenderer::drawAlpha8TextureMesh(float left, float top, float right, float bottom,
@@ -3374,14 +3379,14 @@ void OpenGLRenderer::drawAlpha8TextureMesh(float left, float top, float right, f
GLvoid* vertices, GLvoid* texCoords, GLenum drawMode, GLsizei elementsCount,
bool ignoreTransform, ModelViewMode modelViewMode, bool dirty) {
int color = paint != NULL ? paint->getColor() : 0;
int color = paint != nullptr ? paint->getColor() : 0;
int alpha;
SkXfermode::Mode mode;
getAlphaAndMode(paint, &alpha, &mode);
setupDraw();
setupDrawWithTexture(true);
if (paint != NULL) {
if (paint != nullptr) {
setupDrawAlpha8Color(color, alpha);
}
setupDrawColorFilter(getColorFilter(paint));
@@ -3402,7 +3407,7 @@ void OpenGLRenderer::drawAlpha8TextureMesh(float left, float top, float right, f
void OpenGLRenderer::chooseBlending(bool blend, SkXfermode::Mode mode,
ProgramDescription& description, bool swapSrcDst) {
if (writableSnapshot()->roundRectClipState != NULL /*&& !mSkipOutlineClip*/) {
if (writableSnapshot()->roundRectClipState != nullptr /*&& !mSkipOutlineClip*/) {
blend = true;
mDescription.hasRoundRectClip = true;
}
@@ -3452,7 +3457,7 @@ void OpenGLRenderer::chooseBlending(bool blend, SkXfermode::Mode mode,
bool OpenGLRenderer::useProgram(Program* program) {
if (!program->isInUse()) {
if (mCaches.currentProgram != NULL) mCaches.currentProgram->remove();
if (mCaches.currentProgram != nullptr) mCaches.currentProgram->remove();
program->use();
mCaches.currentProgram = program;
return false;
@@ -3468,7 +3473,8 @@ void OpenGLRenderer::resetDrawTextureTexCoords(float u1, float v1, float u2, flo
TextureVertex::setUV(v++, u2, v2);
}
void OpenGLRenderer::getAlphaAndMode(const 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

View File

@@ -126,13 +126,14 @@ public:
void initLight(const Vector3& lightCenter, float lightRadius,
uint8_t ambientShadowAlpha, uint8_t spotShadowAlpha);
virtual void prepareDirty(float left, float top, float right, float bottom, bool opaque);
virtual void prepare(bool opaque) {
virtual void prepareDirty(float left, float top, float right, float bottom,
bool opaque) override;
virtual void prepare(bool opaque) override {
prepareDirty(0.0f, 0.0f, mState.getWidth(), mState.getHeight(), opaque);
}
virtual bool finish();
virtual bool finish() override;
virtual void callDrawGLFunction(Functor* functor, Rect& dirty);
virtual void callDrawGLFunction(Functor* functor, Rect& dirty) override;
void pushLayerUpdate(Layer* layer);
void cancelLayerUpdate(Layer* layer);
@@ -140,8 +141,8 @@ public:
void markLayersAsBuildLayers();
virtual int saveLayer(float left, float top, float right, float bottom,
const SkPaint* paint, int flags) {
return saveLayer(left, top, right, bottom, paint, flags, NULL);
const SkPaint* paint, int flags) override {
return saveLayer(left, top, right, bottom, paint, flags, nullptr);
}
// Specialized saveLayer implementation, which will pass the convexMask to an FBO layer, if
@@ -152,49 +153,51 @@ public:
int saveLayerDeferred(float left, float top, float right, float bottom,
const SkPaint* paint, int flags);
virtual void drawRenderNode(RenderNode* displayList, Rect& dirty, int32_t replayFlags = 1);
virtual void drawRenderNode(RenderNode* displayList, Rect& dirty,
int32_t replayFlags = 1) override;
virtual void drawLayer(Layer* layer, float x, float y);
virtual void drawBitmap(const SkBitmap* bitmap, const SkPaint* paint);
virtual void drawBitmap(const SkBitmap* bitmap, const SkPaint* paint) override;
void drawBitmaps(const SkBitmap* bitmap, AssetAtlas::Entry* entry, int bitmapCount,
TextureVertex* vertices, bool pureTranslate, const Rect& bounds, const SkPaint* paint);
virtual void drawBitmap(const SkBitmap* bitmap, float srcLeft, float srcTop,
float srcRight, float srcBottom, float dstLeft, float dstTop,
float dstRight, float dstBottom, const SkPaint* paint);
virtual void drawBitmapData(const SkBitmap* bitmap, const SkPaint* paint);
float dstRight, float dstBottom, const SkPaint* paint) override;
virtual void drawBitmapData(const SkBitmap* bitmap, const SkPaint* paint) override;
virtual void drawBitmapMesh(const SkBitmap* bitmap, int meshWidth, int meshHeight,
const float* vertices, const int* colors, const SkPaint* paint);
const float* vertices, const int* colors, const SkPaint* paint) override;
void drawPatches(const SkBitmap* bitmap, AssetAtlas::Entry* entry,
TextureVertex* vertices, uint32_t indexCount, const SkPaint* paint);
virtual void drawPatch(const SkBitmap* bitmap, const Res_png_9patch* patch,
float left, float top, float right, float bottom, const SkPaint* paint);
float left, float top, float right, float bottom, const SkPaint* paint) override;
void drawPatch(const SkBitmap* bitmap, const Patch* mesh, AssetAtlas::Entry* entry,
float left, float top, float right, float bottom, const SkPaint* paint);
virtual void drawColor(int color, SkXfermode::Mode mode);
virtual void drawColor(int color, SkXfermode::Mode mode) override;
virtual void drawRect(float left, float top, float right, float bottom,
const SkPaint* paint);
const SkPaint* paint) override;
virtual void drawRoundRect(float left, float top, float right, float bottom,
float rx, float ry, const SkPaint* paint);
virtual void drawCircle(float x, float y, float radius, const SkPaint* paint);
float rx, float ry, const SkPaint* paint) override;
virtual void drawCircle(float x, float y, float radius, const SkPaint* paint) override;
virtual void drawOval(float left, float top, float right, float bottom,
const SkPaint* paint);
const SkPaint* paint) override;
virtual void drawArc(float left, float top, float right, float bottom,
float startAngle, float sweepAngle, bool useCenter, const SkPaint* paint);
virtual void drawPath(const SkPath* path, const SkPaint* paint);
virtual void drawLines(const float* points, int count, const SkPaint* paint);
virtual void drawPoints(const float* points, int count, const SkPaint* paint);
float startAngle, float sweepAngle, bool useCenter, const SkPaint* paint) override;
virtual void drawPath(const SkPath* path, const SkPaint* paint) override;
virtual void drawLines(const float* points, int count, const SkPaint* paint) override;
virtual void drawPoints(const float* points, int count, const SkPaint* paint) override;
virtual void drawTextOnPath(const char* text, int bytesCount, int count, const SkPath* path,
float hOffset, float vOffset, const SkPaint* paint);
float hOffset, float vOffset, const SkPaint* paint) override;
virtual void drawPosText(const char* text, int bytesCount, int count,
const float* positions, const SkPaint* paint);
const float* positions, const SkPaint* paint) override;
virtual void drawText(const char* text, int bytesCount, int count, float x, float y,
const float* positions, const SkPaint* paint, float totalAdvance, const Rect& bounds,
DrawOpMode drawOpMode = kDrawOpMode_Immediate);
virtual void drawRects(const float* rects, int count, const SkPaint* paint);
DrawOpMode drawOpMode = kDrawOpMode_Immediate) override;
virtual void drawRects(const float* rects, int count, const SkPaint* paint) override;
void drawShadow(float casterAlpha,
const VertexBuffer* ambientShadowVertexBuffer, const VertexBuffer* spotShadowVertexBuffer);
const VertexBuffer* ambientShadowVertexBuffer,
const VertexBuffer* spotShadowVertexBuffer);
virtual void setDrawFilter(SkDrawFilter* filter);
virtual void setDrawFilter(SkDrawFilter* filter) override;
// If this value is set to < 1.0, it overrides alpha set on layer (see drawBitmap, drawLayer)
void setOverrideLayerAlpha(float alpha) { mDrawModifiers.mOverrideLayerAlpha = alpha; }
@@ -264,7 +267,8 @@ public:
* @param alpha Where to store the resulting alpha
* @param mode Where to store the resulting xfermode
*/
static inline void getAlphaAndModeDirect(const 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);
}
@@ -301,7 +305,7 @@ public:
}
static inline bool hasTextShadow(const SkPaint* paint) {
return getTextShadow(paint, NULL);
return getTextShadow(paint, nullptr);
}
/**
@@ -335,34 +339,36 @@ public:
///////////////////////////////////////////////////////////////////
/// State manipulation
virtual void setViewport(int width, int height) { mState.setViewport(width, height); }
virtual void setViewport(int width, int height) override { mState.setViewport(width, height); }
virtual int getSaveCount() const;
virtual int save(int flags);
virtual void restore();
virtual void restoreToCount(int saveCount);
virtual int getSaveCount() const override;
virtual int save(int flags) override;
virtual void restore() override;
virtual void restoreToCount(int saveCount) override;
virtual void getMatrix(SkMatrix* outMatrix) const { mState.getMatrix(outMatrix); }
virtual void setMatrix(const SkMatrix& matrix) { mState.setMatrix(matrix); }
virtual void concatMatrix(const SkMatrix& matrix) { mState.concatMatrix(matrix); }
virtual void getMatrix(SkMatrix* outMatrix) const override { mState.getMatrix(outMatrix); }
virtual void setMatrix(const SkMatrix& matrix) override { mState.setMatrix(matrix); }
virtual void concatMatrix(const SkMatrix& matrix) override { mState.concatMatrix(matrix); }
virtual void translate(float dx, float dy, float dz = 0.0f);
virtual void rotate(float degrees);
virtual void scale(float sx, float sy);
virtual void skew(float sx, float sy);
virtual void translate(float dx, float dy, float dz = 0.0f) override;
virtual void rotate(float degrees) override;
virtual void scale(float sx, float sy) override;
virtual void skew(float sx, float sy) override;
void setMatrix(const Matrix4& matrix); // internal only convenience method
void concatMatrix(const Matrix4& matrix); // internal only convenience method
virtual const Rect& getLocalClipBounds() const { return mState.getLocalClipBounds(); }
virtual const Rect& getLocalClipBounds() const override { return mState.getLocalClipBounds(); }
const Rect& getRenderTargetClipBounds() const { return mState.getRenderTargetClipBounds(); }
virtual bool quickRejectConservative(float left, float top, float right, float bottom) const {
virtual bool quickRejectConservative(float left, float top,
float right, float bottom) const override {
return mState.quickRejectConservative(left, top, right, bottom);
}
virtual bool clipRect(float left, float top, float right, float bottom, SkRegion::Op op);
virtual bool clipPath(const SkPath* path, SkRegion::Op op);
virtual bool clipRegion(const SkRegion* region, SkRegion::Op op);
virtual bool clipRect(float left, float top,
float right, float bottom, SkRegion::Op op) override;
virtual bool clipPath(const SkPath* path, SkRegion::Op op) override;
virtual bool clipRegion(const SkRegion* region, SkRegion::Op op) override;
/**
* Does not support different clipping Ops (that is, every call to setClippingOutline is
@@ -380,9 +386,9 @@ public:
///////////////////////////////////////////////////////////////////
/// CanvasStateClient interface
virtual void onViewportInitialized();
virtual void onSnapshotRestored(const Snapshot& removed, const Snapshot& restored);
virtual GLuint onGetTargetFbo() const { return 0; }
virtual void onViewportInitialized() override;
virtual void onSnapshotRestored(const Snapshot& removed, const Snapshot& restored) override;
virtual GLuint onGetTargetFbo() const override { return 0; }
SkPath* allocPathForFrame() {
SkPath* path = new SkPath();
@@ -427,8 +433,8 @@ protected:
void attachStencilBufferToLayer(Layer* layer);
bool quickRejectSetupScissor(float left, float top, float right, float bottom,
const SkPaint* paint = NULL);
bool quickRejectSetupScissor(const Rect& bounds, const SkPaint* paint = NULL) {
const SkPaint* paint = nullptr);
bool quickRejectSetupScissor(const Rect& bounds, const SkPaint* paint = nullptr) {
return quickRejectSetupScissor(bounds.left, bounds.top,
bounds.right, bounds.bottom, paint);
}
@@ -495,7 +501,7 @@ protected:
* null then null is returned.
*/
static inline SkColorFilter* getColorFilter(const SkPaint* paint) {
return paint ? paint->getColorFilter() : NULL;
return paint ? paint->getColorFilter() : nullptr;
}
/**
@@ -503,7 +509,7 @@ protected:
* null then null is returned.
*/
static inline const SkShader* getShader(const SkPaint* paint) {
return paint ? paint->getShader() : NULL;
return paint ? paint->getShader() : nullptr;
}
/**
@@ -903,8 +909,8 @@ private:
* space must be scaled up and translated to fill the quad provided in (l,t,r,b). These
* transformations are stored in the modelView matrix and uploaded to the shader.
*
* @param offset Set to true if the the matrix should be fudged (translated) slightly to disambiguate
* geometry pixel positioning. See Vertex::GeometryFudgeFactor().
* @param offset Set to true if the the matrix should be fudged (translated) slightly to
* disambiguate geometry pixel positioning. See Vertex::GeometryFudgeFactor().
*
* @param ignoreTransform Set to true if l,t,r,b coordinates already in layer space,
* currentTransform() will be ignored. (e.g. when drawing clip in layer coordinates to stencil,
@@ -930,7 +936,7 @@ private:
void setupDrawTextureTransform();
void setupDrawTextureTransformUniforms(mat4& transform);
void setupDrawTextGammaUniforms();
void setupDrawMesh(const GLvoid* vertices, const GLvoid* texCoords = NULL, GLuint vbo = 0);
void setupDrawMesh(const GLvoid* vertices, const GLvoid* texCoords = nullptr, GLuint vbo = 0);
void setupDrawMesh(const GLvoid* vertices, const GLvoid* texCoords, const GLvoid* colors);
void setupDrawMeshIndices(const GLvoid* vertices, const GLvoid* texCoords, GLuint vbo = 0);
void setupDrawIndexedVertices(GLvoid* vertices);

View File

@@ -95,7 +95,7 @@ public:
}
const SkPath* getPath() const {
if (mType == kOutlineType_None || mType == kOutlineType_Empty) return NULL;
if (mType == kOutlineType_None || mType == kOutlineType_Empty) return nullptr;
return &mPath;
}

View File

@@ -31,7 +31,7 @@
namespace android {
namespace uirenderer {
class TextureVertex;
struct TextureVertex;
///////////////////////////////////////////////////////////////////////////////
// 9-patch structures

View File

@@ -91,7 +91,7 @@ public:
private:
struct PatchDescription {
PatchDescription(): mPatch(NULL), mBitmapWidth(0), mBitmapHeight(0),
PatchDescription(): mPatch(nullptr), mBitmapWidth(0), mBitmapHeight(0),
mPixelWidth(0), mPixelHeight(0) {
}
@@ -146,7 +146,7 @@ private:
* to track available regions of memory in the VBO.
*/
struct BufferBlock {
BufferBlock(uint32_t offset, uint32_t size): offset(offset), size(size), next(NULL) {
BufferBlock(uint32_t offset, uint32_t size): offset(offset), size(size), next(nullptr) {
}
uint32_t offset;

View File

@@ -87,7 +87,7 @@ struct PathTexture: public Texture {
}
void clearTask() {
if (mTask != NULL) {
if (mTask != nullptr) {
mTask.clear();
}
}
@@ -165,7 +165,7 @@ public:
* Used as a callback when an entry is removed from the cache.
* Do not invoke directly.
*/
void operator()(PathDescription& path, PathTexture*& texture);
void operator()(PathDescription& path, PathTexture*& texture) override;
/**
* Clears the cache. This causes all textures to be deleted.
@@ -292,7 +292,7 @@ private:
PathProcessor(Caches& caches);
~PathProcessor() { }
virtual void onProcess(const sp<Task<SkBitmap*> >& task);
virtual void onProcess(const sp<Task<SkBitmap*> >& task) override;
private:
uint32_t mMaxTextureSize;

View File

@@ -255,7 +255,7 @@ enum DebugLevel {
static inline DebugLevel readDebugLevel() {
char property[PROPERTY_VALUE_MAX];
if (property_get(PROPERTY_DEBUG, property, NULL) > 0) {
if (property_get(PROPERTY_DEBUG, property, nullptr) > 0) {
return (DebugLevel) atoi(property);
}
return kDebugDisabled;

View File

@@ -248,7 +248,7 @@ public:
bottom = fmaxf(bottom, y);
}
void dump(const char* label = NULL) const {
void dump(const char* label = nullptr) const {
ALOGD("%s[l=%f t=%f r=%f b=%f]", label ? label : "Rect", left, top, right, bottom);
}

View File

@@ -78,11 +78,11 @@ public:
private:
struct RenderBufferEntry {
RenderBufferEntry():
mBuffer(NULL), mWidth(0), mHeight(0) {
mBuffer(nullptr), mWidth(0), mHeight(0) {
}
RenderBufferEntry(GLenum format, const uint32_t width, const uint32_t height):
mBuffer(NULL), mFormat(format), mWidth(width), mHeight(height) {
mBuffer(nullptr), mFormat(format), mWidth(width), mHeight(height) {
}
RenderBufferEntry(RenderBuffer* buffer):

View File

@@ -188,7 +188,7 @@ public:
if (matrix) {
mStaticMatrix = new SkMatrix(*matrix);
} else {
mStaticMatrix = NULL;
mStaticMatrix = nullptr;
}
return true;
}
@@ -203,7 +203,7 @@ public:
if (matrix) {
mAnimationMatrix = new SkMatrix(*matrix);
} else {
mAnimationMatrix = NULL;
mAnimationMatrix = nullptr;
}
return true;
}
@@ -571,7 +571,7 @@ public:
bool hasShadow() const {
return getZ() > 0.0f
&& getOutline().getPath() != NULL
&& getOutline().getPath() != nullptr
&& getOutline().getAlpha() != 0.0f;
}

View File

@@ -79,13 +79,13 @@ public:
// TODO: move to a method on android:Paint
static inline bool paintWillNotDrawText(const SkPaint& paint) {
return paint.getAlpha() == 0
&& paint.getLooper() == NULL
&& paint.getLooper() == nullptr
&& !paint.getColorFilter()
&& getXfermode(paint.getXfermode()) == SkXfermode::kSrcOver_Mode;
}
static bool isBlendedColorFilter(const SkColorFilter* filter) {
if (filter == NULL) {
if (filter == nullptr) {
return false;
}
return (filter->getFlags() & SkColorFilter::kAlphaUnchanged_Flag) == 0;

View File

@@ -54,7 +54,7 @@ public:
float getRadius() const { return mRadius; }
const SkPath* getPath() const {
if (!mShouldClip) return NULL;
if (!mShouldClip) return nullptr;
return &mPath;
}

View File

@@ -166,7 +166,7 @@ private:
sp<TaskProcessor<VertexBuffer*> > mProcessor;
LruCache<Description, Buffer*> mCache;
class BufferRemovedListener : public OnEntryRemoved<Description, Buffer*> {
void operator()(Description& description, Buffer*& buffer);
void operator()(Description& description, Buffer*& buffer) override;
};
BufferRemovedListener mBufferRemovedListener;
@@ -178,8 +178,8 @@ private:
// holds a pointer, and implicit strong ref to each shadow task of the frame
LruCache<ShadowDescription, Task<vertexBuffer_pair_t*>*> mShadowCache;
class BufferPairRemovedListener : public OnEntryRemoved<ShadowDescription, Task<vertexBuffer_pair_t*>*> {
void operator()(ShadowDescription& description, Task<vertexBuffer_pair_t*>*& bufferPairTask) {
bufferPairTask->decStrong(NULL);
void operator()(ShadowDescription& description, Task<vertexBuffer_pair_t*>*& bufferPairTask) override {
bufferPairTask->decStrong(nullptr);
}
};
BufferPairRemovedListener mBufferPairRemovedListener;

View File

@@ -34,8 +34,8 @@ class Caches;
class FontRenderer;
struct ShadowText {
ShadowText(): len(0), radius(0.0f), textSize(0.0f), typeface(NULL),
flags(0), italicStyle(0.0f), scaleX(0), text(NULL), positions(NULL) {
ShadowText(): len(0), radius(0.0f), textSize(0.0f), typeface(nullptr),
flags(0), italicStyle(0.0f), scaleX(0), text(nullptr), positions(nullptr) {
}
// len is the number of bytes in text
@@ -76,7 +76,7 @@ struct ShadowText {
uint32_t charCount = len / sizeof(char16_t);
str.setTo((const char16_t*) text, charCount);
text = str.string();
if (positions != NULL) {
if (positions != nullptr) {
positionsCopy.clear();
positionsCopy.appendArray(positions, charCount * 2);
positions = positionsCopy.array();
@@ -134,7 +134,7 @@ public:
* Used as a callback when an entry is removed from the cache.
* Do not invoke directly.
*/
void operator()(ShadowText& text, ShadowTexture*& texture);
void operator()(ShadowText& text, ShadowTexture*& texture) override;
ShadowTexture* get(const SkPaint* paint, const char* text, uint32_t len,
int numGlyphs, float radius, const float* positions);

View File

@@ -62,7 +62,7 @@ public:
* Used as a callback when an entry is removed from the cache.
* Do not invoke directly.
*/
void operator()(uint32_t&, Texture*& texture);
void operator()(uint32_t&, Texture*& texture) override;
/**
* Resets all Textures to not be marked as in use

View File

@@ -32,17 +32,17 @@ public:
};
VertexBuffer()
: mBuffer(0)
, mIndices(0)
: mBuffer(nullptr)
, mIndices(nullptr)
, mVertexCount(0)
, mIndexCount(0)
, mAllocatedVertexCount(0)
, mAllocatedIndexCount(0)
, mByteCount(0)
, mMode(kStandard)
, mReallocBuffer(0)
, mCleanupMethod(NULL)
, mCleanupIndexMethod(NULL)
, mReallocBuffer(nullptr)
, mCleanupMethod(nullptr)
, mCleanupIndexMethod(nullptr)
{}
~VertexBuffer() {

View File

@@ -54,7 +54,7 @@ struct CacheBlock {
CacheBlock* mPrev;
CacheBlock(uint16_t x, uint16_t y, uint16_t width, uint16_t height):
mX(x), mY(y), mWidth(width), mHeight(height), mNext(NULL), mPrev(NULL) {
mX(x), mY(y), mWidth(width), mHeight(height), mNext(nullptr), mPrev(nullptr) {
}
static CacheBlock* insertBlock(CacheBlock* head, CacheBlock* newBlock);
@@ -146,7 +146,7 @@ public:
}
uint16_t* indices() const {
return (uint16_t*) 0;
return (uint16_t*) nullptr;
}
void resetMesh() {

View File

@@ -38,7 +38,7 @@ namespace uirenderer {
// Font
///////////////////////////////////////////////////////////////////////////////
class CachedGlyphInfo;
struct CachedGlyphInfo;
class CacheTexture;
class FontRenderer;
@@ -120,7 +120,7 @@ private:
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);
void invalidateTextureCache(CacheTexture* cacheTexture = nullptr);
CachedGlyphInfo* cacheGlyph(const SkPaint* paint, glyph_t glyph, bool precaching);
void updateGlyphCache(const SkPaint* paint, const SkGlyph& skiaGlyph,

View File

@@ -84,8 +84,8 @@ private:
void exit();
private:
virtual status_t readyToRun();
virtual bool threadLoop();
virtual status_t readyToRun() override;
virtual bool threadLoop() override;
// Lock for the list of tasks
mutable Mutex mLock;

View File

@@ -47,7 +47,7 @@ public:
virtual void onProcess(const sp<Task<T> >& task) = 0;
private:
virtual void process(const sp<TaskBase>& task) {
virtual void process(const sp<TaskBase>& task) override {
sp<Task<T> > realTask = static_cast<Task<T>* >(task.get());
// This is the right way to do it but sp<> doesn't play nice
// sp<Task<T> > realTask = static_cast<sp<Task<T> > >(task);

View File

@@ -93,13 +93,13 @@ public:
}
protected:
virtual void do_construct(void* storage, size_t num) const;
virtual void do_destroy(void* storage, size_t num) const;
virtual void do_copy(void* dest, const void* from, size_t num) const;
virtual void do_splat(void* dest, const void* item, size_t num) const;
virtual void do_move_forward(void* dest, const void* from, size_t num) const;
virtual void do_move_backward(void* dest, const void* from, size_t num) const;
virtual int do_compare(const void* lhs, const void* rhs) const;
virtual void do_construct(void* storage, size_t num) const override;
virtual void do_destroy(void* storage, size_t num) const override;
virtual void do_copy(void* dest, const void* from, size_t num) const override;
virtual void do_splat(void* dest, const void* item, size_t num) const override;
virtual void do_move_forward(void* dest, const void* from, size_t num) const override;
virtual void do_move_backward(void* dest, const void* from, size_t num) const override;
virtual int do_compare(const void* lhs, const void* rhs) const override;
}; // class SortedList
///////////////////////////////////////////////////////////////////////////////

View File

@@ -41,7 +41,7 @@ protected:
virtual int do_compare(const void* lhs, const void* rhs) const = 0;
private:
ssize_t _indexOrderOf(const void* item, size_t* order = 0) const;
ssize_t _indexOrderOf(const void* item, size_t* order = nullptr) const;
// these are made private, because they can't be used on a SortedVector
// (they don't have an implementation either)