diff options
author | 2016-11-06 21:07:02 -0800 | |
---|---|---|
committer | 2016-11-06 21:07:02 -0800 | |
commit | ad512797c9405f78b080a1d24cd98f465b9879dd (patch) | |
tree | cd8fd44d95e9762713057555eb484759dac74029 | |
parent | f98b730af08df5b7e6989d2fc1099fbbb07f26d9 (diff) |
Use perfect forwarding in createT of SkSmallAllocator.
This allows createT statements to be written in a clearer style.
BUG=skia:
GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2482683002
Review-Url: https://codereview.chromium.org/2482683002
-rw-r--r-- | src/core/SkSmallAllocator.h | 12 | ||||
-rw-r--r-- | src/utils/SkTextureCompressor_ASTC.cpp | 3 | ||||
-rw-r--r-- | src/utils/SkTextureCompressor_LATC.cpp | 3 | ||||
-rw-r--r-- | src/utils/SkTextureCompressor_R11EAC.cpp | 3 |
4 files changed, 9 insertions, 12 deletions
diff --git a/src/core/SkSmallAllocator.h b/src/core/SkSmallAllocator.h index 67afe75691..13b1505821 100644 --- a/src/core/SkSmallAllocator.h +++ b/src/core/SkSmallAllocator.h @@ -12,6 +12,7 @@ #include "SkTypes.h" #include <new> +#include <utility> /* * Template class for allocating small objects without additional heap memory @@ -56,12 +57,12 @@ public: * will be returned. */ template<typename T, typename... Args> - T* createT(const Args&... args) { + T* createT(Args&&... args) { void* buf = this->reserveT<T>(); if (nullptr == buf) { return nullptr; } - return new (buf) T(args...); + return new (buf) T(std::forward<Args>(args)...); } /* @@ -130,10 +131,9 @@ private: } alignas(16) char fStorage[kTotalBytes]; - // Number of bytes used so far. - size_t fStorageUsed; - uint32_t fNumObjects; - Rec fRecs[kMaxObjects]; + size_t fStorageUsed; // Number of bytes used so far. + uint32_t fNumObjects; + Rec fRecs[kMaxObjects]; }; #endif // SkSmallAllocator_DEFINED diff --git a/src/utils/SkTextureCompressor_ASTC.cpp b/src/utils/SkTextureCompressor_ASTC.cpp index 8a96b911ea..49b34de4f5 100644 --- a/src/utils/SkTextureCompressor_ASTC.cpp +++ b/src/utils/SkTextureCompressor_ASTC.cpp @@ -2073,8 +2073,7 @@ SkBlitter* CreateASTCBlitter(int width, int height, void* outputBuffer, } return allocator->createT< - SkTCompressedAlphaBlitter<12, 16, CompressorASTC>, int, int, void* > - (width, height, outputBuffer); + SkTCompressedAlphaBlitter<12, 16, CompressorASTC>>(width, height, outputBuffer); } void DecompressASTC(uint8_t* dst, int dstRowBytes, const uint8_t* src, diff --git a/src/utils/SkTextureCompressor_LATC.cpp b/src/utils/SkTextureCompressor_LATC.cpp index 50aaf0b275..d7cae4f37d 100644 --- a/src/utils/SkTextureCompressor_LATC.cpp +++ b/src/utils/SkTextureCompressor_LATC.cpp @@ -498,8 +498,7 @@ SkBlitter* CreateLATCBlitter(int width, int height, void* outputBuffer, sk_bzero(outputBuffer, width * height / 2); return allocator->createT< - SkTCompressedAlphaBlitter<4, 8, CompressorLATC>, int, int, void* > - (width, height, outputBuffer); + SkTCompressedAlphaBlitter<4, 8, CompressorLATC>>(width, height, outputBuffer); #elif COMPRESS_LATC_SLOW // TODO (krajcevski) return nullptr; diff --git a/src/utils/SkTextureCompressor_R11EAC.cpp b/src/utils/SkTextureCompressor_R11EAC.cpp index 5c298dda9a..5bdfead58c 100644 --- a/src/utils/SkTextureCompressor_R11EAC.cpp +++ b/src/utils/SkTextureCompressor_R11EAC.cpp @@ -653,8 +653,7 @@ SkBlitter* CreateR11EACBlitter(int width, int height, void* outputBuffer, } return allocator->createT< - SkTCompressedAlphaBlitter<4, 8, CompressorR11EAC>, int, int, void*> - (width, height, outputBuffer); + SkTCompressedAlphaBlitter<4, 8, CompressorR11EAC>>(width, height, outputBuffer); } void DecompressR11EAC(uint8_t* dst, int dstRowBytes, const uint8_t* src, int width, int height) { |