Skip to content

Commit

Permalink
Use base::bits::Log2{Floor,Ceiling} instead of redefining them in Tra…
Browse files Browse the repository at this point in the history
…nsferBuffer.

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
  • Loading branch information
posciak@chromium.org committed May 1, 2014
1 parent 5ee0090 commit 9edf15b
Showing 1 changed file with 2 additions and 29 deletions.
31 changes: 2 additions & 29 deletions gpu/command_buffer/client/transfer_buffer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 9edf15b

Please sign in to comment.