blob: 45f06c3afe0f77b8456b29ae88c479062e154339 [file] [log] [blame]
[email protected]3f7af102011-09-07 04:00:181// Copyright (c) 2011 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 "chrome/browser/ui/tabs/tab_resources.h"
6
7#include "base/logging.h"
8#include "ui/gfx/path.h"
9
10namespace {
11
12// Hit mask constants.
13const SkScalar kTabCapWidth = 15;
14const SkScalar kTabTopCurveWidth = 4;
15const SkScalar kTabBottomCurveWidth = 3;
16
17} // namespace
18
19// static
20void TabResources::GetHitTestMask(int width, int height, gfx::Path* path) {
21 DCHECK(path);
22
23 SkScalar h = SkIntToScalar(height);
24 SkScalar w = SkIntToScalar(width);
25
26 path->moveTo(0, h);
27
28 // Left end cap.
29 path->lineTo(kTabBottomCurveWidth, h - kTabBottomCurveWidth);
30 path->lineTo(kTabCapWidth - kTabTopCurveWidth, kTabTopCurveWidth);
31 path->lineTo(kTabCapWidth, 0);
32
33 // Connect to the right cap.
34 path->lineTo(w - kTabCapWidth, 0);
35
36 // Right end cap.
37 path->lineTo(w - kTabCapWidth + kTabTopCurveWidth, kTabTopCurveWidth);
38 path->lineTo(w - kTabBottomCurveWidth, h - kTabBottomCurveWidth);
39 path->lineTo(w, h);
40
41 // Close out the path.
42 path->lineTo(0, h);
43 path->close();
44}