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

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

Issue 2825018: 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"
9 #include "gfx/canvas_skia.h" 8 #include "gfx/canvas_skia.h"
10 #include "third_party/skia/include/core/SkShader.h" 9 #include "third_party/skia/include/core/SkShader.h"
11 #include "views/widget/widget.h" 10 #include "views/widget/widget.h"
12 11
13 #if defined(OS_WIN) 12 #if defined(OS_WIN)
14 #include "views/widget/widget_win.h" 13 #include "views/widget/widget_win.h"
15 #elif defined(OS_LINUX) 14 #elif defined(OS_LINUX)
16 #include "views/widget/widget_gtk.h" 15 #include "views/widget/widget_gtk.h"
17 #endif 16 #endif
18 17
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
179 178
180 //////////////////////////////////////////////////////////////////////////////// 179 ////////////////////////////////////////////////////////////////////////////////
181 // DraggedTabView, private: 180 // DraggedTabView, private:
182 181
183 void DraggedTabView::PaintAttachedTab(gfx::Canvas* canvas) { 182 void DraggedTabView::PaintAttachedTab(gfx::Canvas* canvas) {
184 renderer_->ProcessPaint(canvas); 183 renderer_->ProcessPaint(canvas);
185 } 184 }
186 185
187 void DraggedTabView::PaintDetachedView(gfx::Canvas* canvas) { 186 void DraggedTabView::PaintDetachedView(gfx::Canvas* canvas) {
188 gfx::Size ps = GetPreferredSize(); 187 gfx::Size ps = GetPreferredSize();
189 // TODO(beng): Convert to CanvasSkia 188 gfx::CanvasSkia scale_canvas(ps.width(), ps.height(), false);
190 gfx::Canvas scale_canvas(ps.width(), ps.height(), false);
191 SkBitmap& bitmap_device = const_cast<SkBitmap&>( 189 SkBitmap& bitmap_device = const_cast<SkBitmap&>(
192 scale_canvas.getTopPlatformDevice().accessBitmap(true)); 190 scale_canvas.getTopPlatformDevice().accessBitmap(true));
193 bitmap_device.eraseARGB(0, 0, 0, 0); 191 bitmap_device.eraseARGB(0, 0, 0, 0);
194 192
195 scale_canvas.FillRectInt(kDraggedTabBorderColor, 0, 193 scale_canvas.FillRectInt(kDraggedTabBorderColor, 0,
196 attached_tab_size_.height() - kDragFrameBorderSize, 194 attached_tab_size_.height() - kDragFrameBorderSize,
197 ps.width(), ps.height() - attached_tab_size_.height()); 195 ps.width(), ps.height() - attached_tab_size_.height());
198 int image_x = kDragFrameBorderSize; 196 int image_x = kDragFrameBorderSize;
199 int image_y = attached_tab_size_.height(); 197 int image_y = attached_tab_size_.height();
200 int image_w = ps.width() - kTwiceDragFrameBorderSize; 198 int image_w = ps.width() - kTwiceDragFrameBorderSize;
(...skipping 21 matching lines...) Expand all
222 SkPaint paint; 220 SkPaint paint;
223 paint.setShader(bitmap_shader); 221 paint.setShader(bitmap_shader);
224 paint.setAntiAlias(true); 222 paint.setAntiAlias(true);
225 bitmap_shader->unref(); 223 bitmap_shader->unref();
226 224
227 SkRect rc; 225 SkRect rc;
228 rc.fLeft = 0; 226 rc.fLeft = 0;
229 rc.fTop = 0; 227 rc.fTop = 0;
230 rc.fRight = SkIntToScalar(ps.width()); 228 rc.fRight = SkIntToScalar(ps.width());
231 rc.fBottom = SkIntToScalar(ps.height()); 229 rc.fBottom = SkIntToScalar(ps.height());
232 canvas->drawRect(rc, paint); 230 canvas->AsCanvasSkia()->drawRect(rc, paint);
233 } 231 }
234 232
235 void DraggedTabView::PaintFocusRect(gfx::Canvas* canvas) { 233 void DraggedTabView::PaintFocusRect(gfx::Canvas* canvas) {
236 gfx::Size ps = GetPreferredSize(); 234 gfx::Size ps = GetPreferredSize();
237 canvas->DrawFocusRect(0, 0, 235 canvas->DrawFocusRect(0, 0,
238 static_cast<int>(ps.width() * kScalingFactor), 236 static_cast<int>(ps.width() * kScalingFactor),
239 static_cast<int>(ps.height() * kScalingFactor)); 237 static_cast<int>(ps.height() * kScalingFactor));
240 } 238 }
241 239
242 void DraggedTabView::ResizeContainer() { 240 void DraggedTabView::ResizeContainer() {
243 gfx::Size ps = GetPreferredSize(); 241 gfx::Size ps = GetPreferredSize();
244 int w = ScaleValue(ps.width()); 242 int w = ScaleValue(ps.width());
245 int h = ScaleValue(ps.height()); 243 int h = ScaleValue(ps.height());
246 #if defined(OS_WIN) 244 #if defined(OS_WIN)
247 SetWindowPos(container_->GetNativeView(), HWND_TOPMOST, 0, 0, w, h, 245 SetWindowPos(container_->GetNativeView(), HWND_TOPMOST, 0, 0, w, h,
248 SWP_NOMOVE | SWP_NOZORDER | SWP_NOACTIVATE); 246 SWP_NOMOVE | SWP_NOZORDER | SWP_NOACTIVATE);
249 #else 247 #else
250 gfx::Rect bounds; 248 gfx::Rect bounds;
251 container_->GetBounds(&bounds, true); 249 container_->GetBounds(&bounds, true);
252 container_->SetBounds(gfx::Rect(bounds.x(), bounds.y(), w, h)); 250 container_->SetBounds(gfx::Rect(bounds.x(), bounds.y(), w, h));
253 #endif 251 #endif
254 } 252 }
255 253
256 int DraggedTabView::ScaleValue(int value) { 254 int DraggedTabView::ScaleValue(int value) {
257 return attached_ ? value : static_cast<int>(value * kScalingFactor); 255 return attached_ ? value : static_cast<int>(value * kScalingFactor);
258 } 256 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698