Flutter Engine
The Flutter Engine
BitmapGetColorTest.cpp
Go to the documentation of this file.
1/*
2 * Copyright 2011 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
13#include "include/core/SkRect.h"
15#include "tests/Test.h"
16
17#include <array>
18#include <cstddef>
19#include <cstdint>
20
21DEF_TEST(GetColor, reporter) {
22 static const struct Rec {
24 SkColor fInColor;
25 SkColor fOutColor;
26 } gRec[] = {
27 // todo: add some tests that involve alpha, so we exercise the
28 // unpremultiply aspect of getColor()
29 { kAlpha_8_SkColorType, 0xFF000000, 0xFF000000 },
30 { kAlpha_8_SkColorType, 0, 0 },
31 { kRGB_565_SkColorType, 0xFF00FF00, 0xFF00FF00 },
32 { kRGB_565_SkColorType, 0xFFFF00FF, 0xFFFF00FF },
33 { kN32_SkColorType, 0xFFFFFFFF, 0xFFFFFFFF },
34 { kN32_SkColorType, 0, 0 },
35 { kN32_SkColorType, 0xFF224466, 0xFF224466 },
36 };
37
38 // specify an area that doesn't touch (0,0) and may extend beyond the
39 // bitmap bounds (to test that we catch that in eraseArea
40 const SkColor initColor = 0xFF0000FF;
41 const SkIRect area = { 1, 1, 3, 3 };
42
43 for (size_t i = 0; i < std::size(gRec); i++) {
46 SkBitmap bm;
47 uint32_t storage[4];
48 bm.installPixels(info, storage, info.minRowBytes());
49
50 bm.eraseColor(initColor);
51 bm.eraseArea(area, gRec[i].fInColor);
52
53 SkColor c = bm.getColor(1, 1);
54 REPORTER_ASSERT(reporter, c == gRec[i].fOutColor);
55 }
56}
DEF_TEST(GetColor, reporter)
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
Definition: DM.cpp:213
static const struct @223 gRec[]
reporter
Definition: FontMgrTest.cpp:39
SkColorType fColorType
@ kPremul_SkAlphaType
pixel components are premultiplied by alpha
Definition: SkAlphaType.h:29
SkColorType
Definition: SkColorType.h:19
@ kAlpha_8_SkColorType
pixel with alpha in 8-bit byte
Definition: SkColorType.h:21
@ kRGB_565_SkColorType
pixel with 5 bits red, 6 bits green, 5 bits blue, in 16-bit word
Definition: SkColorType.h:22
uint32_t SkColor
Definition: SkColor.h:37
#define REPORTER_ASSERT(r, cond,...)
Definition: Test.h:286
bool installPixels(const SkImageInfo &info, void *pixels, size_t rowBytes, void(*releaseProc)(void *addr, void *context), void *context)
Definition: SkBitmap.cpp:323
void eraseArea(const SkIRect &area, SkColor c) const
Definition: SkBitmap.h:854
SkColor getColor(int x, int y) const
Definition: SkBitmap.h:874
void eraseColor(SkColor4f) const
Definition: SkBitmap.cpp:442
it will be possible to load the file into Perfetto s trace viewer disable asset Prevents usage of any non test fonts unless they were explicitly Loaded via prefetched default font Indicates whether the embedding started a prefetch of the default font manager before creating the engine run In non interactive keep the shell running after the Dart script has completed enable serial On low power devices with low core running concurrent GC tasks on threads can cause them to contend with the UI thread which could potentially lead to jank This option turns off all concurrent GC activities domain network JSON encoded network policy per domain This overrides the DisallowInsecureConnections switch Embedder can specify whether to allow or disallow insecure connections at a domain level old gen heap size
Definition: switches.h:259
Definition: SkRect.h:32
static SkImageInfo Make(int width, int height, SkColorType ct, SkAlphaType at)