Home | History | Annotate | Download | only in opts
      1 /*
      2  * Copyright 2009 The Android Open Source Project
      3  *
      4  * Use of this source code is governed by a BSD-style license that can be
      5  * found in the LICENSE file.
      6  */
      7 
      8 #include "SkBitmapProcState_opts_SSE2.h"
      9 #include "SkBitmapProcState_opts_SSSE3.h"
     10 #include "SkBlitMask.h"
     11 #include "SkBlitRow.h"
     12 #include "SkBlitRow_opts_SSE2.h"
     13 #include "SkCpu.h"
     14 
     15 
     16 /*
     17  *****************************************
     18  *********This file is deprecated*********
     19  *****************************************
     20  * New CPU-specific work should be done in
     21  * SkOpts framework. Run-time detection of
     22  * available instruction set extensions is
     23  * implemented in src/core/SkOpts.cpp file
     24  *****************************************
     25  */
     26 
     27 
     28 /* This file must *not* be compiled with -msse or any other optional SIMD
     29    extension, otherwise gcc may generate SIMD instructions even for scalar ops
     30    (and thus give an invalid instruction on Pentium3 on the code below).
     31    For example, only files named *_SSE2.cpp in this directory should be
     32    compiled with -msse2 or higher. */
     33 
     34 ////////////////////////////////////////////////////////////////////////////////
     35 
     36 void SkBitmapProcState::platformProcs() {
     37     /* Every optimization in the function requires at least SSE2 */
     38     if (!SkCpu::Supports(SkCpu::SSE2)) {
     39         return;
     40     }
     41     const bool ssse3 = SkCpu::Supports(SkCpu::SSSE3);
     42 
     43     /* Check fSampleProc32 */
     44     if (fSampleProc32 == S32_opaque_D32_filter_DX) {
     45         if (ssse3) {
     46             fSampleProc32 = S32_opaque_D32_filter_DX_SSSE3;
     47         } else {
     48             fSampleProc32 = S32_opaque_D32_filter_DX_SSE2;
     49         }
     50     } else if (fSampleProc32 == S32_alpha_D32_filter_DX) {
     51         if (ssse3) {
     52             fSampleProc32 = S32_alpha_D32_filter_DX_SSSE3;
     53         } else {
     54             fSampleProc32 = S32_alpha_D32_filter_DX_SSE2;
     55         }
     56     }
     57 
     58     /* Check fMatrixProc */
     59     if (fMatrixProc == ClampX_ClampY_filter_scale) {
     60         fMatrixProc = ClampX_ClampY_filter_scale_SSE2;
     61     } else if (fMatrixProc == ClampX_ClampY_nofilter_scale) {
     62         fMatrixProc = ClampX_ClampY_nofilter_scale_SSE2;
     63     }
     64 }
     65 
     66 ////////////////////////////////////////////////////////////////////////////////
     67 
     68 static const SkBlitRow::Proc32 platform_32_procs_SSE2[] = {
     69     nullptr,                               // S32_Opaque,
     70     S32_Blend_BlitRow32_SSE2,           // S32_Blend,
     71     nullptr,                            // Ported to SkOpts
     72     S32A_Blend_BlitRow32_SSE2,          // S32A_Blend,
     73 };
     74 
     75 SkBlitRow::Proc32 SkBlitRow::PlatformProcs32(unsigned flags) {
     76     if (SkCpu::Supports(SkCpu::SSE2)) {
     77         return platform_32_procs_SSE2[flags];
     78     } else {
     79         return nullptr;
     80     }
     81 }
     82 
     83 ////////////////////////////////////////////////////////////////////////////////
     84 
     85 SkBlitMask::BlitLCD16RowProc SkBlitMask::PlatformBlitRowProcs16(bool isOpaque) {
     86     if (SkCpu::Supports(SkCpu::SSE2)) {
     87         if (isOpaque) {
     88             return SkBlitLCD16OpaqueRow_SSE2;
     89         } else {
     90             return SkBlitLCD16Row_SSE2;
     91         }
     92     } else {
     93         return nullptr;
     94     }
     95 
     96 }
     97 
     98 SkBlitMask::RowProc SkBlitMask::PlatformRowProcs(SkColorType, SkMask::Format, RowFlags) {
     99     return nullptr;
    100 }
    101