diff options
-rw-r--r-- | gyp/core.gypi | 2 | ||||
-rw-r--r-- | include/core/SkSwizzle.h | 19 | ||||
-rw-r--r-- | src/core/SkSwizzle.cpp | 16 | ||||
-rw-r--r-- | tests/SwizzlerTest.cpp | 10 |
4 files changed, 47 insertions, 0 deletions
diff --git a/gyp/core.gypi b/gyp/core.gypi index 7c873c926e..443029d49e 100644 --- a/gyp/core.gypi +++ b/gyp/core.gypi @@ -280,6 +280,7 @@ '<(skia_src_path)/core/SkStrokerPriv.cpp', '<(skia_src_path)/core/SkStrokerPriv.h', '<(skia_src_path)/core/SkSurfacePriv.h', + '<(skia_src_path)/core/SkSwizzle.cpp', '<(skia_src_path)/core/SkTaskGroup.cpp', '<(skia_src_path)/core/SkTaskGroup.h', '<(skia_src_path)/core/SkTDPQueue.h', @@ -393,6 +394,7 @@ '<(skia_include_path)/core/SkString.h', '<(skia_include_path)/core/SkStrokeRec.h', '<(skia_include_path)/core/SkSurface.h', + '<(skia_include_path)/core/SkSwizzle.h', '<(skia_include_path)/core/SkTRegistry.h', '<(skia_include_path)/core/SkTextBlob.h', '<(skia_include_path)/core/SkTime.h', diff --git a/include/core/SkSwizzle.h b/include/core/SkSwizzle.h new file mode 100644 index 0000000000..73e59e386a --- /dev/null +++ b/include/core/SkSwizzle.h @@ -0,0 +1,19 @@ +/* + * Copyright 2016 Google Inc. + * + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#ifndef SkSwizzle_DEFINED +#define SkSwizzle_DEFINED + +#include "SkTypes.h" + +/** + Swizzles byte order of |count| 32-bit pixels, swapping R and B. + (RGBA <-> BGRA) +*/ +void SkSwapRB(uint32_t* dest, const uint32_t* src, int count); + +#endif diff --git a/src/core/SkSwizzle.cpp b/src/core/SkSwizzle.cpp new file mode 100644 index 0000000000..9c1971817b --- /dev/null +++ b/src/core/SkSwizzle.cpp @@ -0,0 +1,16 @@ +/* + * Copyright 2016 Google Inc. + * + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include "SkSwizzle.h" + +#include "SkOpts.h" + +void SkSwapRB(uint32_t* dest, const uint32_t* src, int count) { + SkOpts::RGBA_to_BGRA(dest, src, count); +} + + diff --git a/tests/SwizzlerTest.cpp b/tests/SwizzlerTest.cpp index e1626d52f1..1b34669f97 100644 --- a/tests/SwizzlerTest.cpp +++ b/tests/SwizzlerTest.cpp @@ -5,6 +5,7 @@ * found in the LICENSE file. */ +#include "SkSwizzle.h" #include "SkSwizzler.h" #include "Test.h" #include "SkOpts.h" @@ -157,3 +158,12 @@ DEF_TEST(SwizzleOpts, r) { SkOpts::RGBA_to_bgrA(&dst, &src, 1); REPORTER_ASSERT(r, dst == 0xFA04ADCA); } + +DEF_TEST(PublicSwizzleOpts, r) { + uint32_t dst, src; + + // check a totally arbitrary color + src = 0xFACEB004; + SkSwapRB(&dst, &src, 1); + REPORTER_ASSERT(r, dst == 0xFA04B0CE); +} |