| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "ash/drag_drop/drag_image_view.h" | 5 #include "ash/drag_drop/drag_image_view.h" |
| 6 | 6 |
| 7 #include "skia/ext/image_operations.h" | 7 #include "skia/ext/image_operations.h" |
| 8 #include "ui/aura/window.h" | 8 #include "ui/aura/window.h" |
| 9 #include "ui/compositor/dip_util.h" | 9 #include "ui/compositor/dip_util.h" |
| 10 #include "ui/gfx/canvas.h" | 10 #include "ui/gfx/canvas.h" |
| 11 #include "ui/gfx/size_conversions.h" | 11 #include "ui/gfx/size_conversions.h" |
| 12 #include "ui/views/corewm/shadow_types.h" | 12 #include "ui/views/corewm/shadow_types.h" |
| 13 #include "ui/views/widget/widget.h" | 13 #include "ui/views/widget/widget.h" |
| 14 | 14 |
| 15 namespace ash { | 15 namespace ash { |
| 16 namespace internal { | 16 namespace internal { |
| 17 | 17 |
| 18 namespace { | 18 namespace { |
| 19 using views::Widget; | 19 using views::Widget; |
| 20 | 20 |
| 21 Widget* CreateDragWidget() { | 21 Widget* CreateDragWidget(gfx::NativeView context) { |
| 22 Widget* drag_widget = new Widget; | 22 Widget* drag_widget = new Widget; |
| 23 Widget::InitParams params; | 23 Widget::InitParams params; |
| 24 params.type = Widget::InitParams::TYPE_TOOLTIP; | 24 params.type = Widget::InitParams::TYPE_TOOLTIP; |
| 25 params.keep_on_top = true; | 25 params.keep_on_top = true; |
| 26 params.context = context; |
| 26 params.accept_events = false; | 27 params.accept_events = false; |
| 27 params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; | 28 params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; |
| 28 params.transparent = true; | 29 params.transparent = true; |
| 29 drag_widget->Init(params); | 30 drag_widget->Init(params); |
| 30 drag_widget->SetOpacity(0xFF); | 31 drag_widget->SetOpacity(0xFF); |
| 31 drag_widget->GetNativeWindow()->set_owned_by_parent(false); | 32 drag_widget->GetNativeWindow()->set_owned_by_parent(false); |
| 32 SetShadowType(drag_widget->GetNativeView(), views::corewm::SHADOW_TYPE_NONE); | 33 SetShadowType(drag_widget->GetNativeView(), views::corewm::SHADOW_TYPE_NONE); |
| 33 return drag_widget; | 34 return drag_widget; |
| 34 } | 35 } |
| 35 } | 36 } |
| 36 | 37 |
| 37 DragImageView::DragImageView() : views::ImageView() { | 38 DragImageView::DragImageView(gfx::NativeView context) : views::ImageView() { |
| 38 widget_.reset(CreateDragWidget()); | 39 widget_.reset(CreateDragWidget(context)); |
| 39 widget_->SetContentsView(this); | 40 widget_->SetContentsView(this); |
| 40 widget_->SetAlwaysOnTop(true); | 41 widget_->SetAlwaysOnTop(true); |
| 41 | 42 |
| 42 // We are owned by the DragDropController. | 43 // We are owned by the DragDropController. |
| 43 set_owned_by_client(); | 44 set_owned_by_client(); |
| 44 } | 45 } |
| 45 | 46 |
| 46 DragImageView::~DragImageView() { | 47 DragImageView::~DragImageView() { |
| 47 widget_->Hide(); | 48 widget_->Hide(); |
| 48 } | 49 } |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 92 SkBitmap scaled = skia::ImageOperations::Resize( | 93 SkBitmap scaled = skia::ImageOperations::Resize( |
| 93 image_rep.sk_bitmap(), skia::ImageOperations::RESIZE_LANCZOS3, | 94 image_rep.sk_bitmap(), skia::ImageOperations::RESIZE_LANCZOS3, |
| 94 scaled_widget_size.width(), scaled_widget_size.height()); | 95 scaled_widget_size.width(), scaled_widget_size.height()); |
| 95 gfx::ImageSkia image_skia(gfx::ImageSkiaRep(scaled, device_scale_factor)); | 96 gfx::ImageSkia image_skia(gfx::ImageSkiaRep(scaled, device_scale_factor)); |
| 96 canvas->DrawImageInt(image_skia, 0, 0); | 97 canvas->DrawImageInt(image_skia, 0, 0); |
| 97 } | 98 } |
| 98 } | 99 } |
| 99 | 100 |
| 100 } // namespace internal | 101 } // namespace internal |
| 101 } // namespace ash | 102 } // namespace ash |
| OLD | NEW |