Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(379)

Side by Side Diff: ui/base/cocoa/three_part_image.h

Issue 918533005: Mac: Optimize TabView drawing. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix for rsesek Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2015 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 #ifndef UI_BASE_COCOA_THREE_PART_IMAGE_H
6 #define UI_BASE_COCOA_THREE_PART_IMAGE_H
7
8 #import <Cocoa/Cocoa.h>
9
10 #include "base/mac/scoped_nsobject.h"
11 #include "ui/base/ui_base_export.h"
12
13 namespace ui {
14
15 // A wrapper around NSDrawThreePartImage that caches the images.
16 // The middle image is optional.
17 // Vertical orientation is not currently supported.
18 class UI_BASE_EXPORT ThreePartImage {
19 public:
20 // |left_id|, |middle_id|, and |right_id| are ResourceBundle image
21 // identifiers. Specify 0 for |middle_id| if there is no middle image.
22 ThreePartImage(int left_id, int middle_id, int right_id);
23 ~ThreePartImage();
24
25 // Returns the image rects if drawn in |bounds|.
26 NSRect GetLeftRect(NSRect bounds) const;
27 NSRect GetMiddleRect(NSRect bounds) const;
28 NSRect GetRightRect(NSRect bounds) const;
29
30 // Draws the three part image inside |rect|.
31 void DrawInRect(NSRect rect, NSCompositingOperation op, CGFloat alpha) const;
32
33 // Returns YES if |point| is in a non-transparent part of the images.
34 // Returns YES if |point| is inside the middle rect and there is no middle
35 // image.
36 BOOL HitTest(NSPoint point, NSRect bounds) const;
37
38 private:
39 // Returns YES if |point| is in a non-transparent part of |image|.
40 BOOL HitTestImage(NSPoint point, NSImage* image, NSRect imageRect) const;
41
42 base::scoped_nsobject<NSImage> leftImage_;
43 base::scoped_nsobject<NSImage> middleImage_;
44 base::scoped_nsobject<NSImage> rightImage_;
45 NSSize leftSize_;
46 NSSize rightSize_;
47
48 DISALLOW_COPY_AND_ASSIGN(ThreePartImage);
49 };
50
51 } // namespace ui
52
53 #endif // UI_BASE_COCOA_THREE_PART_IMAGE_H
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698