Index: cc/resources/resource_util.cc |
diff --git a/cc/resources/resource_util.cc b/cc/resources/resource_util.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..71141590e33d7711a5b24c655dac926bdafc4216 |
--- /dev/null |
+++ b/cc/resources/resource_util.cc |
@@ -0,0 +1,38 @@ |
+// 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. |
+ |
+#include "cc/resources/resource_util.h" |
+ |
+#include "cc/base/math_util.h" |
+ |
+namespace cc { |
+ |
+// static |
+size_t ResourceUtil::UncheckedWidthInBytes(size_t width, |
+ ResourceFormat format) { |
+ size_t bytes_per_row = width * static_cast<size_t>(BitsPerPixel(format)) / 8; |
+ return bytes_per_row; |
+} |
+ |
+// static |
+size_t ResourceUtil::UncheckedSizeInBytes(const gfx::Size& size, |
+ ResourceFormat format) { |
+ DCHECK(VerifySizeInBytes<size_t>(size, format)); |
+ return size.height() * UncheckedWidthInBytes(size.width(), format); |
+} |
+ |
+// static |
+size_t ResourceUtil::UncheckedWidthInBytesAligned(size_t width, |
+ ResourceFormat format) { |
+ return MathUtil::RoundUp<size_t>(UncheckedWidthInBytes(width, format), 4u); |
+} |
+ |
+// static |
+size_t ResourceUtil::UncheckedSizeInBytesAligned(const gfx::Size& size, |
+ ResourceFormat format) { |
+ DCHECK(VerifySizeInBytes<size_t>(size, format)); |
ericrk
2015/07/24 20:03:52
Super nit (feel free to ignore): the following can
prashant.n
2015/07/25 07:15:43
Hmm, I'll check on this.
|
+ return size.height() * UncheckedWidthInBytesAligned(size.width(), format); |
+} |
+ |
+} // namespace cc |