Flutter Engine
The Flutter Engine
WritePixelsBench.cpp
Go to the documentation of this file.
1/*
2 * Copyright 2013 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
8#include "bench/Benchmark.h"
13
14// Time variants of write-pixels
15// [ colortype ][ alphatype ][ colorspace ]
16// Different combinations can trigger fast or slow paths in the impls
17//
19public:
21 : fColorType(ct)
22 , fAlphaType(at)
23 , fCS(cs)
24 {
25 fName.printf("writepix_%s_%s_%s",
26 at == kPremul_SkAlphaType ? "pm" : "um",
27 ct == kRGBA_8888_SkColorType ? "rgba" : "bgra",
28 cs ? "srgb" : "null");
29 }
30
31protected:
32 const char* onGetName() override {
33 return fName.c_str();
34 }
35
36 void onDraw(int loops, SkCanvas* canvas) override {
37 SkISize size = canvas->getBaseLayerSize();
38
39 SkImageInfo info = SkImageInfo::Make(size, fColorType, fAlphaType, fCS);
40 SkBitmap bmp;
41 bmp.allocPixels(info);
43
44 for (int loop = 0; loop < loops; ++loop) {
45 canvas->writePixels(info, bmp.getPixels(), bmp.rowBytes(), 0, 0);
46 }
47 }
48
49private:
50 SkColorType fColorType;
51 SkAlphaType fAlphaType;
53 SkString fName;
54
55 using INHERITED = Benchmark;
56};
57
58//////////////////////////////////////////////////////////////////////////////
59
64
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
Definition: DM.cpp:213
SkAlphaType
Definition: SkAlphaType.h:26
@ kPremul_SkAlphaType
pixel components are premultiplied by alpha
Definition: SkAlphaType.h:29
SkColorType
Definition: SkColorType.h:19
@ kBGRA_8888_SkColorType
pixel with 8 bits for blue, green, red, alpha; in 32-bit word
Definition: SkColorType.h:26
@ kRGBA_8888_SkColorType
pixel with 8 bits for red, green, blue, alpha; in 32-bit word
Definition: SkColorType.h:24
constexpr SkColor SK_ColorBLACK
Definition: SkColor.h:103
DEF_BENCH(return new WritePixelsBench(kRGBA_8888_SkColorType, kPremul_SkAlphaType, SkColorSpace::MakeSRGB());) DEF_BENCH(return new WritePixelsBench(kRGBA_8888_SkColorType
kUnpremul_SkAlphaType
void allocPixels(const SkImageInfo &info, size_t rowBytes)
Definition: SkBitmap.cpp:258
size_t rowBytes() const
Definition: SkBitmap.h:238
void * getPixels() const
Definition: SkBitmap.h:283
void eraseColor(SkColor4f) const
Definition: SkBitmap.cpp:442
bool writePixels(const SkImageInfo &info, const void *pixels, size_t rowBytes, int x, int y)
Definition: SkCanvas.cpp:399
virtual SkISize getBaseLayerSize() const
Definition: SkCanvas.cpp:369
static sk_sp< SkColorSpace > MakeSRGB()
void printf(const char format[],...) SK_PRINTF_LIKE(2
Definition: SkString.cpp:534
const char * c_str() const
Definition: SkString.h:133
void onDraw(int loops, SkCanvas *canvas) override
WritePixelsBench(SkColorType ct, SkAlphaType at, sk_sp< SkColorSpace > cs)
const char * onGetName() override
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: SkSize.h:16
static SkImageInfo Make(int width, int height, SkColorType ct, SkAlphaType at)