OLD | NEW |
---|---|
(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 CC_RESOURCES_RESOURCE_UTIL_H_ | |
6 #define CC_RESOURCES_RESOURCE_UTIL_H_ | |
7 | |
8 #include "cc/base/cc_export.h" | |
9 #include "cc/resources/resource_format.h" | |
10 #include "ui/gfx/geometry/size.h" | |
11 | |
12 namespace cc { | |
13 | |
14 class CC_EXPORT ResourceUtil { | |
15 public: | |
16 // Dies with a CRASH() if the size can not be represented as a positive number | |
17 // of bytes. | |
18 static int CheckedSizeInBytes(const gfx::Size& size, ResourceFormat format); | |
vmpstr
2015/07/22 18:05:55
It's a bit awkward that the Checked version return
prashant.n
2015/07/23 05:27:10
I thought of adding following code; but it has a d
vmpstr
2015/07/23 17:56:27
What about the following?
template <typename T>
T
| |
19 // Returns the width in bytes but may overflow or return 0. Only do this for | |
20 // computing widths for sizes that have already been checked. | |
21 static size_t UncheckedWidthInBytes(size_t width, ResourceFormat format); | |
22 static size_t UncheckedWidthInBytesAligned(size_t width, | |
23 ResourceFormat format); | |
24 // Returns the size in bytes but may overflow or return 0. Only do this for | |
25 // sizes that have already been checked. | |
26 static size_t UncheckedSizeInBytes(const gfx::Size& size, | |
27 ResourceFormat format); | |
28 static size_t UncheckedSizeInBytesAligned(const gfx::Size& size, | |
29 ResourceFormat format); | |
30 // Return true if the call to size in bytes would return a value that fits in | |
31 // a size_t. | |
32 static bool VerifySizeInBytes(const gfx::Size& size, ResourceFormat format); | |
33 | |
34 private: | |
35 DISALLOW_COPY_AND_ASSIGN(ResourceUtil); | |
36 }; | |
37 | |
38 } // namespace cc | |
39 | |
40 #endif // CC_RESOURCES_RESOURCE_UTIL_H_ | |
OLD | NEW |