Flutter Engine
The Flutter Engine
Classes | Macros | Typedefs | Functions | Variables
Viewer.cpp File Reference
#include "tools/viewer/Viewer.h"
#include "bench/GpuTools.h"
#include "gm/gm.h"
#include "include/core/SkAlphaType.h"
#include "include/core/SkBitmap.h"
#include "include/core/SkBlendMode.h"
#include "include/core/SkCanvas.h"
#include "include/core/SkColor.h"
#include "include/core/SkColorPriv.h"
#include "include/core/SkColorType.h"
#include "include/core/SkData.h"
#include "include/core/SkFontTypes.h"
#include "include/core/SkGraphics.h"
#include "include/core/SkImage.h"
#include "include/core/SkImageInfo.h"
#include "include/core/SkPicture.h"
#include "include/core/SkPictureRecorder.h"
#include "include/core/SkRect.h"
#include "include/core/SkSamplingOptions.h"
#include "include/core/SkSerialProcs.h"
#include "include/core/SkStream.h"
#include "include/core/SkSurface.h"
#include "include/core/SkSurfaceProps.h"
#include "include/core/SkTextBlob.h"
#include "include/encode/SkPngEncoder.h"
#include "include/gpu/GrDirectContext.h"
#include "include/private/base/SkDebug.h"
#include "include/private/base/SkTPin.h"
#include "include/private/base/SkTo.h"
#include "include/utils/SkPaintFilterCanvas.h"
#include "src/base/SkBase64.h"
#include "src/base/SkTLazy.h"
#include "src/base/SkTSort.h"
#include "src/base/SkUTF.h"
#include "src/core/SkAutoPixmapStorage.h"
#include "src/core/SkLRUCache.h"
#include "src/core/SkMD5.h"
#include "src/core/SkOSFile.h"
#include "src/core/SkReadBuffer.h"
#include "src/core/SkScan.h"
#include "src/core/SkStringUtils.h"
#include "src/core/SkTaskGroup.h"
#include "src/core/SkTextBlobPriv.h"
#include "src/image/SkImage_Base.h"
#include "src/sksl/SkSLCompiler.h"
#include "src/sksl/SkSLString.h"
#include "src/text/GlyphRun.h"
#include "src/utils/SkJSONWriter.h"
#include "src/utils/SkOSPath.h"
#include "src/utils/SkShaderUtils.h"
#include "tools/CodecUtils.h"
#include "tools/DecodeUtils.h"
#include "tools/Resources.h"
#include "tools/RuntimeBlendUtils.h"
#include "tools/SkMetaData.h"
#include "tools/flags/CommandLineFlags.h"
#include "tools/flags/CommonFlags.h"
#include "tools/skui/InputState.h"
#include "tools/skui/Key.h"
#include "tools/skui/ModifierKey.h"
#include "tools/trace/EventTracingPriv.h"
#include "tools/viewer/BisectSlide.h"
#include "tools/viewer/GMSlide.h"
#include "tools/viewer/ImageSlide.h"
#include "tools/viewer/MSKPSlide.h"
#include "tools/viewer/SKPSlide.h"
#include "tools/viewer/SkSLDebuggerSlide.h"
#include "tools/viewer/SkSLSlide.h"
#include "tools/viewer/Slide.h"
#include "tools/viewer/SlideDir.h"
#include <algorithm>
#include <cfloat>
#include <chrono>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <initializer_list>
#include <map>
#include <memory>
#include <optional>
#include <ratio>
#include <regex>
#include <tuple>
#include <utility>
#include <vector>
#include "imgui.h"
#include "misc/cpp/imgui_stdlib.h"

Go to the source code of this file.

Classes

class  CapturingShaderErrorHandler
 
struct  NamedPrimaries
 
class  NullSlide
 
struct  SkPaintTitleUpdater
 
class  OveridePaintFilterCanvas
 

Macros

#define GL_BACKEND_STR
 
#define VK_BACKEND_STR
 
#define MTL_BACKEND_STR
 
#define D3D_BACKEND_STR
 
#define DAWN_BACKEND_STR
 
#define BACKENDS_STR_EVALUATOR(sw, gl, vk, mtl, d3d, dawn)   sw gl vk mtl d3d dawn
 
#define BACKENDS_STR
 
#define PATH_PREFIX   ""
 
#define MAX_ZOOM_LEVEL   8.0f
 
#define MIN_ZOOM_LEVEL   -8.0f
 

Typedefs

using OverrideFlag = SkSL::Compiler::OverrideFlag
 

Functions

static DEFINE_string (slide, "", "Start on this sample.")
 
static DEFINE_bool (list, false, "List samples?")
 
static DEFINE_string2 (backend, b, "sw", "Backend to use. Allowed values are " BACKENDS_STR ".")
 
static DEFINE_int (msaa, 1, "Number of subpixel samples. 0 for no HW antialiasing.")
 
static DEFINE_bool (dmsaa, false, "Use internal MSAA to render to non-MSAA surfaces?")
 
static DEFINE_string (bisect, "", "Path to a .skp or .svg file to bisect.")
 
static DEFINE_string2 (file, f, "", "Open a single file for viewing.")
 
static DEFINE_string2 (match, m, nullptr, "[~][^]substring[$] [...] of name to run.\n" "Multiple matches may be separated by spaces.\n" "~ causes a matching name to always be skipped\n" "^ requires the start of the name to match\n" "$ requires the end of the name to match\n" "^ and $ requires an exact match\n" "If a name does not match any list entry,\n" "it is skipped unless some list entry starts with ~")
 
static DEFINE_string (jpgs, PATH_PREFIX "jpgs", "Directory to read jpgs from.")
 
static DEFINE_string (jxls, PATH_PREFIX "jxls", "Directory to read jxls from.")
 
static DEFINE_string (skps, PATH_PREFIX "skps", "Directory to read skps from.")
 
static DEFINE_string (mskps, PATH_PREFIX "mskps", "Directory to read mskps from.")
 
static DEFINE_string (lotties, PATH_PREFIX "lotties", "Directory to read (Bodymovin) jsons from.")
 
static DEFINE_string (svgs, "", "Directory to read SVGs from, or a single SVG file.")
 
static DEFINE_string (rives, "", "Directory to read RIVs from, or a single .riv file.")
 
static DEFINE_int_2 (threads, j, -1, "Run threadsafe tests on a threadpool with this many extra threads, " "defaulting to one extra thread per core.")
 
static DEFINE_bool (redraw, false, "Toggle continuous redraw.")
 
static DEFINE_bool (offscreen, false, "Force rendering to an offscreen surface.")
 
static DEFINE_bool (stats, false, "Display stats overlay on startup.")
 
static DEFINE_bool (createProtected, false, "Create a protected native backend (e.g., in EGL).")
 
static bool is_graphite_backend_type (sk_app::Window::BackendType type)
 
const char * get_backend_string (sk_app::Window::BackendType type)
 
static sk_app::Window::BackendType get_backend_type (const char *str)
 
static bool primaries_equal (const SkColorSpacePrimaries &a, const SkColorSpacePrimaries &b)
 
static Window::BackendType backend_type_for_window (Window::BackendType backendType)
 
static sk_sp< SkDatadata_from_file (FILE *fp)
 
static sk_sp< SkDatabase64_string_to_data (const std::string &s)
 
static std::vector< sk_sp< SkImage > > find_data_uri_images (sk_sp< SkData > data)
 
static SkSerialProcs serial_procs_using_png ()
 
static void ImGui_Primaries (SkColorSpacePrimaries *primaries, SkPaint *gamutPaint)
 
static bool ImGui_DragLocation (SkPoint *pt)
 
static bool ImGui_DragQuad (SkPoint *pts)
 
static std::string build_sksl_highlight_shader ()
 
static std::string build_metal_highlight_shader (const std::string &inShader)
 
static std::string build_glsl_highlight_shader (const GrShaderCaps &shaderCaps)
 
template<typename OptionsFunc >
static void WriteStateObject (SkJSONWriter &writer, const char *name, const char *value, OptionsFunc &&optionsFunc)
 

Variables

static CapturingShaderErrorHandler gShaderErrorHandler
 
static std::map< GpuPathRenderers, std::string > gGaneshPathRendererNames
 
static SkColorSpacePrimaries gSrgbPrimaries
 
static SkColorSpacePrimaries gAdobePrimaries
 
static SkColorSpacePrimaries gP3Primaries
 
static SkColorSpacePrimaries gRec2020Primaries
 
struct NamedPrimaries gNamedPrimaries []
 
static const char kName [] = "name"
 
static const char kValue [] = "value"
 
static const char kOptions [] = "options"
 
static const char kSlideStateName [] = "Slide"
 
static const char kBackendStateName [] = "Backend"
 
static const char kMSAAStateName [] = "MSAA"
 
static const char kPathRendererStateName [] = "Path renderer"
 
static const char kSoftkeyStateName [] = "Softkey"
 
static const char kSoftkeyHint [] = "Please select a softkey"
 
static const char kON [] = "ON"
 
static const char kRefreshStateName [] = "Refresh"
 

Macro Definition Documentation

◆ BACKENDS_STR

#define BACKENDS_STR
Value:
#define D3D_BACKEND_STR
Definition: Viewer.cpp:200
#define GL_BACKEND_STR
Definition: Viewer.cpp:185
#define DAWN_BACKEND_STR
Definition: Viewer.cpp:205
#define MTL_BACKEND_STR
Definition: Viewer.cpp:195
#define VK_BACKEND_STR
Definition: Viewer.cpp:190
#define BACKENDS_STR_EVALUATOR(sw, gl, vk, mtl, d3d, dawn)
Definition: Viewer.cpp:207

Definition at line 208 of file Viewer.cpp.

◆ BACKENDS_STR_EVALUATOR

#define BACKENDS_STR_EVALUATOR (   sw,
  gl,
  vk,
  mtl,
  d3d,
  dawn 
)    sw gl vk mtl d3d dawn

Definition at line 207 of file Viewer.cpp.

◆ D3D_BACKEND_STR

#define D3D_BACKEND_STR

Definition at line 200 of file Viewer.cpp.

◆ DAWN_BACKEND_STR

#define DAWN_BACKEND_STR

Definition at line 205 of file Viewer.cpp.

◆ GL_BACKEND_STR

#define GL_BACKEND_STR

Definition at line 185 of file Viewer.cpp.

◆ MAX_ZOOM_LEVEL

#define MAX_ZOOM_LEVEL   8.0f

Definition at line 1395 of file Viewer.cpp.

◆ MIN_ZOOM_LEVEL

#define MIN_ZOOM_LEVEL   -8.0f

Definition at line 1396 of file Viewer.cpp.

◆ MTL_BACKEND_STR

#define MTL_BACKEND_STR

Definition at line 195 of file Viewer.cpp.

◆ PATH_PREFIX

#define PATH_PREFIX   ""

Definition at line 263 of file Viewer.cpp.

◆ VK_BACKEND_STR

#define VK_BACKEND_STR

Definition at line 190 of file Viewer.cpp.

Typedef Documentation

◆ OverrideFlag

Definition at line 171 of file Viewer.cpp.

Function Documentation

◆ backend_type_for_window()

static Window::BackendType backend_type_for_window ( Window::BackendType  backendType)
static

Definition at line 474 of file Viewer.cpp.

474 {
475 // In raster mode, we still use GL for the window.
476 // This lets us render the GUI faster (and correct).
477 return Window::kRaster_BackendType == backendType ? Window::kNativeGL_BackendType : backendType;
478}

◆ base64_string_to_data()

static sk_sp< SkData > base64_string_to_data ( const std::string &  s)
static

Definition at line 897 of file Viewer.cpp.

897 {
898 size_t dataLen;
899 if (SkBase64::Decode(s.c_str(), s.size(), nullptr, &dataLen) != SkBase64::kNoError) {
900 return nullptr;
901 }
902
903 sk_sp<SkData> decodedData = SkData::MakeUninitialized(dataLen);
904 void* rawData = decodedData->writable_data();
905 if (SkBase64::Decode(s.c_str(), s.size(), rawData, &dataLen) != SkBase64::kNoError) {
906 return nullptr;
907 }
908
909 return decodedData;
910}
static sk_sp< SkData > MakeUninitialized(size_t length)
Definition: SkData.cpp:116
void * writable_data()
Definition: SkData.h:52
struct MyStruct s
static Error Decode(const void *src, size_t srcLength, void *dst, size_t *dstLength)
Definition: SkBase64.cpp:37
@ kNoError
Definition: SkBase64.h:16

◆ build_glsl_highlight_shader()

static std::string build_glsl_highlight_shader ( const GrShaderCaps shaderCaps)
static

Definition at line 2104 of file Viewer.cpp.

2104 {
2105 const char* versionDecl = shaderCaps.fVersionDeclString;
2106 std::string highlight = versionDecl ? versionDecl : "";
2107 if (shaderCaps.fUsesPrecisionModifiers) {
2108 highlight.append("precision mediump float;\n");
2109 }
2110 SkSL::String::appendf(&highlight, "out vec4 sk_FragColor;\n"
2111 "void main() { sk_FragColor = vec4(1, 0, 1, 0.5); }");
2112 return highlight;
2113}
std::string void appendf(std::string *str, const char *fmt,...) SK_PRINTF_LIKE(2
Definition: SkSLString.cpp:92
const char * fVersionDeclString
Definition: SkSLUtil.h:153
bool fUsesPrecisionModifiers
Definition: SkSLUtil.h:95

◆ build_metal_highlight_shader()

static std::string build_metal_highlight_shader ( const std::string &  inShader)
static

Definition at line 2091 of file Viewer.cpp.

2091 {
2092 // Metal fragment shaders need a lot of non-trivial boilerplate that we don't want to recompute
2093 // here. So keep all shader code, but right before `return *_out;`, swap out the sk_FragColor.
2094 size_t pos = inShader.rfind("return _out;\n");
2095 if (pos == std::string::npos) {
2096 return inShader;
2097 }
2098
2099 std::string replacementShader = inShader;
2100 replacementShader.insert(pos, "_out.sk_FragColor = float4(1.0, 0.0, 1.0, 0.5); ");
2101 return replacementShader;
2102}
SkPoint pos

◆ build_sksl_highlight_shader()

static std::string build_sksl_highlight_shader ( )
static

Definition at line 2087 of file Viewer.cpp.

2087 {
2088 return std::string("void main() { sk_FragColor = half4(1, 0, 1, 0.5); }");
2089}

◆ data_from_file()

static sk_sp< SkData > data_from_file ( FILE *  fp)
static

Definition at line 888 of file Viewer.cpp.

888 {
890 char buf[4096];
891 while (size_t bytesRead = fread(buf, 1, 4096, fp)) {
892 stream.write(buf, bytesRead);
893 }
894 return stream.detachAsData();
895}
const uint32_t fp

◆ DEFINE_bool() [1/6]

static DEFINE_bool ( createProtected  ,
false  ,
"Create a protected native backend (e.g., in EGL)."   
)
static

◆ DEFINE_bool() [2/6]

static DEFINE_bool ( dmsaa  ,
false  ,
"Use internal MSAA to render to non-MSAA surfaces?"   
)
static

◆ DEFINE_bool() [3/6]

static DEFINE_bool ( list  ,
false  ,
"List samples?"   
)
static

◆ DEFINE_bool() [4/6]

static DEFINE_bool ( offscreen  ,
false  ,
"Force rendering to an offscreen surface."   
)
static

◆ DEFINE_bool() [5/6]

static DEFINE_bool ( redraw  ,
false  ,
"Toggle continuous redraw."   
)
static

◆ DEFINE_bool() [6/6]

static DEFINE_bool ( stats  ,
false  ,
"Display stats overlay on startup."   
)
static

◆ DEFINE_int()

static DEFINE_int ( msaa  ,
,
"Number of subpixel samples. 0 for no HW antialiasing."   
)
static

◆ DEFINE_int_2()

static DEFINE_int_2 ( threads  ,
,
1,
"Run threadsafe tests on a threadpool with this many extra  threads,
" "defaulting to one extra thread per core."   
)
static

◆ DEFINE_string() [1/9]

static DEFINE_string ( bisect  ,
""  ,
"Path to a .skp or .svg file to bisect."   
)
static

◆ DEFINE_string() [2/9]

static DEFINE_string ( jpgs  ,
PATH_PREFIX "jpgs"  ,
"Directory to read jpgs from."   
)
static

◆ DEFINE_string() [3/9]

static DEFINE_string ( jxls  ,
PATH_PREFIX "jxls"  ,
"Directory to read jxls from."   
)
static

◆ DEFINE_string() [4/9]

static DEFINE_string ( lotties  ,
PATH_PREFIX "lotties"  ,
"Directory to read (Bodymovin) jsons from."   
)
static

◆ DEFINE_string() [5/9]

static DEFINE_string ( mskps  ,
PATH_PREFIX "mskps"  ,
"Directory to read mskps from."   
)
static

◆ DEFINE_string() [6/9]

static DEFINE_string ( rives  ,
""  ,
"Directory to read RIVs  from,
or a single .riv file."   
)
static

◆ DEFINE_string() [7/9]

static DEFINE_string ( skps  ,
PATH_PREFIX "skps"  ,
"Directory to read skps from."   
)
static

◆ DEFINE_string() [8/9]

static DEFINE_string ( slide  ,
""  ,
"Start on this sample."   
)
static

◆ DEFINE_string() [9/9]

static DEFINE_string ( svgs  ,
""  ,
"Directory to read SVGs  from,
or a single SVG file."   
)
static

◆ DEFINE_string2() [1/3]

static DEFINE_string2 ( backend  ,
b  ,
"sw"  ,
"Backend to use. Allowed values are " BACKENDS_STR "."   
)
static

◆ DEFINE_string2() [2/3]

static DEFINE_string2 ( file  ,
,
""  ,
"Open a single file for viewing."   
)
static

◆ DEFINE_string2() [3/3]

static DEFINE_string2 ( match  ,
,
nullptr  ,
"substring of name to run.\n" "Multiple matches may be separated by spaces.\n" "~ causes a matching name to always be skipped\n" "^ requires the start of the name to match\n" "$ requires the end of the name to match\n" "^ and $ requires an exact match\n" "If a name does not match any list  entry[~][^][$][...],
\n" "it is skipped unless some list entry starts with ~"   
)
static

◆ find_data_uri_images()

static std::vector< sk_sp< SkImage > > find_data_uri_images ( sk_sp< SkData data)
static

Definition at line 912 of file Viewer.cpp.

912 {
913 std::string str(reinterpret_cast<const char*>(data->data()), data->size());
914 std::regex re("data:image/png;base64,([a-zA-Z0-9+/=]+)");
915 std::sregex_iterator images_begin(str.begin(), str.end(), re);
916 std::sregex_iterator images_end;
917 std::vector<sk_sp<SkImage>> images;
918
919 for (auto iter = images_begin; iter != images_end; ++iter) {
920 const std::smatch& match = *iter;
921 auto raw = base64_string_to_data(match[1].str());
922 if (!raw) {
923 continue;
924 }
925 auto image = SkImages::DeferredFromEncodedData(std::move(raw));
926 if (image) {
927 images.push_back(std::move(image));
928 }
929 }
930
931 return images;
932}
static sk_sp< SkData > base64_string_to_data(const std::string &s)
Definition: Viewer.cpp:897
std::array< MockImage, 3 > images
Definition: mock_vulkan.cc:41
SK_API sk_sp< SkImage > DeferredFromEncodedData(sk_sp< SkData > encoded, std::optional< SkAlphaType > alphaType=std::nullopt)
sk_sp< const SkImage > image
Definition: SkRecords.h:269
def match(bench, filt)
Definition: benchmark.py:23
std::shared_ptr< const fml::Mapping > data
Definition: texture_gles.cc:63

◆ get_backend_string()

const char * get_backend_string ( sk_app::Window::BackendType  type)

Definition at line 355 of file Viewer.cpp.

355 {
356 switch (type) {
357 case sk_app::Window::kNativeGL_BackendType: return "OpenGL";
358#if SK_ANGLE && (defined(SK_BUILD_FOR_WIN) || defined(SK_BUILD_FOR_MAC))
359 case sk_app::Window::kANGLE_BackendType: return "ANGLE";
360#endif
361#ifdef SK_DAWN
362#if defined(SK_GRAPHITE)
363 case sk_app::Window::kGraphiteDawn_BackendType: return "Dawn (Graphite)";
364#endif
365#endif
366#ifdef SK_VULKAN
367 case sk_app::Window::kVulkan_BackendType: return "Vulkan";
368#if defined(SK_GRAPHITE)
369 case sk_app::Window::kGraphiteVulkan_BackendType: return "Vulkan (Graphite)";
370#endif
371#endif
372#ifdef SK_METAL
373 case sk_app::Window::kMetal_BackendType: return "Metal";
374#if defined(SK_GRAPHITE)
375 case sk_app::Window::kGraphiteMetal_BackendType: return "Metal (Graphite)";
376#endif
377#endif
378#ifdef SK_DIRECT3D
379 case sk_app::Window::kDirect3D_BackendType: return "Direct3D";
380#endif
381 case sk_app::Window::kRaster_BackendType: return "Raster";
382 }
383 SkASSERT(false);
384 return nullptr;
385}
#define SkASSERT(cond)
Definition: SkAssert.h:116
GLenum type
@ kRaster_BackendType
Definition: Window.h:90

◆ get_backend_type()

static sk_app::Window::BackendType get_backend_type ( const char *  str)
static

Definition at line 387 of file Viewer.cpp.

387 {
388#ifdef SK_DAWN
389#if defined(SK_GRAPHITE)
390 if (0 == strcmp(str, "grdawn")) {
391 return sk_app::Window::kGraphiteDawn_BackendType;
392 } else
393#endif
394#endif
395#ifdef SK_VULKAN
396 if (0 == strcmp(str, "vk")) {
397 return sk_app::Window::kVulkan_BackendType;
398 } else
399#if defined(SK_GRAPHITE)
400 if (0 == strcmp(str, "grvk")) {
401 return sk_app::Window::kGraphiteVulkan_BackendType;
402 } else
403#endif
404#endif
405#if SK_ANGLE && (defined(SK_BUILD_FOR_WIN) || defined(SK_BUILD_FOR_MAC))
406 if (0 == strcmp(str, "angle")) {
407 return sk_app::Window::kANGLE_BackendType;
408 } else
409#endif
410#ifdef SK_METAL
411 if (0 == strcmp(str, "mtl")) {
412 return sk_app::Window::kMetal_BackendType;
413 } else
414#if defined(SK_GRAPHITE)
415 if (0 == strcmp(str, "grmtl")) {
416 return sk_app::Window::kGraphiteMetal_BackendType;
417 } else
418#endif
419#endif
420#ifdef SK_DIRECT3D
421 if (0 == strcmp(str, "d3d")) {
422 return sk_app::Window::kDirect3D_BackendType;
423 } else
424#endif
425
426 if (0 == strcmp(str, "gl")) {
427 return sk_app::Window::kNativeGL_BackendType;
428 } else if (0 == strcmp(str, "sw")) {
430 } else {
431 SkDebugf("Unknown backend type, %s, defaulting to sw.", str);
433 }
434}
void SK_SPI SkDebugf(const char format[],...) SK_PRINTF_LIKE(1

◆ ImGui_DragLocation()

static bool ImGui_DragLocation ( SkPoint pt)
static

Definition at line 2064 of file Viewer.cpp.

2064 {
2065 ImGui::DragCanvas dc(pt);
2066 dc.fillColor(IM_COL32(0, 0, 0, 128));
2067 dc.dragPoint(pt);
2068 return dc.fDragging;
2069}

◆ ImGui_DragQuad()

static bool ImGui_DragQuad ( SkPoint pts)
static

Definition at line 2071 of file Viewer.cpp.

2071 {
2072 ImGui::DragCanvas dc(pts);
2073 dc.fillColor(IM_COL32(0, 0, 0, 128));
2074
2075 for (int i = 0; i < 4; ++i) {
2076 dc.dragPoint(pts + i);
2077 }
2078
2079 dc.fDrawList->AddLine(dc.fScreenPoints[0], dc.fScreenPoints[1], 0xFFFFFFFF);
2080 dc.fDrawList->AddLine(dc.fScreenPoints[1], dc.fScreenPoints[3], 0xFFFFFFFF);
2081 dc.fDrawList->AddLine(dc.fScreenPoints[3], dc.fScreenPoints[2], 0xFFFFFFFF);
2082 dc.fDrawList->AddLine(dc.fScreenPoints[2], dc.fScreenPoints[0], 0xFFFFFFFF);
2083
2084 return dc.fDragging;
2085}

◆ ImGui_Primaries()

static void ImGui_Primaries ( SkColorSpacePrimaries primaries,
SkPaint gamutPaint 
)
static

Definition at line 2046 of file Viewer.cpp.

2046 {
2047 // The gamut image covers a (0.8 x 0.9) shaped region
2048 ImGui::DragCanvas dc(primaries, { 0.0f, 0.9f }, { 0.8f, 0.0f });
2049
2050 // Background image. Only draw a subset of the image, to avoid the regions less than zero.
2051 // Simplifes re-mapping math, clipping behavior, and increases resolution in the useful area.
2052 // Magic numbers are pixel locations of the origin and upper-right corner.
2053 dc.fDrawList->AddImage(gamutPaint, dc.fPos,
2054 ImVec2(dc.fPos.x + dc.fSize.x, dc.fPos.y + dc.fSize.y),
2055 ImVec2(242, 61), ImVec2(1897, 1922));
2056
2057 dc.dragPoint((SkPoint*)(&primaries->fRX), true, 0xFF000040);
2058 dc.dragPoint((SkPoint*)(&primaries->fGX), true, 0xFF004000);
2059 dc.dragPoint((SkPoint*)(&primaries->fBX), true, 0xFF400000);
2060 dc.dragPoint((SkPoint*)(&primaries->fWX), true);
2061 dc.fDrawList->AddPolyline(dc.fScreenPoints.begin(), 3, 0xFFFFFFFF, true, 1.5f);
2062}
ImDrawList * fDrawList
Definition: ImGuiLayer.h:114

◆ is_graphite_backend_type()

static bool is_graphite_backend_type ( sk_app::Window::BackendType  type)
static

Definition at line 291 of file Viewer.cpp.

291 {
292#if defined(SK_GRAPHITE)
293 switch (type) {
294#ifdef SK_DAWN
295 case sk_app::Window::kGraphiteDawn_BackendType:
296#endif
297#ifdef SK_METAL
298 case sk_app::Window::kGraphiteMetal_BackendType:
299#endif
300#ifdef SK_VULKAN
301 case sk_app::Window::kGraphiteVulkan_BackendType:
302#endif
303 return true;
304 default:
305 break;
306 }
307#endif
308 return false;
309}

◆ primaries_equal()

static bool primaries_equal ( const SkColorSpacePrimaries a,
const SkColorSpacePrimaries b 
)
static

Definition at line 470 of file Viewer.cpp.

470 {
471 return memcmp(&a, &b, sizeof(SkColorSpacePrimaries)) == 0;
472}
static bool b
struct MyStruct a[10]

◆ serial_procs_using_png()

static SkSerialProcs serial_procs_using_png ( )
static

Definition at line 1688 of file Viewer.cpp.

1688 {
1689 SkSerialProcs sProcs;
1690 sProcs.fImageProc = [](SkImage* img, void*) -> sk_sp<SkData> {
1691 return SkPngEncoder::Encode(as_IB(img)->directContext(), img, SkPngEncoder::Options{});
1692 };
1693 return sProcs;
1694}
static SkImage_Base * as_IB(SkImage *image)
Definition: SkImage_Base.h:201
SK_API bool Encode(SkWStream *dst, const SkPixmap &src, const Options &options)
SkSerialImageProc fImageProc
Definition: SkSerialProcs.h:90

◆ WriteStateObject()

template<typename OptionsFunc >
static void WriteStateObject ( SkJSONWriter writer,
const char *  name,
const char *  value,
OptionsFunc &&  optionsFunc 
)
static

Definition at line 3178 of file Viewer.cpp.

3179 {
3180 writer.beginObject();
3181 {
3182 writer.appendCString(kName , name);
3183 writer.appendCString(kValue, value);
3184
3185 writer.beginArray(kOptions);
3186 {
3187 optionsFunc(writer);
3188 }
3189 writer.endArray();
3190 }
3191 writer.endObject();
3192}
static const char kName[]
Definition: Viewer.cpp:486
static const char kValue[]
Definition: Viewer.cpp:487
static const char kOptions[]
Definition: Viewer.cpp:488
void beginArray(const char *name=nullptr, bool multiline=true)
Definition: SkJSONWriter.h:146
void beginObject(const char *name=nullptr, bool multiline=true)
Definition: SkJSONWriter.h:114
void endObject()
Definition: SkJSONWriter.h:126
void appendCString(const char *value)
Definition: SkJSONWriter.h:224
void endArray()
Definition: SkJSONWriter.h:158
uint8_t value
DEF_SWITCHES_START aot vmservice shared library name
Definition: switches.h:32

Variable Documentation

◆ gAdobePrimaries

SkColorSpacePrimaries gAdobePrimaries
static
Initial value:
= {
0.64f, 0.33f,
0.21f, 0.71f,
0.15f, 0.06f,
0.3127f, 0.3290f }

Definition at line 442 of file Viewer.cpp.

◆ gGaneshPathRendererNames

std::map<GpuPathRenderers, std::string> gGaneshPathRendererNames
static

Definition at line 173 of file Viewer.cpp.

◆ gNamedPrimaries

struct NamedPrimaries gNamedPrimaries[]
Initial value:
= {
{ "sRGB", &gSrgbPrimaries },
{ "AdobeRGB", &gAdobePrimaries },
{ "P3", &gP3Primaries },
{ "Rec. 2020", &gRec2020Primaries },
}
static SkColorSpacePrimaries gSrgbPrimaries
Definition: Viewer.cpp:436
static SkColorSpacePrimaries gAdobePrimaries
Definition: Viewer.cpp:442
static SkColorSpacePrimaries gRec2020Primaries
Definition: Viewer.cpp:454
static SkColorSpacePrimaries gP3Primaries
Definition: Viewer.cpp:448

◆ gP3Primaries

SkColorSpacePrimaries gP3Primaries
static
Initial value:
= {
0.680f, 0.320f,
0.265f, 0.690f,
0.150f, 0.060f,
0.3127f, 0.3290f }

Definition at line 448 of file Viewer.cpp.

◆ gRec2020Primaries

SkColorSpacePrimaries gRec2020Primaries
static
Initial value:
= {
0.708f, 0.292f,
0.170f, 0.797f,
0.131f, 0.046f,
0.3127f, 0.3290f }

Definition at line 454 of file Viewer.cpp.

◆ gShaderErrorHandler

CapturingShaderErrorHandler gShaderErrorHandler
static

Definition at line 165 of file Viewer.cpp.

◆ gSrgbPrimaries

SkColorSpacePrimaries gSrgbPrimaries
static
Initial value:
= {
0.64f, 0.33f,
0.30f, 0.60f,
0.15f, 0.06f,
0.3127f, 0.3290f }

Definition at line 436 of file Viewer.cpp.

◆ kBackendStateName

const char kBackendStateName[] = "Backend"
static

Definition at line 490 of file Viewer.cpp.

◆ kMSAAStateName

const char kMSAAStateName[] = "MSAA"
static

Definition at line 491 of file Viewer.cpp.

◆ kName

const char kName[] = "name"
static

Definition at line 486 of file Viewer.cpp.

◆ kON

const char kON[] = "ON"
static

Definition at line 495 of file Viewer.cpp.

◆ kOptions

const char kOptions[] = "options"
static

Definition at line 488 of file Viewer.cpp.

◆ kPathRendererStateName

const char kPathRendererStateName[] = "Path renderer"
static

Definition at line 492 of file Viewer.cpp.

◆ kRefreshStateName

const char kRefreshStateName[] = "Refresh"
static

Definition at line 496 of file Viewer.cpp.

◆ kSlideStateName

const char kSlideStateName[] = "Slide"
static

Definition at line 489 of file Viewer.cpp.

◆ kSoftkeyHint

const char kSoftkeyHint[] = "Please select a softkey"
static

Definition at line 494 of file Viewer.cpp.

◆ kSoftkeyStateName

const char kSoftkeyStateName[] = "Softkey"
static

Definition at line 493 of file Viewer.cpp.

◆ kValue

const char kValue[] = "value"
static

Definition at line 487 of file Viewer.cpp.