diff options
author | thakis@chromium.org <thakis@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-05-08 05:55:07 +0000 |
---|---|---|
committer | thakis@chromium.org <thakis@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-05-08 05:55:07 +0000 |
commit | 0724e82343ab19fca8afe92c57f0bd78df1fa567 (patch) | |
tree | e6ddfc1207ede93faf6c8991071ae8b93944a05f | |
parent | 47b375e2cabf0d953a4a342e7c51abc9a5afc926 (diff) | |
download | chromium_src-0724e82343ab19fca8afe92c57f0bd78df1fa567.zip chromium_src-0724e82343ab19fca8afe92c57f0bd78df1fa567.tar.gz chromium_src-0724e82343ab19fca8afe92c57f0bd78df1fa567.tar.bz2 |
Revert r135533.
It broke all content_unittests on mac in debug builds.
BUG=121135,126558
TEST=no stack dumps in content_unittests output on mac debug builds
TBR=varunjain
Review URL: https://chromiumcodereview.appspot.com/10386020
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@135796 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | ash/drag_drop/drag_drop_controller.cc | 2 | ||||
-rw-r--r-- | content/test/DEPS | 4 | ||||
-rw-r--r-- | content/test/content_test_suite.cc | 6 | ||||
-rw-r--r-- | content/test/content_test_suite.h | 3 | ||||
-rw-r--r-- | ui/aura/aura.gyp | 2 | ||||
-rw-r--r-- | ui/aura/root_window_host_linux.cc | 55 | ||||
-rw-r--r-- | ui/aura/root_window_host_linux.h | 3 | ||||
-rw-r--r-- | ui/base/x/x11_util.cc | 21 | ||||
-rw-r--r-- | ui/base/x/x11_util.h | 7 | ||||
-rw-r--r-- | ui/gfx/codec/png_codec.cc | 21 | ||||
-rw-r--r-- | ui/gfx/skia_util.cc | 25 | ||||
-rw-r--r-- | ui/gfx/skia_util.h | 7 | ||||
-rw-r--r-- | ui/resources/ui_resources_2x.grd | 2 | ||||
-rw-r--r-- | ui/resources/ui_resources_standard.grd | 2 | ||||
-rw-r--r-- | ui/resources/ui_resources_touch.grd | 2 | ||||
-rw-r--r-- | ui/ui.gyp | 1 | ||||
-rw-r--r-- | webkit/glue/webcursor_aurax11.cc | 35 |
17 files changed, 53 insertions, 145 deletions
diff --git a/ash/drag_drop/drag_drop_controller.cc b/ash/drag_drop/drag_drop_controller.cc index b06beed67..09e0aad 100644 --- a/ash/drag_drop/drag_drop_controller.cc +++ b/ash/drag_drop/drag_drop_controller.cc @@ -114,7 +114,7 @@ void DragDropController::DragUpdate(aura::Window* target, drag_operation_); int op = delegate->OnDragUpdated(e); gfx::NativeCursor cursor = (op == ui::DragDropTypes::DRAG_NONE)? - ui::kCursorNoDrop : ui::kCursorCopy; + ui::kCursorMove : ui::kCursorHand; Shell::GetRootWindow()->SetCursor(cursor); } } diff --git a/content/test/DEPS b/content/test/DEPS index f614bb5..1d02736 100644 --- a/content/test/DEPS +++ b/content/test/DEPS @@ -3,7 +3,5 @@ include_rules = [ # Testing utilities can access anything in content/ "+content", "+media/base", # For ChannelLayout in WebRTC tests. - "+ui/base/resource/data_pack.h", - # TODO(varunjain): remove this - "+ui/base/resource/resource_bundle.h", + "+ui/base/resource/data_pack.h" ] diff --git a/content/test/content_test_suite.cc b/content/test/content_test_suite.cc index 9c018e9..2007156 100644 --- a/content/test/content_test_suite.cc +++ b/content/test/content_test_suite.cc @@ -11,7 +11,6 @@ #include "content/test/test_content_client.h" #include "content/test/test_content_client_initializer.h" #include "testing/gtest/include/gtest/gtest.h" -#include "ui/base/resource/resource_bundle.h" #include "ui/base/ui_base_paths.h" #if defined(OS_MACOSX) @@ -72,10 +71,5 @@ void ContentTestSuite::Initialize() { testing::TestEventListeners& listeners = testing::UnitTest::GetInstance()->listeners(); listeners.Append(new TestInitializationListener); - ui::ResourceBundle::InitSharedInstanceWithLocale("en-US"); } -void ContentTestSuite::Shutdown() { - ui::ResourceBundle::CleanupSharedInstance(); - base::TestSuite::Shutdown(); -} diff --git a/content/test/content_test_suite.h b/content/test/content_test_suite.h index e3abdb7..6a2b948 100644 --- a/content/test/content_test_suite.h +++ b/content/test/content_test_suite.h @@ -1,4 +1,4 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -17,7 +17,6 @@ class ContentTestSuite : public base::TestSuite { protected: virtual void Initialize() OVERRIDE; - virtual void Shutdown() OVERRIDE; private: base::win::ScopedCOMInitializer com_initializer_; diff --git a/ui/aura/aura.gyp b/ui/aura/aura.gyp index a8e898f..f7b3f8f 100644 --- a/ui/aura/aura.gyp +++ b/ui/aura/aura.gyp @@ -19,8 +19,6 @@ '../ui.gyp:gfx_resources', '../ui.gyp:ui', '../ui.gyp:ui_resources', - '../ui.gyp:ui_resources_2x', - '../ui.gyp:ui_resources_standard', ], 'defines': [ 'AURA_IMPLEMENTATION', diff --git a/ui/aura/root_window_host_linux.cc b/ui/aura/root_window_host_linux.cc index d9b9cd3..83ca3ee 100644 --- a/ui/aura/root_window_host_linux.cc +++ b/ui/aura/root_window_host_linux.cc @@ -5,7 +5,6 @@ #include "ui/aura/root_window_host_linux.h" #include <X11/Xatom.h> -#include <X11/Xcursor/Xcursor.h> #include <X11/cursorfont.h> #include <X11/extensions/XInput2.h> #include <X11/extensions/Xfixes.h> @@ -15,8 +14,6 @@ #include "base/message_pump_x.h" #include "base/stl_util.h" #include "base/stringprintf.h" -#include "grit/ui_resources_standard.h" -#include "third_party/skia/include/core/SkBitmap.h" #include "ui/aura/client/user_gesture_client.h" #include "ui/aura/dispatcher_linux.h" #include "ui/aura/env.h" @@ -24,12 +21,10 @@ #include "ui/aura/root_window.h" #include "ui/base/cursor/cursor.h" #include "ui/base/keycodes/keyboard_codes.h" -#include "ui/base/resource/resource_bundle.h" #include "ui/base/touch/touch_factory.h" #include "ui/base/view_prop.h" #include "ui/base/x/x11_util.h" #include "ui/compositor/layer.h" -#include "ui/gfx/image/image.h" using std::max; using std::min; @@ -297,51 +292,6 @@ const char* kAtomList[] = { } // namespace -// A utility class that provides X Cursor for NativeCursors for which we have -// image resources. -class RootWindowHostLinux::ImageCursors { - public: - ImageCursors() { - LoadImageCursor(ui::kCursorNoDrop, IDR_AURA_CURSOR_NO_DROP); - LoadImageCursor(ui::kCursorCopy, IDR_AURA_CURSOR_COPY); - // TODO (varunjain): add more cursors once we have assets. - } - - ~ImageCursors() { - std::map<int, Cursor>::const_iterator it; - for (it = cursors_.begin(); it != cursors_.end(); ++it) - ui::UnrefCustomXCursor(it->second); - } - - // Returns true if we have an image resource loaded for the |native_cursor|. - bool IsImageCursor(gfx::NativeCursor native_cursor) { - return cursors_.find(native_cursor.native_type()) != cursors_.end(); - } - - // Gets the X Cursor corresponding to the |native_cursor|. - ::Cursor ImageCursorFromNative(gfx::NativeCursor native_cursor) { - DCHECK(cursors_.find(native_cursor.native_type()) != cursors_.end()); - return cursors_[native_cursor.native_type()]; - } - - private: - // Creates an X Cursor from an image resource and puts it in the cursor map. - void LoadImageCursor(int id, int resource_id) { - const SkBitmap* bitmap = - ui::ResourceBundle::GetSharedInstance().GetImageNamed( - resource_id).ToSkBitmap(); - - XcursorImage* image = ui::SkBitmapToXcursorImage(bitmap, gfx::Point(0, 0)); - cursors_[id] = ui::CreateReffedCustomXCursor(image); - // |bitmap| is owned by the resource bundle. So we do not need to free it. - } - - // A map to hold all image cursors. It maps the cursor ID to the X Cursor. - std::map<int, Cursor> cursors_; - - DISALLOW_COPY_AND_ASSIGN(ImageCursors); -}; - RootWindowHostLinux::RootWindowHostLinux(const gfx::Rect& bounds) : root_window_(NULL), xdisplay_(base::MessagePumpX::GetDefaultXDisplay()), @@ -351,8 +301,7 @@ RootWindowHostLinux::RootWindowHostLinux(const gfx::Rect& bounds) cursor_shown_(true), bounds_(bounds), focus_when_shown_(false), - pointer_barriers_(NULL), - image_cursors_(new ImageCursors) { + pointer_barriers_(NULL) { XSetWindowAttributes swa; memset(&swa, 0, sizeof(swa)); swa.background_pixmap = None; @@ -845,8 +794,6 @@ bool RootWindowHostLinux::IsWindowManagerPresent() { void RootWindowHostLinux::SetCursorInternal(gfx::NativeCursor cursor) { ::Cursor xcursor = - image_cursors_->IsImageCursor(cursor) ? - image_cursors_->ImageCursorFromNative(cursor) : cursor == ui::kCursorNone ? invisible_cursor_ : cursor == ui::kCursorCustom ? diff --git a/ui/aura/root_window_host_linux.h b/ui/aura/root_window_host_linux.h index 34484e4..ae435e9 100644 --- a/ui/aura/root_window_host_linux.h +++ b/ui/aura/root_window_host_linux.h @@ -101,9 +101,6 @@ class RootWindowHostLinux : public RootWindowHost, scoped_ptr<ui::ViewProp> prop_; - class ImageCursors; - scoped_ptr<ImageCursors> image_cursors_; - DISALLOW_COPY_AND_ASSIGN(RootWindowHostLinux); }; diff --git a/ui/base/x/x11_util.cc b/ui/base/x/x11_util.cc index a7b1bc3..5df42c0 100644 --- a/ui/base/x/x11_util.cc +++ b/ui/base/x/x11_util.cc @@ -37,8 +37,6 @@ #if defined(USE_AURA) #include <X11/Xcursor/Xcursor.h> -#include "third_party/skia/include/core/SkBitmap.h" -#include "ui/gfx/skia_util.h" #endif #if defined(TOOLKIT_GTK) @@ -413,25 +411,6 @@ void RefCustomXCursor(::Cursor cursor) { void UnrefCustomXCursor(::Cursor cursor) { XCustomCursorCache::GetInstance()->Unref(cursor); } - -XcursorImage* SkBitmapToXcursorImage(const SkBitmap* bitmap, - const gfx::Point& hotspot) { - DCHECK(bitmap->config() == SkBitmap::kARGB_8888_Config); - XcursorImage* image = XcursorImageCreate(bitmap->width(), bitmap->height()); - image->xhot = hotspot.x(); - image->yhot = hotspot.y(); - - if (bitmap->width() && bitmap->height()) { - bitmap->lockPixels(); - gfx::ConvertSkiaToRGBA( - static_cast<const unsigned char*>(bitmap->getPixels()), - bitmap->width() * bitmap->height(), - reinterpret_cast<unsigned char*>(image->pixels)); - bitmap->unlockPixels(); - } - - return image; -} #endif XID GetX11RootWindow() { diff --git a/ui/base/x/x11_util.h b/ui/base/x/x11_util.h index bf89c3b..771e8ef 100644 --- a/ui/base/x/x11_util.h +++ b/ui/base/x/x11_util.h @@ -18,7 +18,6 @@ #include "base/basictypes.h" #include "ui/base/events.h" #include "ui/base/ui_export.h" -#include "ui/gfx/point.h" typedef unsigned long Atom; typedef unsigned long XID; @@ -36,7 +35,6 @@ typedef struct _GtkWindow GtkWindow; namespace gfx { class Rect; } -class SkBitmap; namespace ui { @@ -91,11 +89,6 @@ UI_EXPORT void RefCustomXCursor(::Cursor cursor); // Decreases the refcount of the custom cursor, and destroys it if it reaches 0. UI_EXPORT void UnrefCustomXCursor(::Cursor cursor); - -// Creates a XcursorImage and copies the SkBitmap |bitmap| on it. |bitmap| -// should be non-null. Caller owns the returned object. -UI_EXPORT XcursorImage* SkBitmapToXcursorImage(const SkBitmap* bitmap, - const gfx::Point& hotspot); #endif // These functions do not cache their results -------------------------- diff --git a/ui/gfx/codec/png_codec.cc b/ui/gfx/codec/png_codec.cc index da73928..1ca139d 100644 --- a/ui/gfx/codec/png_codec.cc +++ b/ui/gfx/codec/png_codec.cc @@ -8,7 +8,6 @@ #include "base/memory/scoped_ptr.h" #include "base/string_util.h" #include "ui/gfx/size.h" -#include "ui/gfx/skia_util.h" #include "third_party/skia/include/core/SkBitmap.h" #include "third_party/skia/include/core/SkUnPreMultiply.h" #include "third_party/skia/include/core/SkColorPriv.h" @@ -77,7 +76,25 @@ void ConvertSkiatoRGB(const unsigned char* skia, int pixel_width, void ConvertSkiatoRGBA(const unsigned char* skia, int pixel_width, unsigned char* rgba, bool* is_opaque) { - gfx::ConvertSkiaToRGBA(skia, pixel_width, rgba); + int total_length = pixel_width * 4; + for (int i = 0; i < total_length; i += 4) { + const uint32_t pixel_in = *reinterpret_cast<const uint32_t*>(&skia[i]); + + // Pack the components here. + int alpha = SkGetPackedA32(pixel_in); + if (alpha != 0 && alpha != 255) { + SkColor unmultiplied = SkUnPreMultiply::PMColorToColor(pixel_in); + rgba[i + 0] = SkColorGetR(unmultiplied); + rgba[i + 1] = SkColorGetG(unmultiplied); + rgba[i + 2] = SkColorGetB(unmultiplied); + rgba[i + 3] = alpha; + } else { + rgba[i + 0] = SkGetPackedR32(pixel_in); + rgba[i + 1] = SkGetPackedG32(pixel_in); + rgba[i + 2] = SkGetPackedB32(pixel_in); + rgba[i + 3] = alpha; + } + } } } // namespace diff --git a/ui/gfx/skia_util.cc b/ui/gfx/skia_util.cc index a459cdd..bfee378 100644 --- a/ui/gfx/skia_util.cc +++ b/ui/gfx/skia_util.cc @@ -8,7 +8,6 @@ #include "third_party/skia/include/core/SkBitmap.h" #include "third_party/skia/include/core/SkColorPriv.h" #include "third_party/skia/include/core/SkShader.h" -#include "third_party/skia/include/core/SkUnPreMultiply.h" #include "third_party/skia/include/effects/SkGradientShader.h" #include "ui/gfx/rect.h" @@ -102,28 +101,4 @@ string16 RemoveAcceleratorChar(const string16& s, return accelerator_removed; } -void ConvertSkiaToRGBA(const unsigned char* skia, - int pixel_width, - unsigned char* rgba) { - int total_length = pixel_width * 4; - for (int i = 0; i < total_length; i += 4) { - const uint32_t pixel_in = *reinterpret_cast<const uint32_t*>(&skia[i]); - - // Pack the components here. - int alpha = SkGetPackedA32(pixel_in); - if (alpha != 0 && alpha != 255) { - SkColor unmultiplied = SkUnPreMultiply::PMColorToColor(pixel_in); - rgba[i + 0] = SkColorGetR(unmultiplied); - rgba[i + 1] = SkColorGetG(unmultiplied); - rgba[i + 2] = SkColorGetB(unmultiplied); - rgba[i + 3] = alpha; - } else { - rgba[i + 0] = SkGetPackedR32(pixel_in); - rgba[i + 1] = SkGetPackedG32(pixel_in); - rgba[i + 2] = SkGetPackedB32(pixel_in); - rgba[i + 3] = alpha; - } - } -} - } // namespace gfx diff --git a/ui/gfx/skia_util.h b/ui/gfx/skia_util.h index 152b731..de7b8f4 100644 --- a/ui/gfx/skia_util.h +++ b/ui/gfx/skia_util.h @@ -1,4 +1,4 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -50,11 +50,6 @@ UI_EXPORT string16 RemoveAcceleratorChar(const string16& s, int* accelerated_char_pos, int* accelerated_char_span); -// Converts Skia ARGB format pixels in |skia| to RGBA. -UI_EXPORT void ConvertSkiaToRGBA(const unsigned char* skia, - int pixel_width, - unsigned char* rgba); - } // namespace gfx #endif // UI_GFX_SKIA_UTIL_H_ diff --git a/ui/resources/ui_resources_2x.grd b/ui/resources/ui_resources_2x.grd index f5674d8..fc13cd6 100644 --- a/ui/resources/ui_resources_2x.grd +++ b/ui/resources/ui_resources_2x.grd @@ -78,8 +78,6 @@ <include name="IDR_AURA_WINDOW_SNAP_MINIMIZE_P" file="aura/window_snap_minimize_p.png" type="BINDATA" /> <include name="IDR_AURA_WINDOW_SNAP_P" file="aura/window_snap_p.png" type="BINDATA" /> <include name="IDR_AURA_WINDOW_SNAP_RIGHT_P" file="aura/window_snap_right_p.png" type="BINDATA" /> - <include name="IDR_AURA_CURSOR_NO_DROP" file="aura/left_ptr_nodrop_2x.png" type="BINDATA" /> - <include name="IDR_AURA_CURSOR_COPY" file="aura/left_ptr_copy_2x.png" type="BINDATA" /> </if> </includes> </release> diff --git a/ui/resources/ui_resources_standard.grd b/ui/resources/ui_resources_standard.grd index d63dc98..926779e 100644 --- a/ui/resources/ui_resources_standard.grd +++ b/ui/resources/ui_resources_standard.grd @@ -75,8 +75,6 @@ <include name="IDR_AURA_WINDOW_SNAP_MINIMIZE_P" file="aura/window_snap_minimize_p.png" type="BINDATA" /> <include name="IDR_AURA_WINDOW_SNAP_P" file="aura/window_snap_p.png" type="BINDATA" /> <include name="IDR_AURA_WINDOW_SNAP_RIGHT_P" file="aura/window_snap_right_p.png" type="BINDATA" /> - <include name="IDR_AURA_CURSOR_NO_DROP" file="aura/left_ptr_nodrop.png" type="BINDATA" /> - <include name="IDR_AURA_CURSOR_COPY" file="aura/left_ptr_copy.png" type="BINDATA" /> </if> </includes> </release> diff --git a/ui/resources/ui_resources_touch.grd b/ui/resources/ui_resources_touch.grd index a21b0ce..59eb2a2c 100644 --- a/ui/resources/ui_resources_touch.grd +++ b/ui/resources/ui_resources_touch.grd @@ -75,8 +75,6 @@ <include name="IDR_AURA_WINDOW_SNAP_MINIMIZE_P" file="aura/window_snap_minimize_touch_p.png" type="BINDATA" /> <include name="IDR_AURA_WINDOW_SNAP_P" file="aura/window_snap_touch_p.png" type="BINDATA" /> <include name="IDR_AURA_WINDOW_SNAP_RIGHT_P" file="aura/window_snap_right_touch_p.png" type="BINDATA" /> - <include name="IDR_AURA_CURSOR_NO_DROP" file="aura/left_ptr_nodrop.png" type="BINDATA" /> - <include name="IDR_AURA_CURSOR_COPY" file="aura/left_ptr_copy.png" type="BINDATA" /> </if> </includes> </release> @@ -491,7 +491,6 @@ ], 'link_settings': { 'libraries': [ - '-lXcursor', # For XCursor* function calls in x11_util.cc. '-lXrender', # For XRender* function calls in x11_util.cc. ], }, diff --git a/webkit/glue/webcursor_aurax11.cc b/webkit/glue/webcursor_aurax11.cc index b3f6989..fe221e2 100644 --- a/webkit/glue/webcursor_aurax11.cc +++ b/webkit/glue/webcursor_aurax11.cc @@ -10,6 +10,7 @@ #include "base/logging.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebCursorInfo.h" +#include "third_party/skia/include/core/SkUnPreMultiply.h" #include "ui/base/cursor/cursor.h" #include "ui/base/x/x11_util.h" @@ -17,13 +18,35 @@ const ui::PlatformCursor WebCursor::GetPlatformCursor() { if (platform_cursor_) return platform_cursor_; - SkBitmap bitmap; - bitmap.setConfig(SkBitmap::kARGB_8888_Config, - custom_size_.width(), custom_size_.height()); - bitmap.allocPixels(); - memcpy(bitmap.getAddr32(0, 0), custom_data_.data(), custom_data_.size()); + XcursorImage* image = + XcursorImageCreate(custom_size_.width(), custom_size_.height()); + image->xhot = hotspot_.x(); + image->yhot = hotspot_.y(); + uint32* pixels = image->pixels; + + if (custom_size_.width() && custom_size_.height()) { + SkBitmap bitmap; + bitmap.setConfig(SkBitmap::kARGB_8888_Config, + custom_size_.width(), custom_size_.height()); + bitmap.allocPixels(); + memcpy(bitmap.getAddr32(0, 0), custom_data_.data(), custom_data_.size()); + + bitmap.lockPixels(); + int height = bitmap.height(), width = bitmap.width(); + for (int y = 0, i = 0; y < height; y++) { + for (int x = 0; x < width; x++) { + uint32 pixel = bitmap.getAddr32(0, y)[x]; + int alpha = SkColorGetA(pixel); + if (alpha != 0 && alpha != 255) + pixels[i] = SkUnPreMultiply::PMColorToColor(pixel); + else + pixels[i] = pixel; + ++i; + } + } + bitmap.unlockPixels(); + } - XcursorImage* image = ui::SkBitmapToXcursorImage(&bitmap, hotspot_); platform_cursor_ = ui::CreateReffedCustomXCursor(image); return platform_cursor_; } |