blob: fe45fcd4a07b84b249e7c717714517d51aacb1f8 [file] [log] [blame]
ellyjones9412ffff2016-05-17 22:41:111// Copyright 2016 The Chromium Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#include "ui/gfx/scoped_canvas.h"
6
7#include "base/i18n/rtl.h"
8#include "ui/gfx/geometry/rect.h"
9
10namespace gfx {
11
Peter Kasting838fdda2019-06-25 21:41:1412ScopedCanvas::ScopedCanvas(gfx::Canvas* canvas) : canvas_(canvas) {
13 if (canvas_)
14 canvas_->Save();
15}
16
17ScopedCanvas::~ScopedCanvas() {
18 if (canvas_)
19 canvas_->Restore();
20}
21
22void ScopedCanvas::FlipIfRTL(int width) {
23 if (base::i18n::IsRTL()) {
24 canvas_->Translate(gfx::Vector2d(width, 0));
25 canvas_->Scale(-1, 1);
ellyjones9412ffff2016-05-17 22:41:1126 }
27}
28
29} // namespace gfx