gfx/skia/trunk/src/opts/SkMorphology_opts_neon.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.

michael@0 1 /*
michael@0 2 * Copyright 2013 The Android Open Source Project
michael@0 3 *
michael@0 4 * Use of this source code is governed by a BSD-style license that can be
michael@0 5 * found in the LICENSE file.
michael@0 6 */
michael@0 7
michael@0 8
michael@0 9 #include "SkColorPriv.h"
michael@0 10 #include "SkMorphology_opts.h"
michael@0 11 #include "SkMorphology_opts_neon.h"
michael@0 12
michael@0 13 #include <arm_neon.h>
michael@0 14
michael@0 15 /* neon version of dilateX, dilateY, erodeX, erodeY.
michael@0 16 * portable versions are in src/effects/SkMorphologyImageFilter.cpp.
michael@0 17 */
michael@0 18
michael@0 19 enum MorphType {
michael@0 20 kDilate, kErode
michael@0 21 };
michael@0 22
michael@0 23 enum MorphDirection {
michael@0 24 kX, kY
michael@0 25 };
michael@0 26
michael@0 27 template<MorphType type, MorphDirection direction>
michael@0 28 static void SkMorph_neon(const SkPMColor* src, SkPMColor* dst, int radius,
michael@0 29 int width, int height, int srcStride, int dstStride)
michael@0 30 {
michael@0 31 const int srcStrideX = direction == kX ? 1 : srcStride;
michael@0 32 const int dstStrideX = direction == kX ? 1 : dstStride;
michael@0 33 const int srcStrideY = direction == kX ? srcStride : 1;
michael@0 34 const int dstStrideY = direction == kX ? dstStride : 1;
michael@0 35 radius = SkMin32(radius, width - 1);
michael@0 36 const SkPMColor* upperSrc = src + radius * srcStrideX;
michael@0 37 for (int x = 0; x < width; ++x) {
michael@0 38 const SkPMColor* lp = src;
michael@0 39 const SkPMColor* up = upperSrc;
michael@0 40 SkPMColor* dptr = dst;
michael@0 41 for (int y = 0; y < height; ++y) {
michael@0 42 uint8x8_t max = vdup_n_u8(type == kDilate ? 0 : 255);
michael@0 43 for (const SkPMColor* p = lp; p <= up; p += srcStrideX) {
michael@0 44 uint8x8_t src_pixel = vreinterpret_u8_u32(vdup_n_u32(*p));
michael@0 45 max = type == kDilate ? vmax_u8(src_pixel, max) : vmin_u8(src_pixel, max);
michael@0 46 }
michael@0 47 *dptr = vget_lane_u32(vreinterpret_u32_u8(max), 0);
michael@0 48 dptr += dstStrideY;
michael@0 49 lp += srcStrideY;
michael@0 50 up += srcStrideY;
michael@0 51 }
michael@0 52 if (x >= radius) src += srcStrideX;
michael@0 53 if (x + radius < width - 1) upperSrc += srcStrideX;
michael@0 54 dst += dstStrideX;
michael@0 55 }
michael@0 56 }
michael@0 57
michael@0 58 void SkDilateX_neon(const SkPMColor* src, SkPMColor* dst, int radius,
michael@0 59 int width, int height, int srcStride, int dstStride)
michael@0 60 {
michael@0 61 SkMorph_neon<kDilate, kX>(src, dst, radius, width, height, srcStride, dstStride);
michael@0 62 }
michael@0 63
michael@0 64 void SkErodeX_neon(const SkPMColor* src, SkPMColor* dst, int radius,
michael@0 65 int width, int height, int srcStride, int dstStride)
michael@0 66 {
michael@0 67 SkMorph_neon<kErode, kX>(src, dst, radius, width, height, srcStride, dstStride);
michael@0 68 }
michael@0 69
michael@0 70 void SkDilateY_neon(const SkPMColor* src, SkPMColor* dst, int radius,
michael@0 71 int width, int height, int srcStride, int dstStride)
michael@0 72 {
michael@0 73 SkMorph_neon<kDilate, kY>(src, dst, radius, width, height, srcStride, dstStride);
michael@0 74 }
michael@0 75
michael@0 76 void SkErodeY_neon(const SkPMColor* src, SkPMColor* dst, int radius,
michael@0 77 int width, int height, int srcStride, int dstStride)
michael@0 78 {
michael@0 79 SkMorph_neon<kErode, kY>(src, dst, radius, width, height, srcStride, dstStride);
michael@0 80 }

mercurial