• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2020 The PDFium Authors
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6 
7 #include "core/fxge/cfx_drawutils.h"
8 
9 #include "core/fxge/cfx_fillrenderoptions.h"
10 #include "core/fxge/cfx_graphstatedata.h"
11 #include "core/fxge/cfx_path.h"
12 #include "core/fxge/cfx_renderdevice.h"
13 #include "third_party/base/check.h"
14 
15 // static
DrawFocusRect(CFX_RenderDevice * render_device,const CFX_Matrix & user_to_device,const CFX_FloatRect & view_bounding_box)16 void CFX_DrawUtils::DrawFocusRect(CFX_RenderDevice* render_device,
17                                   const CFX_Matrix& user_to_device,
18                                   const CFX_FloatRect& view_bounding_box) {
19   DCHECK(render_device);
20   CFX_Path path;
21   path.AppendPoint(CFX_PointF(view_bounding_box.left, view_bounding_box.top),
22                    CFX_Path::Point::Type::kMove);
23   path.AppendPoint(CFX_PointF(view_bounding_box.left, view_bounding_box.bottom),
24                    CFX_Path::Point::Type::kLine);
25   path.AppendPoint(
26       CFX_PointF(view_bounding_box.right, view_bounding_box.bottom),
27       CFX_Path::Point::Type::kLine);
28   path.AppendPoint(CFX_PointF(view_bounding_box.right, view_bounding_box.top),
29                    CFX_Path::Point::Type::kLine);
30   path.AppendPoint(CFX_PointF(view_bounding_box.left, view_bounding_box.top),
31                    CFX_Path::Point::Type::kLine);
32 
33   CFX_GraphStateData graph_state_data;
34   graph_state_data.m_DashArray = {1.0f};
35   graph_state_data.m_DashPhase = 0;
36   graph_state_data.m_LineWidth = 1.0f;
37 
38   render_device->DrawPath(path, &user_to_device, &graph_state_data, 0,
39                           ArgbEncode(255, 0, 0, 0),
40                           CFX_FillRenderOptions::EvenOddOptions());
41 }
42