Skip to content

Commit

Permalink
Reverting 6709,6708,6706.
Browse files Browse the repository at this point in the history
Review URL: http://codereview.chromium.org/13345

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@6710 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
brettw@google.com committed Dec 10, 2008
1 parent f3750b3 commit c4b347b
Show file tree
Hide file tree
Showing 15 changed files with 168 additions and 160 deletions.
6 changes: 3 additions & 3 deletions chrome/browser/fav_icon_helper.cc
Original file line number Diff line number Diff line change
Expand Up @@ -257,9 +257,9 @@ SkBitmap FavIconHelper::ConvertToFavIconSize(const SkBitmap& image) {
int height = image.height();
if (width > 0 && height > 0) {
calc_favicon_target_size(&width, &height);
return skia::ImageOperations::Resize(image,
skia::ImageOperations::RESIZE_LANCZOS3,
width, height);
return gfx::ImageOperations::Resize(
image, gfx::ImageOperations::RESIZE_LANCZOS3,
gfx::Size(width, height));
}
return image;
}
Expand Down
6 changes: 3 additions & 3 deletions chrome/browser/importer/importer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -384,9 +384,9 @@ bool Importer::ReencodeFavicon(const unsigned char* src_data, size_t src_len,
int new_width = decoded.width();
int new_height = decoded.height();
calc_favicon_target_size(&new_width, &new_height);
decoded = skia::ImageOperations::Resize(
decoded, skia::ImageOperations::RESIZE_LANCZOS3,
new_width, new_height);
decoded = gfx::ImageOperations::Resize(
decoded, gfx::ImageOperations::RESIZE_LANCZOS3,
gfx::Size(new_width, new_height));
}

// Encode our bitmap as a PNG.
Expand Down
6 changes: 3 additions & 3 deletions chrome/browser/views/tabs/tab_renderer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -586,13 +586,13 @@ void TabRenderer::PaintActiveTabBackground(ChromeCanvas* canvas) {
void TabRenderer::PaintHoverTabBackground(ChromeCanvas* canvas,
double opacity) {
bool is_otr = data_.off_the_record;
SkBitmap left = skia::ImageOperations::CreateBlendedBitmap(
SkBitmap left = gfx::ImageOperations::CreateBlendedBitmap(
(is_otr ? *tab_inactive_otr_l : *tab_inactive_l),
*tab_hover_l, opacity);
SkBitmap center = skia::ImageOperations::CreateBlendedBitmap(
SkBitmap center = gfx::ImageOperations::CreateBlendedBitmap(
(is_otr ? *tab_inactive_otr_c : *tab_inactive_c),
*tab_hover_c, opacity);
SkBitmap right = skia::ImageOperations::CreateBlendedBitmap(
SkBitmap right = gfx::ImageOperations::CreateBlendedBitmap(
(is_otr ? *tab_inactive_otr_r : *tab_inactive_r),
*tab_hover_r, opacity);

Expand Down
6 changes: 3 additions & 3 deletions chrome/common/gfx/icon_util.cc
Original file line number Diff line number Diff line change
Expand Up @@ -403,9 +403,9 @@ void IconUtil::CreateResizedBitmapSet(const SkBitmap& bitmap_to_resize,
inserted_original_bitmap = true;
}
}
bitmaps->push_back(skia::ImageOperations::Resize(
bitmap_to_resize, skia::ImageOperations::RESIZE_LANCZOS3,
icon_dimensions_[i], icon_dimensions_[i]));
bitmaps->push_back(gfx::ImageOperations::Resize(
bitmap_to_resize, gfx::ImageOperations::RESIZE_LANCZOS3,
gfx::Size(icon_dimensions_[i], icon_dimensions_[i])));
}

if (!inserted_original_bitmap) {
Expand Down
4 changes: 2 additions & 2 deletions chrome/renderer/render_view.cc
Original file line number Diff line number Diff line change
Expand Up @@ -798,8 +798,8 @@ bool RenderView::CaptureThumbnail(WebFrame* frame,
device->accessBitmap(false).extractSubset(&subset, src_rect);

// Resample the subset that we want to get it the right size.
*thumbnail = skia::ImageOperations::Resize(
subset, skia::ImageOperations::RESIZE_LANCZOS3, w, h);
*thumbnail = gfx::ImageOperations::Resize(
subset, gfx::ImageOperations::RESIZE_LANCZOS3, gfx::Size(w, h));

score->boring_score = CalculateBoringScore(thumbnail);

Expand Down
2 changes: 1 addition & 1 deletion chrome/views/button.cc
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ SkBitmap Button::GetImageToPaint() {
SkBitmap img;

if (!images_[BS_HOT].isNull() && hover_animation_->IsAnimating()) {
img = skia::ImageOperations::CreateBlendedBitmap(images_[BS_NORMAL],
img = gfx::ImageOperations::CreateBlendedBitmap(images_[BS_NORMAL],
images_[BS_HOT], hover_animation_->GetCurrentValue());
} else {
img = images_[GetState()];
Expand Down
59 changes: 30 additions & 29 deletions skia/ext/convolver.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,18 @@

#include <algorithm>

#include "base/basictypes.h"
#include "base/logging.h"
#include "skia/ext/convolver.h"
#include "SkTypes.h"

namespace skia {
namespace gfx {

namespace {

// Converts the argument to an 8-bit unsigned value by clamping to the range
// 0-255.
inline unsigned int ClampTo8(int a) {
if (static_cast<int>(a) < 256)
inline uint8 ClampTo8(int32 a) {
if (static_cast<uint32>(a) < 256)
return a; // Avoid the extra check in the common case.
if (a < 0)
return 0;
Expand Down Expand Up @@ -44,8 +45,8 @@ class CircularRowBuffer {

// Moves to the next row in the buffer, returning a pointer to the beginning
// of it.
unsigned char* AdvanceRow() {
unsigned char* row = &buffer_[next_row_ * row_byte_width_];
uint8* AdvanceRow() {
uint8* row = &buffer_[next_row_ * row_byte_width_];
next_row_coordinate_++;

// Set the pointer to the next row to use, wrapping around if necessary.
Expand All @@ -61,7 +62,7 @@ class CircularRowBuffer {
//
// The |first_row_index_| may be negative. This means the circular buffer
// starts before the top of the image (it hasn't been filled yet).
unsigned char* const* GetRowAddresses(int* first_row_index) {
uint8* const* GetRowAddresses(int* first_row_index) {
// Example for a 4-element circular buffer holding coords 6-9.
// Row 0 Coord 8
// Row 1 Coord 9
Expand All @@ -88,7 +89,7 @@ class CircularRowBuffer {

private:
// The buffer storing the rows. They are packed, each one row_byte_width_.
std::vector<unsigned char> buffer_;
std::vector<uint8> buffer_;

// Number of bytes per row in the |buffer_|.
int row_byte_width_;
Expand All @@ -105,31 +106,31 @@ class CircularRowBuffer {
int next_row_coordinate_;

// Buffer used by GetRowAddresses().
std::vector<unsigned char*> row_addresses_;
std::vector<uint8*> row_addresses_;
};

// Convolves horizontally along a single row. The row data is given in
// |src_data| and continues for the num_values() of the filter.
template<bool has_alpha>
void ConvolveHorizontally(const unsigned char* src_data,
void ConvolveHorizontally(const uint8* src_data,
const ConvolusionFilter1D& filter,
unsigned char* out_row) {
// Loop over each pixel on this row in the output image.
int num_values = filter.num_values();
for (int out_x = 0; out_x < num_values; out_x++) {
// Get the filter that determines the current output pixel.
int filter_offset, filter_length;
const short* filter_values =
const int16* filter_values =
filter.FilterForValue(out_x, &filter_offset, &filter_length);

// Compute the first pixel in this row that the filter affects. It will
// touch |filter_length| pixels (4 bytes each) after this.
const unsigned char* row_to_filter = &src_data[filter_offset * 4];
const uint8* row_to_filter = &src_data[filter_offset * 4];

// Apply the filter to the row to get the destination pixel in |accum|.
int accum[4] = {0};
int32 accum[4] = {0};
for (int filter_x = 0; filter_x < filter_length; filter_x++) {
short cur_filter = filter_values[filter_x];
int16 cur_filter = filter_values[filter_x];
accum[0] += cur_filter * row_to_filter[filter_x * 4 + 0];
accum[1] += cur_filter * row_to_filter[filter_x * 4 + 1];
accum[2] += cur_filter * row_to_filter[filter_x * 4 + 2];
Expand Down Expand Up @@ -161,11 +162,11 @@ void ConvolveHorizontally(const unsigned char* src_data,
//
// The output must have room for |pixel_width * 4| bytes.
template<bool has_alpha>
void ConvolveVertically(const short* filter_values,
void ConvolveVertically(const int16* filter_values,
int filter_length,
unsigned char* const* source_data_rows,
uint8* const* source_data_rows,
int pixel_width,
unsigned char* out_row) {
uint8* out_row) {
// We go through each column in the output and do a vertical convolusion,
// generating one output pixel each time.
for (int out_x = 0; out_x < pixel_width; out_x++) {
Expand All @@ -174,9 +175,9 @@ void ConvolveVertically(const short* filter_values,
int byte_offset = out_x * 4;

// Apply the filter to one column of pixels.
int accum[4] = {0};
int32 accum[4] = {0};
for (int filter_y = 0; filter_y < filter_length; filter_y++) {
short cur_filter = filter_values[filter_y];
int16 cur_filter = filter_values[filter_y];
accum[0] += cur_filter * source_data_rows[filter_y][byte_offset + 0];
accum[1] += cur_filter * source_data_rows[filter_y][byte_offset + 1];
accum[2] += cur_filter * source_data_rows[filter_y][byte_offset + 2];
Expand All @@ -197,7 +198,7 @@ void ConvolveVertically(const short* filter_values,
out_row[byte_offset + 1] = ClampTo8(accum[1]);
out_row[byte_offset + 2] = ClampTo8(accum[2]);
if (has_alpha) {
unsigned char alpha = ClampTo8(accum[3]);
uint8 alpha = ClampTo8(accum[3]);

// Make sure the alpha channel doesn't come out larger than any of the
// color channels. We use premultipled alpha channels, so this should
Expand Down Expand Up @@ -232,23 +233,23 @@ void ConvolusionFilter1D::AddFilter(int filter_offset,
instance.length = filter_length;
filters_.push_back(instance);

SkASSERT(filter_length > 0);
DCHECK(filter_length > 0);
for (int i = 0; i < filter_length; i++)
filter_values_.push_back(FloatToFixed(filter_values[i]));

max_filter_ = std::max(max_filter_, filter_length);
}

void ConvolusionFilter1D::AddFilter(int filter_offset,
const short* filter_values,
const int16* filter_values,
int filter_length) {
FilterInstance instance;
instance.data_location = static_cast<int>(filter_values_.size());
instance.offset = filter_offset;
instance.length = filter_length;
filters_.push_back(instance);

SkASSERT(filter_length > 0);
DCHECK(filter_length > 0);
for (int i = 0; i < filter_length; i++)
filter_values_.push_back(filter_values[i]);

Expand All @@ -257,12 +258,12 @@ void ConvolusionFilter1D::AddFilter(int filter_offset,

// BGRAConvolve2D -------------------------------------------------------------

void BGRAConvolve2D(const unsigned char* source_data,
void BGRAConvolve2D(const uint8* source_data,
int source_byte_row_stride,
bool source_has_alpha,
const ConvolusionFilter1D& filter_x,
const ConvolusionFilter1D& filter_y,
unsigned char* output) {
uint8* output) {
int max_y_filter_size = filter_y.max_filter();

// The next row in the input that we will generate a horizontally
Expand All @@ -271,7 +272,7 @@ void BGRAConvolve2D(const unsigned char* source_data,
// don't want to generate any output rows before that. Compute the starting
// row for convolusion as the first pixel for the first vertical filter.
int filter_offset, filter_length;
const short* filter_values =
const int16* filter_values =
filter_y.FilterForValue(0, &filter_offset, &filter_length);
int next_x_row = filter_offset;

Expand Down Expand Up @@ -306,16 +307,16 @@ void BGRAConvolve2D(const unsigned char* source_data,
}

// Compute where in the output image this row of final data will go.
unsigned char* cur_output_row = &output[out_y * output_row_byte_width];
uint8* cur_output_row = &output[out_y * output_row_byte_width];

// Get the list of rows that the circular buffer has, in order.
int first_row_in_circular_buffer;
unsigned char* const* rows_to_convolve =
uint8* const* rows_to_convolve =
row_buffer.GetRowAddresses(&first_row_in_circular_buffer);

// Now compute the start of the subset of those rows that the filter
// needs.
unsigned char* const* first_row_for_filter =
uint8* const* first_row_for_filter =
&rows_to_convolve[filter_offset - first_row_in_circular_buffer];

if (source_has_alpha) {
Expand Down
24 changes: 13 additions & 11 deletions skia/ext/convolver.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,14 @@

#include <vector>

#include "base/basictypes.h"

// avoid confusion with Mac OS X's math library (Carbon)
#if defined(__APPLE__)
#if defined(OS_MACOSX)
#undef FloatToFixed
#endif

namespace skia {
namespace gfx {

// Represents a filter in one dimension. Each output pixel has one entry in this
// object for the filter values contributing to it. You build up the filter
Expand All @@ -31,10 +33,10 @@ class ConvolusionFilter1D {
}

// Convert between floating point and our fixed point representation.
static short FloatToFixed(float f) {
return static_cast<short>(f * (1 << kShiftBits));
static inline int16 FloatToFixed(float f) {
return static_cast<int16>(f * (1 << kShiftBits));
}
static unsigned char FixedToChar(short x) {
static inline unsigned char FixedToChar(int16 x) {
return static_cast<unsigned char>(x >> kShiftBits);
}

Expand Down Expand Up @@ -63,15 +65,15 @@ class ConvolusionFilter1D {

// Same as the above version, but the input is already fixed point.
void AddFilter(int filter_offset,
const short* filter_values,
const int16* filter_values,
int filter_length);

// Retrieves a filter for the given |value_offset|, a position in the output
// image in the direction we're convolving. The offset and length of the
// filter values are put into the corresponding out arguments (see AddFilter
// above for what these mean), and a pointer to the first scaling factor is
// returned. There will be |filter_length| values in this array.
inline const short* FilterForValue(int value_offset,
inline const int16* FilterForValue(int value_offset,
int* filter_offset,
int* filter_length) const {
const FilterInstance& filter = filters_[value_offset];
Expand All @@ -98,7 +100,7 @@ class ConvolusionFilter1D {
// We store all the filter values in this flat list, indexed by
// |FilterInstance.data_location| to avoid the mallocs required for storing
// each one separately.
std::vector<short> filter_values_;
std::vector<int16> filter_values_;

// The maximum size of any filter we've added.
int max_filter_;
Expand All @@ -122,14 +124,14 @@ class ConvolusionFilter1D {
//
// The layout in memory is assumed to be 4-bytes per pixel in B-G-R-A order
// (this is ARGB when loaded into 32-bit words on a little-endian machine).
void BGRAConvolve2D(const unsigned char* source_data,
void BGRAConvolve2D(const uint8* source_data,
int source_byte_row_stride,
bool source_has_alpha,
const ConvolusionFilter1D& xfilter,
const ConvolusionFilter1D& yfilter,
unsigned char* output);
uint8* output);

} // namespace skia
} // namespace gfx

#endif // SKIA_EXT_CONVOLVER_H_

2 changes: 1 addition & 1 deletion skia/ext/convolver_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#include "skia/ext/convolver.h"
#include "testing/gtest/include/gtest/gtest.h"

namespace skia {
namespace gfx {

namespace {

Expand Down
Loading

0 comments on commit c4b347b

Please sign in to comment.