| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "chrome/browser/ui/views/tabs/dragged_tab_view.h" | 5 #include "chrome/browser/ui/views/tabs/dragged_tab_view.h" |
| 6 | 6 |
| 7 #include "base/stl_util-inl.h" | 7 #include "base/stl_util-inl.h" |
| 8 #include "chrome/browser/ui/views/tabs/native_view_photobooth.h" | 8 #include "chrome/browser/ui/views/tabs/native_view_photobooth.h" |
| 9 #include "third_party/skia/include/core/SkShader.h" | 9 #include "third_party/skia/include/core/SkShader.h" |
| 10 #include "ui/gfx/canvas_skia.h" | 10 #include "ui/gfx/canvas_skia.h" |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 126 int height = renderer_bounds_.back().height() + kDragFrameBorderSize + | 126 int height = renderer_bounds_.back().height() + kDragFrameBorderSize + |
| 127 contents_size_.height(); | 127 contents_size_.height(); |
| 128 return gfx::Size(width, height); | 128 return gfx::Size(width, height); |
| 129 } | 129 } |
| 130 | 130 |
| 131 //////////////////////////////////////////////////////////////////////////////// | 131 //////////////////////////////////////////////////////////////////////////////// |
| 132 // DraggedTabView, private: | 132 // DraggedTabView, private: |
| 133 | 133 |
| 134 void DraggedTabView::PaintDetachedView(gfx::Canvas* canvas) { | 134 void DraggedTabView::PaintDetachedView(gfx::Canvas* canvas) { |
| 135 gfx::Size ps = GetPreferredSize(); | 135 gfx::Size ps = GetPreferredSize(); |
| 136 gfx::CanvasSkia scale_canvas(ps.width(), ps.height(), false); | 136 gfx::CanvasSkia scale_canvas; |
| 137 scale_canvas.Init(ps.width(), ps.height(), false); |
| 137 SkBitmap& bitmap_device = const_cast<SkBitmap&>( | 138 SkBitmap& bitmap_device = const_cast<SkBitmap&>( |
| 138 scale_canvas.getTopPlatformDevice().accessBitmap(true)); | 139 scale_canvas.skia_canvas()->getTopDevice()->accessBitmap(true)); |
| 139 bitmap_device.eraseARGB(0, 0, 0, 0); | 140 bitmap_device.eraseARGB(0, 0, 0, 0); |
| 140 | 141 |
| 141 int tab_height = renderer_bounds_.back().height(); | 142 int tab_height = renderer_bounds_.back().height(); |
| 142 scale_canvas.FillRectInt(kDraggedTabBorderColor, 0, | 143 scale_canvas.FillRectInt(kDraggedTabBorderColor, 0, |
| 143 tab_height - kDragFrameBorderSize, | 144 tab_height - kDragFrameBorderSize, |
| 144 ps.width(), ps.height() - tab_height); | 145 ps.width(), ps.height() - tab_height); |
| 145 int image_x = kDragFrameBorderSize; | 146 int image_x = kDragFrameBorderSize; |
| 146 int image_y = tab_height; | 147 int image_y = tab_height; |
| 147 int image_w = ps.width() - kTwiceDragFrameBorderSize; | 148 int image_w = ps.width() - kTwiceDragFrameBorderSize; |
| 148 int image_h = contents_size_.height(); | 149 int image_h = contents_size_.height(); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 169 SkPaint paint; | 170 SkPaint paint; |
| 170 paint.setShader(bitmap_shader); | 171 paint.setShader(bitmap_shader); |
| 171 paint.setAntiAlias(true); | 172 paint.setAntiAlias(true); |
| 172 bitmap_shader->unref(); | 173 bitmap_shader->unref(); |
| 173 | 174 |
| 174 SkRect rc; | 175 SkRect rc; |
| 175 rc.fLeft = 0; | 176 rc.fLeft = 0; |
| 176 rc.fTop = 0; | 177 rc.fTop = 0; |
| 177 rc.fRight = SkIntToScalar(ps.width()); | 178 rc.fRight = SkIntToScalar(ps.width()); |
| 178 rc.fBottom = SkIntToScalar(ps.height()); | 179 rc.fBottom = SkIntToScalar(ps.height()); |
| 179 canvas->AsCanvasSkia()->drawRect(rc, paint); | 180 canvas->AsCanvasSkia()->skia_canvas()->drawRect(rc, paint); |
| 180 } | 181 } |
| 181 | 182 |
| 182 void DraggedTabView::PaintFocusRect(gfx::Canvas* canvas) { | 183 void DraggedTabView::PaintFocusRect(gfx::Canvas* canvas) { |
| 183 gfx::Size ps = GetPreferredSize(); | 184 gfx::Size ps = GetPreferredSize(); |
| 184 canvas->DrawFocusRect(0, 0, | 185 canvas->DrawFocusRect(0, 0, |
| 185 static_cast<int>(ps.width() * kScalingFactor), | 186 static_cast<int>(ps.width() * kScalingFactor), |
| 186 static_cast<int>(ps.height() * kScalingFactor)); | 187 static_cast<int>(ps.height() * kScalingFactor)); |
| 187 } | 188 } |
| 188 | 189 |
| 189 gfx::Size DraggedTabView::PreferredContainerSize() { | 190 gfx::Size DraggedTabView::PreferredContainerSize() { |
| 190 gfx::Size ps = GetPreferredSize(); | 191 gfx::Size ps = GetPreferredSize(); |
| 191 return gfx::Size(ScaleValue(ps.width()), ScaleValue(ps.height())); | 192 return gfx::Size(ScaleValue(ps.width()), ScaleValue(ps.height())); |
| 192 } | 193 } |
| 193 | 194 |
| 194 int DraggedTabView::ScaleValue(int value) { | 195 int DraggedTabView::ScaleValue(int value) { |
| 195 return static_cast<int>(value * kScalingFactor); | 196 return static_cast<int>(value * kScalingFactor); |
| 196 } | 197 } |
| OLD | NEW |