Commit dd8429c2 authored by pkotwicz@chromium.org's avatar pkotwicz@chromium.org

Fix a couple of bugs with the image skia implementation

Bug=124566
Test=Manual

Review URL: https://chromiumcodereview.appspot.com/10389109

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@137622 0039d316-1c4b-4281-b951-d872f2087c98
parent 44de6072
......@@ -25,6 +25,7 @@
#include "ui/gfx/codec/jpeg_codec.h"
#include "ui/gfx/codec/png_codec.h"
#include "ui/gfx/image/image_skia.h"
#include "ui/gfx/screen.h"
namespace ui {
......@@ -236,11 +237,11 @@ gfx::Image& ResourceBundle::GetImageNamed(int resource_id) {
for (size_t i = 0; i < data_packs_.size(); ++i) {
scoped_ptr<SkBitmap> bitmap(LoadBitmap(*data_packs_[i], resource_id));
if (bitmap.get()) {
#if defined(ENABLE_DIP)
image_skia.AddBitmapForScale(*bitmap, data_packs_[i]->GetScaleFactor());
#else
image_skia.AddBitmapForScale(*bitmap, 1.0f);
#endif
if (gfx::Screen::IsDIPEnabled())
image_skia.AddBitmapForScale(*bitmap,
data_packs_[i]->GetScaleFactor());
else
image_skia.AddBitmapForScale(*bitmap, 1.0f);
}
}
......
......@@ -91,15 +91,10 @@ void ImageSkia::AddBitmapForScale(const SkBitmap& bitmap,
if (isNull()) {
Init(bitmap, dip_scale_factor);
} else {
// We currently assume that the bitmap size = 1x size * |dip_scale_factor|.
// TODO(pkotwicz): Do something better because of rounding errors when
// |dip_scale_factor| is not an int.
// TODO(pkotwicz): Remove DCHECK for dip_scale_factor == 1.0f once
// image_loading_tracker correctly handles multiple sized images.
DCHECK(dip_scale_factor == 1.0f ||
static_cast<int>(width() * dip_scale_factor) == bitmap.width());
DCHECK(dip_scale_factor == 1.0f ||
static_cast<int>(height() * dip_scale_factor) == bitmap.height());
// Currently data packs include 1x scale images whenever a different scale
// image is unavailable. As |dip_scale_factor| is derived from the data
// pack, sometimes |dip_scale_factor| is incorrect.
// TODO(pkotwicz): Fix this and add DCHECK.
storage_->AddBitmap(bitmap);
}
}
......
......@@ -28,6 +28,9 @@ class UI_EXPORT Screen {
static void SetInstance(ScreenImpl* screen);
#endif
// True if DIP is enabled.
static bool IsDIPEnabled();
// Returns the current absolute position of the mouse pointer.
static gfx::Point GetCursorScreenPoint();
......
......@@ -9,6 +9,11 @@
namespace gfx {
// static
bool Screen::IsDIPEnabled() {
return false;
}
// static
gfx::Monitor Screen::GetPrimaryMonitor() {
NOTIMPLEMENTED() << "crbug.com/117839 tracks implementation";
......
......@@ -5,6 +5,7 @@
#include "ui/gfx/screen.h"
#include "base/logging.h"
#include "ui/compositor/dip_util.h"
#include "ui/gfx/monitor.h"
#include "ui/gfx/native_widget_types.h"
#include "ui/gfx/screen_impl.h"
......@@ -26,6 +27,11 @@ void Screen::SetInstance(ScreenImpl* screen) {
// TODO(oshima): Implement ScreenImpl for Linux/aura and remove this
// ifdef.
// static
bool Screen::IsDIPEnabled() {
return ui::IsDIPEnabled();
}
// static
Point Screen::GetCursorScreenPoint() {
return g_instance_->GetCursorScreenPoint();
......
......@@ -75,6 +75,11 @@ gfx::Rect GetMonitorAreaNearestWindow(gfx::NativeView view) {
namespace gfx {
// static
bool Screen::IsDIPEnabled() {
return false;
}
// static
gfx::Point Screen::GetCursorScreenPoint() {
gint x, y;
......
......@@ -74,6 +74,11 @@ gfx::Monitor GetMonitorForScreen(NSScreen* screen, bool is_primary) {
namespace gfx {
// static
bool Screen::IsDIPEnabled() {
return false;
}
// static
gfx::Point Screen::GetCursorScreenPoint() {
NSPoint mouseLocation = [NSEvent mouseLocation];
......
......@@ -29,6 +29,11 @@ gfx::Monitor GetMonitor(MONITORINFO& monitor_info) {
namespace gfx {
// static
bool Screen::IsDIPEnabled() {
return false;
}
// static
gfx::Point Screen::GetCursorScreenPoint() {
POINT pt;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment