---
# System prepended metadata

title: Border Paint on ChromeOS
tags: [Chromium-Graphics, elkurin-daily-note]

---

# Border Paint on ChromeOS


We checked border painting on Linux in [Border Paint on Linux](/fnDxBlW0REaHpeMPP7a3UA). Let's check ChromeOS codes.

## OnPaint
OnPaint implementation in ChromeOS is [BrowserNonClientFrameViewChromeOS::OnPaint](https://source.chromium.org/chromium/chromium/src/+/main:chrome/browser/ui/views/frame/browser_non_client_frame_view_chromeos.cc;l=431;drc=7848977d02a3202da96ddc12f8416074ed920c2f).  


First, check [GetShouldPaint](https://source.chromium.org/chromium/chromium/src/+/main:chrome/browser/ui/views/frame/browser_non_client_frame_view_chromeos.cc;l=893;drc=977dc02c431b4979e34c7792bc3d646f649dacb4) and paint only if it should.  
If the window is floated, using WebUI tab strip, in immersive mode or in fullscreen mode, it skips painting. 

It proceeds with [FrameHeader::PaintHeader](https://source.chromium.org/chromium/chromium/src/+/main:chromeos/ui/frame/frame_header.cc;l=225;drc=977dc02c431b4979e34c7792bc3d646f649dacb4) -> [BrowserFrameHeaderChromeOS::DoPaintHeader](https://source.chromium.org/chromium/chromium/src/+/main:chrome/browser/ui/views/frame/browser_frame_header_chromeos.cc;l=142;drc=977dc02c431b4979e34c7792bc3d646f649dacb4).  

Here, there are two steps.  
First it paints images.  
[PaintFrameImages](https://source.chromium.org/chromium/chromium/src/+/main:chrome/browser/ui/views/frame/browser_frame_header_chromeos.cc;l=202;drc=977dc02c431b4979e34c7792bc3d646f649dacb4) is responsible for painting the frame images. 
There are two types of [mode_](https://source.chromium.org/chromium/chromium/src/+/main:chromeos/ui/frame/frame_header.h;l=253;drc=977dc02c431b4979e34c7792bc3d646f649dacb4) here: ACTIVE or INACTIVE. The frame image here can be obtained from `IDR_THEME_FRAME` and `IDR_THEME_FRAME_INACTIVE` resources via [BrowserNonClientFrameVivew::GetFrameImage](https://source.chromium.org/chromium/chromium/src/+/main:chrome/browser/ui/views/frame/browser_non_client_frame_view.cc;l=240;drc=977dc02c431b4979e34c7792bc3d646f649dacb4).  
Using this frame_image and frame_overlay_image, it calls [PaintFrameImagesInRoundRect](https://source.chromium.org/chromium/chromium/src/+/main:chrome/browser/ui/views/frame/browser_frame_header_chromeos.cc;l=102;drc=977dc02c431b4979e34c7792bc3d646f649dacb4) with the inset of 0 for x and [BrowserView::GetThemeOffsetFromBrowserView](https://source.chromium.org/chromium/chromium/src/+/main:chrome/browser/ui/views/frame/browser_view.cc;l=1595;drc=977dc02c431b4979e34c7792bc3d646f649dacb4) for y.  
It interacts with cc via gfx::Canvas.  
Tile image is painted by [TileImageInt](https://source.chromium.org/chromium/chromium/src/+/main:chrome/browser/ui/views/frame/browser_frame_header_chromeos.cc;l=71;drc=977dc02c431b4979e34c7792bc3d646f649dacb4) and overlay image is pained by [DrawImageInt](https://source.chromium.org/chromium/chromium/src/+/main:ui/gfx/canvas.cc;l=296;drc=977dc02c431b4979e34c7792bc3d646f649dacb4).

Second it paints title bar.  
It only draws text set in [`frame_text_override_`](https://source.chromium.org/chromium/chromium/src/+/main:chromeos/ui/frame/frame_header.h;l=258;drc=977dc02c431b4979e34c7792bc3d646f649dacb4) via [gfx::Canvas::DrawStringRectWithFlags](https://source.chromium.org/chromium/chromium/src/+/main:ui/gfx/canvas_skia.cc;l=158;drc=977dc02c431b4979e34c7792bc3d646f649dacb4).  
Inside DrawStringRect, it clips by text_bounds.


## Diff against Linux
In ChromeOS implementation, it only draws the header, but not other border.

In [Linux impl](https://source.chromium.org/chromium/chromium/src/+/main:ui/gtk/window_frame_provider_gtk.cc;l=285-322;drc=977dc02c431b4979e34c7792bc3d646f649dacb4), it draw image of 4 corners and 4 edges.  
On the other hand, ChromeOS implementation does not have a border decoration but instead only interacts with [FrameHeader](https://source.chromium.org/chromium/chromium/src/+/main:chrome/browser/ui/views/frame/browser_non_client_frame_view_chromeos.cc;l=436;drc=7848977d02a3202da96ddc12f8416074ed920c2f).
