• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2021 Google LLC.
2 #include "experimental/sktext/editor/Selection.h"
3 
4 using namespace skia::text;
5 
6 namespace skia {
7 namespace editor {
8 
select(TextRange range,SkRect rect)9 void Selection::select(TextRange range, SkRect rect) {
10     fGlyphBoxes.clear();
11     fTextRanges.clear();
12 
13     fGlyphBoxes.emplace_back(rect);
14     fTextRanges.emplace_back(range);
15 }
16 
paint(SkCanvas * canvas,SkPoint xy)17 void Selection::paint(SkCanvas* canvas, SkPoint xy) {
18     for (auto& box : fGlyphBoxes) {
19         canvas->drawRect(
20                 SkRect::MakeXYWH(box.fLeft + xy.fX, box.fTop + xy.fY, box.width(), box.height()),
21                 fBackground);
22     }
23 }
24 
25 } // namespace editor
26 } // namespace skia
27