gfx/skia/trunk/src/opts/SkUtils_opts_SSE2.cpp

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.

     2 /*
     3  * Copyright 2009 The Android Open Source Project
     4  *
     5  * Use of this source code is governed by a BSD-style license that can be
     6  * found in the LICENSE file.
     7  */
    10 #include <emmintrin.h>
    11 #include "SkUtils_opts_SSE2.h"
    13 void sk_memset16_SSE2(uint16_t *dst, uint16_t value, int count)
    14 {
    15     SkASSERT(dst != NULL && count >= 0);
    17     // dst must be 2-byte aligned.
    18     SkASSERT((((size_t) dst) & 0x01) == 0);
    20     if (count >= 32) {
    21         while (((size_t)dst) & 0x0F) {
    22             *dst++ = value;
    23             --count;
    24         }
    25         __m128i *d = reinterpret_cast<__m128i*>(dst);
    26         __m128i value_wide = _mm_set1_epi16(value);
    27         while (count >= 32) {
    28             _mm_store_si128(d    , value_wide);
    29             _mm_store_si128(d + 1, value_wide);
    30             _mm_store_si128(d + 2, value_wide);
    31             _mm_store_si128(d + 3, value_wide);
    32             d += 4;
    33             count -= 32;
    34         }
    35         dst = reinterpret_cast<uint16_t*>(d);
    36     }
    37     while (count > 0) {
    38         *dst++ = value;
    39         --count;
    40     }
    41 }
    43 void sk_memset32_SSE2(uint32_t *dst, uint32_t value, int count)
    44 {
    45     SkASSERT(dst != NULL && count >= 0);
    47     // dst must be 4-byte aligned.
    48     SkASSERT((((size_t) dst) & 0x03) == 0);
    50     if (count >= 16) {
    51         while (((size_t)dst) & 0x0F) {
    52             *dst++ = value;
    53             --count;
    54         }
    55         __m128i *d = reinterpret_cast<__m128i*>(dst);
    56         __m128i value_wide = _mm_set1_epi32(value);
    57         while (count >= 16) {
    58             _mm_store_si128(d    , value_wide);
    59             _mm_store_si128(d + 1, value_wide);
    60             _mm_store_si128(d + 2, value_wide);
    61             _mm_store_si128(d + 3, value_wide);
    62             d += 4;
    63             count -= 16;
    64         }
    65         dst = reinterpret_cast<uint32_t*>(d);
    66     }
    67     while (count > 0) {
    68         *dst++ = value;
    69         --count;
    70     }
    71 }

mercurial