From 9edf15bce7dab0c0a083b0c2dac910736d766c84 Mon Sep 17 00:00:00 2001 From: "posciak@chromium.org" Date: Thu, 1 May 2014 08:02:00 +0000 Subject: [PATCH] Use base::bits::Log2{Floor,Ceiling} instead of redefining them in TransferBuffer. Both implementations appear identical. BUG=None TEST=gpu_unittests Review URL: https://codereview.chromium.org/266483002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@267478 0039d316-1c4b-4281-b951-d872f2087c98 --- gpu/command_buffer/client/transfer_buffer.cc | 31 ++------------------ 1 file changed, 2 insertions(+), 29 deletions(-) diff --git a/gpu/command_buffer/client/transfer_buffer.cc b/gpu/command_buffer/client/transfer_buffer.cc index 22a31c8c1ac19b..70c4bf0761887e 100644 --- a/gpu/command_buffer/client/transfer_buffer.cc +++ b/gpu/command_buffer/client/transfer_buffer.cc @@ -6,6 +6,7 @@ #include "gpu/command_buffer/client/transfer_buffer.h" +#include "base/bits.h" #include "base/debug/trace_event.h" #include "base/logging.h" #include "gpu/command_buffer/client/cmd_buffer_helper.h" @@ -109,36 +110,8 @@ void TransferBuffer::AllocateRingBuffer(unsigned int size) { usable_ = false; } -// Returns the integer i such as 2^i <= n < 2^(i+1) -static int Log2Floor(uint32 n) { - if (n == 0) - return -1; - int log = 0; - uint32 value = n; - for (int i = 4; i >= 0; --i) { - int shift = (1 << i); - uint32 x = value >> shift; - if (x != 0) { - value = x; - log += shift; - } - } - DCHECK_EQ(value, 1u); - return log; -} - -// Returns the integer i such as 2^(i-1) < n <= 2^i -static int Log2Ceiling(uint32 n) { - if (n == 0) { - return -1; - } else { - // Log2Floor returns -1 for 0, so the following works correctly for n=1. - return 1 + Log2Floor(n - 1); - } -} - static unsigned int ComputePOTSize(unsigned int dimension) { - return (dimension == 0) ? 0 : 1 << Log2Ceiling(dimension); + return (dimension == 0) ? 0 : 1 << base::bits::Log2Ceiling(dimension); } void TransferBuffer::ReallocateRingBuffer(unsigned int size) {