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

Side by Side Diff: cc/resources/resource_util.cc

Issue 1202843008: cc: Fix BytesPerPixel issue and refactor. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed review comments. Created 5 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
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 #include "cc/resources/resource_util.h"
6
7 #include "cc/base/math_util.h"
8
9 namespace cc {
10
11 // static
12 size_t ResourceUtil::UncheckedWidthInBytes(size_t width,
13 ResourceFormat format) {
14 size_t bytes_per_row = width * static_cast<size_t>(BitsPerPixel(format)) / 8;
15 return bytes_per_row;
16 }
17
18 // static
19 size_t ResourceUtil::UncheckedSizeInBytes(const gfx::Size& size,
20 ResourceFormat format) {
21 DCHECK(VerifySizeInBytes<size_t>(size, format));
22 return size.height() * UncheckedWidthInBytes(size.width(), format);
23 }
24
25 // static
26 size_t ResourceUtil::UncheckedWidthInBytesAligned(size_t width,
27 ResourceFormat format) {
28 return MathUtil::RoundUp<size_t>(UncheckedWidthInBytes(width, format), 4u);
29 }
30
31 // static
32 size_t ResourceUtil::UncheckedSizeInBytesAligned(const gfx::Size& size,
33 ResourceFormat format) {
34 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.
35 return size.height() * UncheckedWidthInBytesAligned(size.width(), format);
36 }
37
38 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698