#ifdef UNSAFE_BUFFERS_BUILD
#pragma allow_unsafe_buffers
#endif
#include "components/qr_code_generator/bitmap_generator.h"
#include "base/metrics/histogram_macros.h"
#include "base/notreached.h"
#include "base/types/expected.h"
#include "build/build_config.h"
#include "components/qr_code_generator/dino_image.h"
#include "components/qr_code_generator/qr_code_generator.h"
#include "components/vector_icons/vector_icons.h"
#include "third_party/skia/include/core/SkBitmap.h"
#include "third_party/skia/include/core/SkCanvas.h"
#include "third_party/skia/include/core/SkPaint.h"
#include "ui/gfx/geometry/rect.h"
#include "ui/gfx/geometry/skia_conversions.h"
#include "ui/gfx/image/image_skia.h"
#include "ui/gfx/image/image_skia_operations.h"
#include "ui/gfx/image/image_skia_rep_default.h"
#include "ui/gfx/paint_vector_icon.h"
namespace qr_code_generator {
namespace {
static const int kModuleSizePixels = …;
static const int kDinoTileSizePixels = …;
static const int kLocatorSizeModules = …;
SkBitmap CreateDinoBitmap() { … }
void PaintCenterImage(SkCanvas* canvas,
const SkRect& canvas_bounds,
const int width_px,
const int height_px,
const int border_px,
const SkPaint& paint_background,
const SkBitmap& image);
#if !BUILDFLAG(IS_IOS)
void DrawPasskeyIcon(SkCanvas* canvas,
const SkRect& canvas_bounds,
const SkPaint& paint_foreground,
const SkPaint& paint_background) { … }
void DrawProductIcon(SkCanvas* canvas,
const SkRect& canvas_bounds,
const SkPaint& paint_foreground,
const SkPaint& paint_background) { … }
#endif
void DrawDino(SkCanvas* canvas,
const SkRect& canvas_bounds,
const int pixels_per_dino_tile,
const int dino_border_px,
const SkPaint& paint_foreground,
const SkPaint& paint_background) { … }
void PaintCenterImage(SkCanvas* canvas,
const SkRect& canvas_bounds,
const int width_px,
const int height_px,
const int border_px,
const SkPaint& paint_background,
const SkBitmap& image) { … }
void DrawLocators(SkCanvas* canvas,
const gfx::Size data_size,
const SkPaint& paint_foreground,
const SkPaint& paint_background,
LocatorStyle style,
int margin) { … }
int CalculateMargin(QuietZone quiet_zone) { … }
SkBitmap RenderBitmap(base::span<const uint8_t> data,
const gfx::Size data_size,
ModuleStyle module_style,
LocatorStyle locator_style,
CenterImage center_image,
QuietZone quiet_zone) { … }
}
const int kQuietZoneSizePixels = …;
base::expected<gfx::ImageSkia, Error> GenerateImage(
base::span<const uint8_t> data,
ModuleStyle module_style,
LocatorStyle locator_style,
CenterImage center_image,
QuietZone quiet_zone) { … }
base::expected<SkBitmap, Error> GenerateBitmap(base::span<const uint8_t> data,
ModuleStyle module_style,
LocatorStyle locator_style,
CenterImage center_image,
QuietZone quiet_zone) { … }
}