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 "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.h" | 7 #include "base/stl_util.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.h" | 10 #include "ui/gfx/canvas.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::Canvas scale_canvas(ps, false); | 136 // TODO(pkotwicz): DIP enable this class. |
| 137 gfx::Canvas scale_canvas(ps, ui::SCALE_FACTOR_100P, false); |
137 SkBitmap& bitmap_device = const_cast<SkBitmap&>( | 138 SkBitmap& bitmap_device = const_cast<SkBitmap&>( |
138 skia::GetTopDevice(*scale_canvas.sk_canvas())->accessBitmap(true)); | 139 skia::GetTopDevice(*scale_canvas.sk_canvas())->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.FillRect(gfx::Rect(0, tab_height - kDragFrameBorderSize, | 143 scale_canvas.FillRect(gfx::Rect(0, tab_height - kDragFrameBorderSize, |
143 ps.width(), ps.height() - tab_height), | 144 ps.width(), ps.height() - tab_height), |
144 kDraggedTabBorderColor); | 145 kDraggedTabBorderColor); |
145 gfx::Rect image_rect(kDragFrameBorderSize, | 146 gfx::Rect image_rect(kDragFrameBorderSize, |
146 tab_height, | 147 tab_height, |
147 ps.width() - kTwiceDragFrameBorderSize, | 148 ps.width() - kTwiceDragFrameBorderSize, |
148 contents_size_.height()); | 149 contents_size_.height()); |
149 scale_canvas.FillRect(image_rect, SK_ColorBLACK); | 150 scale_canvas.FillRect(image_rect, SK_ColorBLACK); |
150 photobooth_->PaintScreenshotIntoCanvas(&scale_canvas, image_rect); | 151 photobooth_->PaintScreenshotIntoCanvas(&scale_canvas, image_rect); |
151 for (size_t i = 0; i < renderers_.size(); ++i) | 152 for (size_t i = 0; i < renderers_.size(); ++i) |
152 renderers_[i]->Paint(&scale_canvas); | 153 renderers_[i]->Paint(&scale_canvas); |
153 | 154 |
154 SkIRect subset; | 155 SkIRect subset; |
155 subset.set(0, 0, ps.width(), ps.height()); | 156 subset.set(0, 0, ps.width(), ps.height()); |
156 SkBitmap mipmap = scale_canvas.ExtractBitmap(); | 157 SkBitmap mipmap = scale_canvas.ExtractImageRep().sk_bitmap(); |
157 mipmap.buildMipMap(true); | 158 mipmap.buildMipMap(true); |
158 | 159 |
159 SkShader* bitmap_shader = | 160 SkShader* bitmap_shader = |
160 SkShader::CreateBitmapShader(mipmap, SkShader::kClamp_TileMode, | 161 SkShader::CreateBitmapShader(mipmap, SkShader::kClamp_TileMode, |
161 SkShader::kClamp_TileMode); | 162 SkShader::kClamp_TileMode); |
162 | 163 |
163 SkMatrix shader_scale; | 164 SkMatrix shader_scale; |
164 shader_scale.setScale(kScalingFactor, kScalingFactor); | 165 shader_scale.setScale(kScalingFactor, kScalingFactor); |
165 bitmap_shader->setLocalMatrix(shader_scale); | 166 bitmap_shader->setLocalMatrix(shader_scale); |
166 | 167 |
(...skipping 19 matching lines...) Expand all Loading... |
186 } | 187 } |
187 | 188 |
188 gfx::Size DraggedTabView::PreferredContainerSize() { | 189 gfx::Size DraggedTabView::PreferredContainerSize() { |
189 gfx::Size ps = GetPreferredSize(); | 190 gfx::Size ps = GetPreferredSize(); |
190 return gfx::Size(ScaleValue(ps.width()), ScaleValue(ps.height())); | 191 return gfx::Size(ScaleValue(ps.width()), ScaleValue(ps.height())); |
191 } | 192 } |
192 | 193 |
193 int DraggedTabView::ScaleValue(int value) { | 194 int DraggedTabView::ScaleValue(int value) { |
194 return static_cast<int>(value * kScalingFactor); | 195 return static_cast<int>(value * kScalingFactor); |
195 } | 196 } |
OLD | NEW |