summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpvalchev@google.com <pvalchev@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2010-05-13 22:06:01 +0000
committerpvalchev@google.com <pvalchev@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2010-05-13 22:06:01 +0000
commit7cd70c394eeaeb6a93a8e28142942b5584f01e2d (patch)
tree4a3bde2aefad49928afe234d0d48154370ecbfc5
parent42b206a6890ec008ed2729b36a5a58f0f334b3be (diff)
downloadchromium_src-7cd70c394eeaeb6a93a8e28142942b5584f01e2d.zip
chromium_src-7cd70c394eeaeb6a93a8e28142942b5584f01e2d.tar.gz
chromium_src-7cd70c394eeaeb6a93a8e28142942b5584f01e2d.tar.bz2
Move non-linux specific code from base/linux_util to app/gtk_util
from sprewell Review URL: http://codereview.chromium.org/2058004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@47201 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--app/app_paths.cc2
-rw-r--r--app/clipboard/clipboard_linux.cc7
-rw-r--r--app/gtk_util.cc20
-rw-r--r--app/gtk_util.h6
-rw-r--r--base/linux_util.cc20
-rw-r--r--base/linux_util.h5
-rw-r--r--chrome/browser/icon_loader_linux.cc5
7 files changed, 34 insertions, 31 deletions
diff --git a/app/app_paths.cc b/app/app_paths.cc
index 0007a10..3121c43 100644
--- a/app/app_paths.cc
+++ b/app/app_paths.cc
@@ -56,7 +56,7 @@ bool PathProvider(int key, FilePath* result) {
#endif
break;
case app::FILE_RESOURCES_PAK:
-#if defined(OS_LINUX)
+#if defined(OS_POSIX) && !defined(OS_MACOSX)
if (!PathService::Get(base::DIR_EXE, &cur))
return false;
// TODO(tony): We shouldn't be referencing chrome here.
diff --git a/app/clipboard/clipboard_linux.cc b/app/clipboard/clipboard_linux.cc
index e7994de..d03d356 100644
--- a/app/clipboard/clipboard_linux.cc
+++ b/app/clipboard/clipboard_linux.cc
@@ -13,7 +13,7 @@
#include "base/file_path.h"
#include "base/logging.h"
#include "base/scoped_ptr.h"
-#include "base/linux_util.h"
+#include "app/gtk_util.h"
#include "base/utf_string_conversions.h"
#include "gfx/size.h"
@@ -189,8 +189,9 @@ void Clipboard::WriteWebSmartPaste() {
void Clipboard::WriteBitmap(const char* pixel_data, const char* size_data) {
const gfx::Size* size = reinterpret_cast<const gfx::Size*>(size_data);
- guchar* data = base::BGRAToRGBA(reinterpret_cast<const uint8_t*>(pixel_data),
- size->width(), size->height(), 0);
+ guchar* data =
+ gtk_util::BGRAToRGBA(reinterpret_cast<const uint8_t*>(pixel_data),
+ size->width(), size->height(), 0);
GdkPixbuf* pixbuf =
gdk_pixbuf_new_from_data(data, GDK_COLORSPACE_RGB, TRUE,
diff --git a/app/gtk_util.cc b/app/gtk_util.cc
index 0411fbb..00b1b5b 100644
--- a/app/gtk_util.cc
+++ b/app/gtk_util.cc
@@ -31,6 +31,26 @@ void GetWidgetSizeFromResources(
GetWidgetSizeFromCharacters(widget, chars, lines, width, height);
}
+uint8_t* BGRAToRGBA(const uint8_t* pixels, int width, int height, int stride) {
+ if (stride == 0)
+ stride = width * 4;
+
+ uint8_t* new_pixels = static_cast<uint8_t*>(malloc(height * stride));
+
+ // We have to copy the pixels and swap from BGRA to RGBA.
+ for (int i = 0; i < height; ++i) {
+ for (int j = 0; j < width; ++j) {
+ int idx = i * stride + j * 4;
+ new_pixels[idx] = pixels[idx + 2];
+ new_pixels[idx + 1] = pixels[idx + 1];
+ new_pixels[idx + 2] = pixels[idx];
+ new_pixels[idx + 3] = pixels[idx + 3];
+ }
+ }
+
+ return new_pixels;
+}
+
void GetWidgetSizeFromCharacters(
GtkWidget* widget, double width_chars, double height_lines,
int* width, int* height) {
diff --git a/app/gtk_util.h b/app/gtk_util.h
index 22ab7d2..089e901 100644
--- a/app/gtk_util.h
+++ b/app/gtk_util.h
@@ -5,6 +5,7 @@
#ifndef APP_GTK_UTIL_H_
#define APP_GTK_UTIL_H_
+#include <stdint.h>
typedef struct _GtkWidget GtkWidget;
namespace gtk_util {
@@ -29,6 +30,11 @@ void GetWidgetSizeFromCharacters(
// with gtk_message_dialog_new.
void ApplyMessageDialogQuirks(GtkWidget* dialog);
+// Makes a copy of |pixels| with the ordering changed from BGRA to RGBA.
+// The caller is responsible for free()ing the data. If |stride| is 0,
+// it's assumed to be 4 * |width|.
+uint8_t* BGRAToRGBA(const uint8_t* pixels, int width, int height, int stride);
+
} // namespace gtk_util
#endif // APP_GTK_UTIL_H_
diff --git a/base/linux_util.cc b/base/linux_util.cc
index 0ad9bb0..d9fd065 100644
--- a/base/linux_util.cc
+++ b/base/linux_util.cc
@@ -122,26 +122,6 @@ bool ProcPathGetInode(ino_t* inode_out, const char* path, bool log = false) {
namespace base {
-uint8_t* BGRAToRGBA(const uint8_t* pixels, int width, int height, int stride) {
- if (stride == 0)
- stride = width * 4;
-
- uint8_t* new_pixels = static_cast<uint8_t*>(malloc(height * stride));
-
- // We have to copy the pixels and swap from BGRA to RGBA.
- for (int i = 0; i < height; ++i) {
- for (int j = 0; j < width; ++j) {
- int idx = i * stride + j * 4;
- new_pixels[idx] = pixels[idx + 2];
- new_pixels[idx + 1] = pixels[idx + 1];
- new_pixels[idx + 2] = pixels[idx];
- new_pixels[idx + 3] = pixels[idx + 3];
- }
- }
-
- return new_pixels;
-}
-
// We use this static string to hold the Linux distro info. If we
// crash, the crash handler code will send this in the crash dump.
std::string linux_distro =
diff --git a/base/linux_util.h b/base/linux_util.h
index 2550f70..e810674 100644
--- a/base/linux_util.h
+++ b/base/linux_util.h
@@ -18,11 +18,6 @@ class EnvVarGetter;
static const char kFindInodeSwitch[] = "--find-inode";
-// Makes a copy of |pixels| with the ordering changed from BGRA to RGBA.
-// The caller is responsible for free()ing the data. If |stride| is 0,
-// it's assumed to be 4 * |width|.
-uint8_t* BGRAToRGBA(const uint8_t* pixels, int width, int height, int stride);
-
// Get the Linux Distro if we can, or return "Unknown", similar to
// GetWinVersion() in base/win_util.h.
std::string GetLinuxDistro();
diff --git a/chrome/browser/icon_loader_linux.cc b/chrome/browser/icon_loader_linux.cc
index 4a685ee..de26857 100644
--- a/chrome/browser/icon_loader_linux.cc
+++ b/chrome/browser/icon_loader_linux.cc
@@ -10,7 +10,7 @@
#include "base/file_util.h"
#include "base/logging.h"
-#include "base/linux_util.h"
+#include "app/gtk_util.h"
#include "base/message_loop.h"
#include "base/mime_util.h"
#include "base/thread.h"
@@ -60,7 +60,8 @@ void IconLoader::ParseIcon() {
if (!gdk_pixbuf_get_has_alpha(pixbuf)) {
LOG(WARNING) << "Got an image with no alpha channel, aborting load.";
} else {
- uint8_t* BGRA_pixels = base::BGRAToRGBA(pixels, width, height, stride);
+ uint8_t* BGRA_pixels =
+ gtk_util::BGRAToRGBA(pixels, width, height, stride);
std::vector<unsigned char> pixel_vector;
pixel_vector.resize(height * stride);
memcpy(const_cast<unsigned char*>(pixel_vector.data()), BGRA_pixels,