Flutter Engine
The Flutter Engine
SkSampler.cpp
Go to the documentation of this file.
1/*
2 * Copyright 2015 Google Inc.
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
9
15#include "src/core/SkMemset.h"
16
17#include <cstdint>
18#include <cstring>
19
20void SkSampler::Fill(const SkImageInfo& info, void* dst, size_t rowBytes,
21 SkCodec::ZeroInitialized zeroInit) {
22 SkASSERT(dst != nullptr);
23
24 if (SkCodec::kYes_ZeroInitialized == zeroInit) {
25 return;
26 }
27
28 const int width = info.width();
29 const int numRows = info.height();
30
31 // Use the proper memset routine to fill the remaining bytes
32 switch (info.colorType()) {
35 uint32_t* dstRow = (uint32_t*) dst;
36 for (int row = 0; row < numRows; row++) {
37 SkOpts::memset32(dstRow, 0, width);
38 dstRow = SkTAddOffset<uint32_t>(dstRow, rowBytes);
39 }
40 break;
41 }
43 uint16_t* dstRow = (uint16_t*) dst;
44 for (int row = 0; row < numRows; row++) {
45 SkOpts::memset16(dstRow, 0, width);
46 dstRow = SkTAddOffset<uint16_t>(dstRow, rowBytes);
47 }
48 break;
49 }
51 uint8_t* dstRow = (uint8_t*) dst;
52 for (int row = 0; row < numRows; row++) {
53 memset(dstRow, 0, width);
54 dstRow = SkTAddOffset<uint8_t>(dstRow, rowBytes);
55 }
56 break;
57 }
59 uint64_t* dstRow = (uint64_t*) dst;
60 for (int row = 0; row < numRows; row++) {
61 SkOpts::memset64(dstRow, 0, width);
62 dstRow = SkTAddOffset<uint64_t>(dstRow, rowBytes);
63 }
64 break;
65 }
66 default:
67 SkCodecPrintf("Error: Unsupported dst color type for fill(). Doing nothing.\n");
68 SkASSERT(false);
69 break;
70 }
71}
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
Definition: DM.cpp:213
#define SkASSERT(cond)
Definition: SkAssert.h:116
#define SkCodecPrintf(...)
Definition: SkCodecPriv.h:23
@ kBGRA_8888_SkColorType
pixel with 8 bits for blue, green, red, alpha; in 32-bit word
Definition: SkColorType.h:26
@ kRGBA_F16_SkColorType
pixel with half floats for red, green, blue, alpha;
Definition: SkColorType.h:38
@ kGray_8_SkColorType
pixel with grayscale level in 8-bit byte
Definition: SkColorType.h:35
@ kRGB_565_SkColorType
pixel with 5 bits red, 6 bits green, 5 bits blue, in 16-bit word
Definition: SkColorType.h:22
@ kRGBA_8888_SkColorType
pixel with 8 bits for red, green, blue, alpha; in 32-bit word
Definition: SkColorType.h:24
ZeroInitialized
Definition: SkCodec.h:303
@ kYes_ZeroInitialized
Definition: SkCodec.h:308
static void Fill(const SkImageInfo &info, void *dst, size_t rowBytes, SkCodec::ZeroInitialized zeroInit)
Definition: SkSampler.cpp:20
void(* memset64)(uint64_t[], uint64_t, int)
void(* memset16)(uint16_t[], uint16_t, int)
void(* memset32)(uint32_t[], uint32_t, int)
dst
Definition: cp.py:12
int32_t width