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

Side by Side Diff: ui/gfx/image/image_skia_rep.h

Issue 10696130: Get rid of implicit conversion to and from ImageSkiaRep (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 5 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 | Annotate | Revision Log
« no previous file with comments | « ui/gfx/image/image_skia.cc ('k') | ui/gfx/image/image_skia_rep.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef UI_GFX_IMAGE_IMAGE_SKIA_REP_H_ 5 #ifndef UI_GFX_IMAGE_IMAGE_SKIA_REP_H_
6 #define UI_GFX_IMAGE_IMAGE_SKIA_REP_H_ 6 #define UI_GFX_IMAGE_IMAGE_SKIA_REP_H_
7 #pragma once 7 #pragma once
8 8
9 #include "third_party/skia/include/core/SkBitmap.h" 9 #include "third_party/skia/include/core/SkBitmap.h"
10 #include "ui/base/layout.h" 10 #include "ui/base/layout.h"
11 #include "ui/base/ui_export.h" 11 #include "ui/base/ui_export.h"
12 12
13 namespace gfx { 13 namespace gfx {
14 class Size; 14 class Size;
15 15
16 // An ImageSkiaRep represents a bitmap and the scale factor it is intended for. 16 // An ImageSkiaRep represents a bitmap and the scale factor it is intended for.
17 class UI_EXPORT ImageSkiaRep { 17 class UI_EXPORT ImageSkiaRep {
18 public: 18 public:
19 // Create null bitmap. 19 // Create null bitmap.
20 ImageSkiaRep(); 20 ImageSkiaRep();
21 ~ImageSkiaRep(); 21 ~ImageSkiaRep();
22 22
23 // Creates a bitmap with kARGB_8888_Config config with given |size| in DIP. 23 // Creates a bitmap with kARGB_8888_Config config with given |size| in DIP.
24 // This allocates pixels in the bitmap. 24 // This allocates pixels in the bitmap.
25 ImageSkiaRep(const gfx::Size& size, ui::ScaleFactor scale_factor); 25 ImageSkiaRep(const gfx::Size& size, ui::ScaleFactor scale_factor);
26 26
27 // Creates a bitmap with a default scale factor of 1x.
28 // Adds ref to |src|.
29 // TODO(pkotwicz): This is temporary and should be removed ASAP.
30 ImageSkiaRep(const SkBitmap& src);
31
32 // Creates a bitmap with given scale factor. 27 // Creates a bitmap with given scale factor.
33 // Adds ref to |src|. 28 // Adds ref to |src|.
34 ImageSkiaRep(const SkBitmap& src, ui::ScaleFactor scale_factor); 29 ImageSkiaRep(const SkBitmap& src, ui::ScaleFactor scale_factor);
35 30
36 // Converts to and from SkBitmap.
37 // TODO(pkotwicz): This is temporary and should be removed ASAP.
38 ImageSkiaRep& operator=(const SkBitmap& other);
39 operator SkBitmap&() const;
40
41 // Returns true if the backing bitmap is null. 31 // Returns true if the backing bitmap is null.
42 bool is_null() const { return bitmap_.isNull(); } 32 bool is_null() const { return bitmap_.isNull(); }
43 33
44 // Get width and height of bitmap in DIP. 34 // Get width and height of bitmap in DIP.
45 int GetWidth() const; 35 int GetWidth() const;
46 int GetHeight() const; 36 int GetHeight() const;
47 37
48 // Get width and height of bitmap in pixels. 38 // Get width and height of bitmap in pixels.
49 int pixel_width() const { return bitmap_.width(); } 39 int pixel_width() const { return bitmap_.width(); }
50 int pixel_height() const { return bitmap_.height(); } 40 int pixel_height() const { return bitmap_.height(); }
51 41
52 // Retrieves the scale that the bitmap will be painted at. 42 // Retrieves the scale that the bitmap will be painted at.
53 float GetScale() const; 43 float GetScale() const;
54 ui::ScaleFactor scale_factor() const { return scale_factor_; } 44 ui::ScaleFactor scale_factor() const { return scale_factor_; }
55 45
56 // Returns backing bitmap. 46 // Returns backing bitmap.
57 const SkBitmap& sk_bitmap() const { return bitmap_; } 47 const SkBitmap& sk_bitmap() const { return bitmap_; }
58 48
59 private: 49 private:
60 SkBitmap bitmap_; 50 SkBitmap bitmap_;
61 ui::ScaleFactor scale_factor_; 51 ui::ScaleFactor scale_factor_;
62 }; 52 };
63 53
64 } // namespace gfx 54 } // namespace gfx
65 55
66 #endif // UI_GFX_IMAGE_IMAGE_SKIA_REP_H_ 56 #endif // UI_GFX_IMAGE_IMAGE_SKIA_REP_H_
OLDNEW
« no previous file with comments | « ui/gfx/image/image_skia.cc ('k') | ui/gfx/image/image_skia_rep.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698