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

Unified 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: Split ThreePartImage 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 side-by-side diff with in-line comments
Download patch
Index: ui/base/cocoa/three_part_image.h
diff --git a/ui/base/cocoa/three_part_image.h b/ui/base/cocoa/three_part_image.h
new file mode 100644
index 0000000000000000000000000000000000000000..6969ada2ee9fa5dfa8376f3e6edcd857b67e74c8
--- /dev/null
+++ b/ui/base/cocoa/three_part_image.h
@@ -0,0 +1,51 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef UI_BASE_COCOA_THREE_PART_IMAGE_H
+#define UI_BASE_COCOA_THREE_PART_IMAGE_H
+
+#import <Cocoa/Cocoa.h>
+
+#include "base/mac/scoped_nsobject.h"
+#include "ui/base/ui_base_export.h"
+
+namespace ui {
+
+// A wrapper around NSDrawThreePartImage that caches the images.
Robert Sesek 2015/02/12 21:56:37 This should mention that the ids are for ResourceB
Andre 2015/02/12 22:10:37 Done.
+// The middle image is optional.
+// Vertical orientation is not currently supported.
+class UI_BASE_EXPORT ThreePartImage {
+ public:
+ ThreePartImage(int left_id, int middle_id, int right_id);
+ ~ThreePartImage();
+
+ // Returns the image rects if drawn in |bounds|.
+ NSRect GetLeftRect(NSRect bounds) const;
+ NSRect GetMiddleRect(NSRect bounds) const;
+ NSRect GetRightRect(NSRect bounds) const;
+
+ // Draws the three part image inside |rect|.
+ void DrawInRect(NSRect rect, NSCompositingOperation op, CGFloat alpha) const;
+
+ // Returns YES if |point| is in a non-transparent part of the images.
+ // Returns YES if |point| is inside the middle rect and there is no middle
+ // image.
+ BOOL HitTest(NSPoint point, NSRect bounds) const;
+
+ private:
+ // Returns YES if |point| is in a non-transparent part of |image|.
+ BOOL HitTestImage(NSPoint point, NSImage* image, NSRect imageRect) const;
+
+ base::scoped_nsobject<NSImage> leftImage_;
+ base::scoped_nsobject<NSImage> middleImage_;
+ base::scoped_nsobject<NSImage> rightImage_;
+ NSSize leftSize_;
+ NSSize rightSize_;
+
+ DISALLOW_COPY_AND_ASSIGN(ThreePartImage);
+};
+
+} // namespace ui
+
+#endif // UI_BASE_COCOA_THREE_PART_IMAGE_H

Powered by Google App Engine
This is Rietveld 408576698