From: bungeman Date: Tue, 9 Feb 2016 19:32:56 +0000 (-0800) Subject: Remove SkNEW_APPEND_TO_TARRAY. X-Git-Tag: accepted/tizen/5.0/unified/20181102.025319~129^2~2142 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=85dc359f749c349bbd8e0ba56825b9457f654237;p=platform%2Fupstream%2FlibSkiaSharp.git Remove SkNEW_APPEND_TO_TARRAY. The use of SkNEW_APPEND_TO_TARRAY is now better served by SkTArray::emplace_back(...) which should now be used instead. The existing users of SkNEW_APPEND_TO_TARRAY are converted and the code relating to SkNEW_APPEND_TO_TARRAY is removed. TBR=reed This only removes code. The file should also be made private. Review URL: https://codereview.chromium.org/1682083002 --- diff --git a/include/core/SkTArray.h b/include/core/SkTArray.h index 86c5eaa..5330e49 100644 --- a/include/core/SkTArray.h +++ b/include/core/SkTArray.h @@ -15,15 +15,12 @@ #include #include -template class SkTArray; -template void* operator new(size_t, SkTArray*, int); - /** When MEM_COPY is true T will be bit copied when moved. When MEM_COPY is false, T will be copy constructed / destructed. In all cases T will be default-initialized on allocation, and its destructor will be called from this object's destructor. */ -template class SkTArray { +template class SkTArray { public: /** * Creates an empty array with no initial storage @@ -464,8 +461,6 @@ private: } } - friend void* operator new(size_t, SkTArray*, int); - int fReserveCount; int fCount; int fAllocCount; @@ -476,29 +471,6 @@ private: }; }; -// Use the below macro (SkNEW_APPEND_TO_TARRAY) rather than calling this directly -template -void* operator new(size_t, SkTArray* array, int SkDEBUGCODE(atIndex)) { - // Currently, we only support adding to the end of the array. When the array class itself - // supports random insertion then this should be updated. - // SkASSERT(atIndex >= 0 && atIndex <= array->count()); - SkASSERT(atIndex == array->count()); - return array->push_back_raw(1); -} - -// Skia doesn't use C++ exceptions but it may be compiled with them enabled. Having an op delete -// to match the op new silences warnings about missing op delete when a constructor throws an -// exception. -template -void operator delete(void*, SkTArray* /*array*/, int /*atIndex*/) { - SK_ABORT("Invalid Operation"); -} - -// Constructs a new object as the last element of an SkTArray. -#define SkNEW_APPEND_TO_TARRAY(array_ptr, type_name, args) \ - (new ((array_ptr), (array_ptr)->count()) type_name args) - - /** * Subclass of SkTArray that contains a preallocated memory block for the array. */ diff --git a/src/gpu/GrPathProcessor.cpp b/src/gpu/GrPathProcessor.cpp index 6ecad59..405152c 100644 --- a/src/gpu/GrPathProcessor.cpp +++ b/src/gpu/GrPathProcessor.cpp @@ -72,8 +72,7 @@ public: &v).toIndex(); fInstalledTransforms[i][t].fType = varyingType; - SkNEW_APPEND_TO_TARRAY(&(*tout)[i], GrGLSLTransformedCoords, - (SkString(v.fsIn()), varyingType)); + (*tout)[i].emplace_back(SkString(v.fsIn()), varyingType); } } } diff --git a/src/gpu/gl/builders/GrGLProgramBuilder.cpp b/src/gpu/gl/builders/GrGLProgramBuilder.cpp index 52ef7b5..905fcde 100644 --- a/src/gpu/gl/builders/GrGLProgramBuilder.cpp +++ b/src/gpu/gl/builders/GrGLProgramBuilder.cpp @@ -92,8 +92,7 @@ void GrGLProgramBuilder::emitSamplers(const GrProcessor& processor, fUniformHandler.addUniform(GrGLSLUniformHandler::kFragment_Visibility, samplerType, kDefault_GrSLPrecision, name.c_str()); - SkNEW_APPEND_TO_TARRAY(outSamplers, GrGLSLTextureSampler, - (localSamplerUniforms[t], processor.textureAccess(t))); + outSamplers->emplace_back(localSamplerUniforms[t], processor.textureAccess(t)); if (kSamplerExternal_GrSLType == samplerType) { const char* externalFeatureString = this->glslCaps()->externalTextureExtensionString(); // We shouldn't ever create a GrGLTexture that requires external sampler type diff --git a/src/gpu/glsl/GrGLSLGeometryProcessor.cpp b/src/gpu/glsl/GrGLSLGeometryProcessor.cpp index a8bd8ac..967c18d 100644 --- a/src/gpu/glsl/GrGLSLGeometryProcessor.cpp +++ b/src/gpu/glsl/GrGLSLGeometryProcessor.cpp @@ -62,8 +62,7 @@ void GrGLSLGeometryProcessor::emitTransforms(GrGLSLVertexBuilder* vb, varyingHandler->addVarying(strVaryingName.c_str(), &v, precision); SkASSERT(kVec2f_GrSLType == varyingType || kVec3f_GrSLType == varyingType); - SkNEW_APPEND_TO_TARRAY(&(*tout)[i], GrGLSLTransformedCoords, - (SkString(v.fsIn()), varyingType)); + (*tout)[i].emplace_back(SkString(v.fsIn()), varyingType); // varying = matrix * coords (logically) if (kDevice_GrCoordSet == coordType) { @@ -117,9 +116,7 @@ void GrGLSLGeometryProcessor::emitTransforms(GrGLSLVertexBuilder* vb, varyingHandler->addVarying(strVaryingName.c_str(), &v, precision); vb->codeAppendf("%s = %s;", v.vsOut(), localCoords); - SkNEW_APPEND_TO_TARRAY(&(*tout)[i], - GrGLSLTransformedCoords, - (SkString(v.fsIn()), varyingType)); + (*tout)[i].emplace_back(SkString(v.fsIn()), varyingType); } } } diff --git a/tests/TextBlobCacheTest.cpp b/tests/TextBlobCacheTest.cpp index 6aa6c20..c2907fc 100644 --- a/tests/TextBlobCacheTest.cpp +++ b/tests/TextBlobCacheTest.cpp @@ -126,7 +126,7 @@ static void text_blob_cache_inner(skiatest::Reporter* reporter, GrContext* conte } } } - SkNEW_APPEND_TO_TARRAY(&blobs, TextBlobWrapper, (builder.build())); + blobs.emplace_back(builder.build()); } }