Publicly expose one accelerated swizzle.

SkOpts is intentionally internal, but we want to give Chrome access
to those pieces that would seriously benefit them.
GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1822363002

Review URL: https://codereview.chromium.org/1822363002
This commit is contained in:
tomhudson 2016-03-23 10:51:20 -07:00 committed by Commit bot
parent 7dbd45d2c7
commit 734351d255
4 changed files with 47 additions and 0 deletions

View File

@ -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',

19
include/core/SkSwizzle.h Normal file
View File

@ -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

16
src/core/SkSwizzle.cpp Normal file
View File

@ -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);
}

View File

@ -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);
}