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

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

Issue 2862025: Canvas refactoring part 2.... (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.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
18 static const int kTransparentAlpha = 200; 19 static const int kTransparentAlpha = 200;
(...skipping 159 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::Canvas scale_canvas(ps.width(), ps.height(), false); 189 gfx::CanvasSkia scale_canvas(ps.width(), ps.height(), false);
189 SkBitmap& bitmap_device = const_cast<SkBitmap&>( 190 SkBitmap& bitmap_device = const_cast<SkBitmap&>(
190 scale_canvas.getTopPlatformDevice().accessBitmap(true)); 191 scale_canvas.getTopPlatformDevice().accessBitmap(true));
191 bitmap_device.eraseARGB(0, 0, 0, 0); 192 bitmap_device.eraseARGB(0, 0, 0, 0);
192 193
193 scale_canvas.FillRectInt(kDraggedTabBorderColor, 0, 194 scale_canvas.FillRectInt(kDraggedTabBorderColor, 0,
194 attached_tab_size_.height() - kDragFrameBorderSize, 195 attached_tab_size_.height() - kDragFrameBorderSize,
195 ps.width(), ps.height() - attached_tab_size_.height()); 196 ps.width(), ps.height() - attached_tab_size_.height());
196 int image_x = kDragFrameBorderSize; 197 int image_x = kDragFrameBorderSize;
197 int image_y = attached_tab_size_.height(); 198 int image_y = attached_tab_size_.height();
198 int image_w = ps.width() - kTwiceDragFrameBorderSize; 199 int image_w = ps.width() - kTwiceDragFrameBorderSize;
199 int image_h = 200 int image_h =
200 ps.height() - kTwiceDragFrameBorderSize - attached_tab_size_.height(); 201 ps.height() - kTwiceDragFrameBorderSize - attached_tab_size_.height();
201 scale_canvas.FillRectInt(SK_ColorBLACK, image_x, image_y, image_w, image_h); 202 scale_canvas.FillRectInt(SK_ColorBLACK, image_x, image_y, image_w, image_h);
202 photobooth_->PaintScreenshotIntoCanvas( 203 photobooth_->PaintScreenshotIntoCanvas(
203 &scale_canvas, 204 scale_canvas.AsCanvas(),
204 gfx::Rect(image_x, image_y, image_w, image_h)); 205 gfx::Rect(image_x, image_y, image_w, image_h));
205 renderer_->ProcessPaint(&scale_canvas); 206 renderer_->ProcessPaint(scale_canvas.AsCanvas());
206 207
207 SkIRect subset; 208 SkIRect subset;
208 subset.set(0, 0, ps.width(), ps.height()); 209 subset.set(0, 0, ps.width(), ps.height());
209 SkBitmap mipmap = scale_canvas.ExtractBitmap(); 210 SkBitmap mipmap = scale_canvas.ExtractBitmap();
210 mipmap.buildMipMap(true); 211 mipmap.buildMipMap(true);
211 212
212 SkShader* bitmap_shader = 213 SkShader* bitmap_shader =
213 SkShader::CreateBitmapShader(mipmap, SkShader::kClamp_TileMode, 214 SkShader::CreateBitmapShader(mipmap, SkShader::kClamp_TileMode,
214 SkShader::kClamp_TileMode); 215 SkShader::kClamp_TileMode);
215 216
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
247 #else 248 #else
248 gfx::Rect bounds; 249 gfx::Rect bounds;
249 container_->GetBounds(&bounds, true); 250 container_->GetBounds(&bounds, true);
250 container_->SetBounds(gfx::Rect(bounds.x(), bounds.y(), w, h)); 251 container_->SetBounds(gfx::Rect(bounds.x(), bounds.y(), w, h));
251 #endif 252 #endif
252 } 253 }
253 254
254 int DraggedTabView::ScaleValue(int value) { 255 int DraggedTabView::ScaleValue(int value) {
255 return attached_ ? value : static_cast<int>(value * kScalingFactor); 256 return attached_ ? value : static_cast<int>(value * kScalingFactor);
256 } 257 }
OLDNEW
« no previous file with comments | « chrome/browser/views/tab_contents/tab_contents_view_win.cc ('k') | chrome/browser/views/tabs/tab.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698