Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(717)

Side by Side Diff: chrome/browser/views/tabs/dragged_tab_view.cc

Issue 2811032: Revert 50784 - Canvas refactoring part 3.... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 10 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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/views/tabs/dragged_tab_view.h" 5 #include "chrome/browser/views/tabs/dragged_tab_view.h"
6 6
7 #include "chrome/browser/views/tabs/native_view_photobooth.h" 7 #include "chrome/browser/views/tabs/native_view_photobooth.h"
8 #include "gfx/canvas.h"
8 #include "gfx/canvas_skia.h" 9 #include "gfx/canvas_skia.h"
9 #include "third_party/skia/include/core/SkShader.h" 10 #include "third_party/skia/include/core/SkShader.h"
10 #include "views/widget/widget.h" 11 #include "views/widget/widget.h"
11 12
12 #if defined(OS_WIN) 13 #if defined(OS_WIN)
13 #include "views/widget/widget_win.h" 14 #include "views/widget/widget_win.h"
14 #elif defined(OS_LINUX) 15 #elif defined(OS_LINUX)
15 #include "views/widget/widget_gtk.h" 16 #include "views/widget/widget_gtk.h"
16 #endif 17 #endif
17 18
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
178 179
179 //////////////////////////////////////////////////////////////////////////////// 180 ////////////////////////////////////////////////////////////////////////////////
180 // DraggedTabView, private: 181 // DraggedTabView, private:
181 182
182 void DraggedTabView::PaintAttachedTab(gfx::Canvas* canvas) { 183 void DraggedTabView::PaintAttachedTab(gfx::Canvas* canvas) {
183 renderer_->ProcessPaint(canvas); 184 renderer_->ProcessPaint(canvas);
184 } 185 }
185 186
186 void DraggedTabView::PaintDetachedView(gfx::Canvas* canvas) { 187 void DraggedTabView::PaintDetachedView(gfx::Canvas* canvas) {
187 gfx::Size ps = GetPreferredSize(); 188 gfx::Size ps = GetPreferredSize();
188 gfx::CanvasSkia scale_canvas(ps.width(), ps.height(), false); 189 // TODO(beng): Convert to CanvasSkia
190 gfx::Canvas scale_canvas(ps.width(), ps.height(), false);
189 SkBitmap& bitmap_device = const_cast<SkBitmap&>( 191 SkBitmap& bitmap_device = const_cast<SkBitmap&>(
190 scale_canvas.getTopPlatformDevice().accessBitmap(true)); 192 scale_canvas.getTopPlatformDevice().accessBitmap(true));
191 bitmap_device.eraseARGB(0, 0, 0, 0); 193 bitmap_device.eraseARGB(0, 0, 0, 0);
192 194
193 scale_canvas.FillRectInt(kDraggedTabBorderColor, 0, 195 scale_canvas.FillRectInt(kDraggedTabBorderColor, 0,
194 attached_tab_size_.height() - kDragFrameBorderSize, 196 attached_tab_size_.height() - kDragFrameBorderSize,
195 ps.width(), ps.height() - attached_tab_size_.height()); 197 ps.width(), ps.height() - attached_tab_size_.height());
196 int image_x = kDragFrameBorderSize; 198 int image_x = kDragFrameBorderSize;
197 int image_y = attached_tab_size_.height(); 199 int image_y = attached_tab_size_.height();
198 int image_w = ps.width() - kTwiceDragFrameBorderSize; 200 int image_w = ps.width() - kTwiceDragFrameBorderSize;
(...skipping 21 matching lines...) Expand all
220 SkPaint paint; 222 SkPaint paint;
221 paint.setShader(bitmap_shader); 223 paint.setShader(bitmap_shader);
222 paint.setAntiAlias(true); 224 paint.setAntiAlias(true);
223 bitmap_shader->unref(); 225 bitmap_shader->unref();
224 226
225 SkRect rc; 227 SkRect rc;
226 rc.fLeft = 0; 228 rc.fLeft = 0;
227 rc.fTop = 0; 229 rc.fTop = 0;
228 rc.fRight = SkIntToScalar(ps.width()); 230 rc.fRight = SkIntToScalar(ps.width());
229 rc.fBottom = SkIntToScalar(ps.height()); 231 rc.fBottom = SkIntToScalar(ps.height());
230 canvas->AsCanvasSkia()->drawRect(rc, paint); 232 canvas->drawRect(rc, paint);
231 } 233 }
232 234
233 void DraggedTabView::PaintFocusRect(gfx::Canvas* canvas) { 235 void DraggedTabView::PaintFocusRect(gfx::Canvas* canvas) {
234 gfx::Size ps = GetPreferredSize(); 236 gfx::Size ps = GetPreferredSize();
235 canvas->DrawFocusRect(0, 0, 237 canvas->DrawFocusRect(0, 0,
236 static_cast<int>(ps.width() * kScalingFactor), 238 static_cast<int>(ps.width() * kScalingFactor),
237 static_cast<int>(ps.height() * kScalingFactor)); 239 static_cast<int>(ps.height() * kScalingFactor));
238 } 240 }
239 241
240 void DraggedTabView::ResizeContainer() { 242 void DraggedTabView::ResizeContainer() {
241 gfx::Size ps = GetPreferredSize(); 243 gfx::Size ps = GetPreferredSize();
242 int w = ScaleValue(ps.width()); 244 int w = ScaleValue(ps.width());
243 int h = ScaleValue(ps.height()); 245 int h = ScaleValue(ps.height());
244 #if defined(OS_WIN) 246 #if defined(OS_WIN)
245 SetWindowPos(container_->GetNativeView(), HWND_TOPMOST, 0, 0, w, h, 247 SetWindowPos(container_->GetNativeView(), HWND_TOPMOST, 0, 0, w, h,
246 SWP_NOMOVE | SWP_NOZORDER | SWP_NOACTIVATE); 248 SWP_NOMOVE | SWP_NOZORDER | SWP_NOACTIVATE);
247 #else 249 #else
248 gfx::Rect bounds; 250 gfx::Rect bounds;
249 container_->GetBounds(&bounds, true); 251 container_->GetBounds(&bounds, true);
250 container_->SetBounds(gfx::Rect(bounds.x(), bounds.y(), w, h)); 252 container_->SetBounds(gfx::Rect(bounds.x(), bounds.y(), w, h));
251 #endif 253 #endif
252 } 254 }
253 255
254 int DraggedTabView::ScaleValue(int value) { 256 int DraggedTabView::ScaleValue(int value) {
255 return attached_ ? value : static_cast<int>(value * kScalingFactor); 257 return attached_ ? value : static_cast<int>(value * kScalingFactor);
256 } 258 }
OLDNEW
« no previous file with comments | « chrome/browser/views/tabs/dragged_tab_controller.cc ('k') | chrome/browser/views/tabs/native_view_photobooth_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698