Lay groundwork for SkOpts.

This doesn't really do anything yet.  It's just the CPU detection code, skeleton new .cpp files, and a few little .gyp tweaks.

BUG=skia:4117

Review URL: https://codereview.chromium.org/1255193002
This commit is contained in:
mtklein 2015-07-27 10:52:33 -07:00 committed by Commit bot
parent 9a5d1ab54d
commit ce2c5055ce
10 changed files with 135 additions and 0 deletions

View File

@ -134,6 +134,7 @@
'<(skia_src_path)/core/SkMiniRecorder.cpp',
'<(skia_src_path)/core/SkMultiPictureDraw.cpp',
'<(skia_src_path)/core/SkNinePatchIter.cpp',
'<(skia_src_path)/core/SkOpts.cpp',
'<(skia_src_path)/core/SkPackBits.cpp',
'<(skia_src_path)/core/SkPaint.cpp',
'<(skia_src_path)/core/SkPaintPriv.cpp',

View File

@ -105,6 +105,7 @@
'type': 'static_library',
'standalone_static_library': 1,
'dependencies': [ 'core.gyp:*' ],
'include_dirs': [ '../src/core' ],
'sources': [ '<@(sse41_sources)' ],
'conditions': [
[ 'skia_os == "win"', {

View File

@ -34,6 +34,7 @@
'<(skia_src_path)/opts/SkTextureCompression_opts_neon.cpp',
'<(skia_src_path)/opts/SkUtils_opts_arm_neon.cpp',
'<(skia_src_path)/opts/SkXfermode_opts_arm_neon.cpp',
'<(skia_src_path)/opts/SkOpts_neon.cpp',
],
'arm64_sources': [
'<(skia_src_path)/opts/SkBitmapProcState_arm_neon.cpp',
@ -51,6 +52,7 @@
'<(skia_src_path)/opts/SkUtils_opts_none.cpp',
'<(skia_src_path)/opts/SkXfermode_opts_arm.cpp',
'<(skia_src_path)/opts/SkXfermode_opts_arm_neon.cpp',
'<(skia_src_path)/opts/SkOpts_neon.cpp',
],
'mips_dsp_sources': [
@ -74,12 +76,15 @@
'<(skia_src_path)/opts/SkUtils_opts_SSE2.cpp',
'<(skia_src_path)/opts/SkXfermode_opts_none.cpp',
'<(skia_src_path)/opts/opts_check_x86.cpp',
'<(skia_src_path)/opts/SkOpts_sse2.cpp',
],
'ssse3_sources': [
'<(skia_src_path)/opts/SkBitmapProcState_opts_SSSE3.cpp',
'<(skia_src_path)/opts/SkOpts_ssse3.cpp',
],
'sse41_sources': [
'<(skia_src_path)/opts/SkBlurImage_opts_SSE4.cpp',
'<(skia_src_path)/opts/SkBlitRow_opts_SSE4.cpp',
'<(skia_src_path)/opts/SkOpts_sse41.cpp',
],
}

View File

@ -14,6 +14,7 @@
#include "SkGeometry.h"
#include "SkMath.h"
#include "SkMatrix.h"
#include "SkOpts.h"
#include "SkPath.h"
#include "SkPathEffect.h"
#include "SkPixelRef.h"
@ -50,6 +51,7 @@ void SkGraphics::GetVersion(int32_t* major, int32_t* minor, int32_t* patch) {
#endif
void SkGraphics::Init() {
SkOpts::Init();
#ifdef SK_DEVELOPER
skRTConfRegistry().possiblyDumpFile();
skRTConfRegistry().validate();

48
src/core/SkOpts.cpp Normal file
View File

@ -0,0 +1,48 @@
/*
* Copyright 2015 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#include "SkOpts.h"
#if defined(SK_CPU_X86)
#if defined(SK_BUILD_FOR_WIN32)
#include <intrin.h>
static void cpuid(uint32_t abcd[4]) { __cpuid((int*)abcd, 1); }
#else
#include <cpuid.h>
static void cpuid(uint32_t abcd[4]) { __get_cpuid(1, abcd+0, abcd+1, abcd+2, abcd+3); }
#endif
#elif defined(SK_BUILD_FOR_ANDROID)
#include <cpu-features.h>
#endif
namespace SkOpts {
// (Define default function pointer values here...)
// Each Init_foo() is defined in src/opts/SkOpts_foo.cpp.
void Init_sse2();
void Init_ssse3();
void Init_sse41();
void Init_neon();
//TODO: _dsp2, _armv7, _armv8, _x86, _x86_64, _sse42, _avx, avx2, ... ?
void Init() {
#if defined(SK_CPU_X86)
uint32_t abcd[] = {0,0,0,0};
cpuid(abcd);
if (abcd[3] & (1<<26)) { Init_sse2(); }
if (abcd[2] & (1<< 9)) { Init_ssse3(); }
if (abcd[2] & (1<<19)) { Init_sse41(); }
#elif defined(SK_ARM_HAS_NEON)
Init_neon();
#elif defined(SK_BUILD_FOR_ANDROID)
if (android_getCpuFeatures() & ANDROID_CPU_ARM_FEATURE_NEON) { Init_neon(); }
#endif
}
}

22
src/core/SkOpts.h Normal file
View File

@ -0,0 +1,22 @@
/*
* Copyright 2015 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#ifndef SkOpts_DEFINED
#define SkOpts_DEFINED
#include "SkTypes.h"
namespace SkOpts {
// Called by SkGraphics::Init().
// It's not thread safe, but it's fine to call more than once.
// If Init() were somehow not called, that'd also be fine: you'll get portable fallbacks.
void Init();
// (Function pointers go here).
}
#endif//SkOpts_DEFINED

14
src/opts/SkOpts_neon.cpp Normal file
View File

@ -0,0 +1,14 @@
/*
* Copyright 2015 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#include "SkOpts.h"
namespace SkOpts {
void Init_neon() {
}
}

14
src/opts/SkOpts_sse2.cpp Normal file
View File

@ -0,0 +1,14 @@
/*
* Copyright 2015 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#include "SkOpts.h"
namespace SkOpts {
void Init_sse2() {
}
}

14
src/opts/SkOpts_sse41.cpp Normal file
View File

@ -0,0 +1,14 @@
/*
* Copyright 2015 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#include "SkOpts.h"
namespace SkOpts {
void Init_sse41() {
}
}

14
src/opts/SkOpts_ssse3.cpp Normal file
View File

@ -0,0 +1,14 @@
/*
* Copyright 2015 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#include "SkOpts.h"
namespace SkOpts {
void Init_ssse3() {
}
}