1
    2
    3
    4
    5
    6
    7
    8
    9
   10
   11
   12
   13
   14
   15
   16
   17
   18
   19
   20
   21
   22
   23
   24
   25
   26
   27
   28
   29
   30
   31
   32
   33
   34
   35
   36
   37
   38
   39
   40
   41
   42

ash / public / cpp / annotator / annotator_tool.cc [blame]

// Copyright 2024 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "ash/public/cpp/annotator/annotator_tool.h"

#include <string>

#include "base/notreached.h"
#include "base/strings/string_number_conversions.h"

namespace ash {

std::string AnnotatorTool::GetColorHexString() const {
  uint8_t alpha = SkColorGetA(color);
  uint8_t red = SkColorGetR(color);
  uint8_t green = SkColorGetG(color);
  uint8_t blue = SkColorGetB(color);
  uint8_t bytes[] = {red, green, blue, alpha};
  return base::HexEncode(bytes);
}

std::string AnnotatorTool::GetToolString() const {
  switch (type) {
    case AnnotatorToolType::kMarker:
      return "marker";
    case AnnotatorToolType::kPen:
      return "pen";
    case AnnotatorToolType::kHighlighter:
      return "highlighter";
    case AnnotatorToolType::kEraser:
      return "eraser";
    case AnnotatorToolType::kToolNone:
      return "";
  }
}

bool AnnotatorTool::operator==(const AnnotatorTool& rhs) const {
  return rhs.color == color && rhs.size == size && rhs.type == type;
}

}  // namespace ash