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

Side by Side Diff: chrome/browser/renderer_host/backing_store_x.cc

Issue 144006: Add Linux support for getting the thumbnail and wire into the switcher. (Closed)
Patch Set: For checkin Created 11 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
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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/renderer_host/backing_store.h" 5 #include "chrome/browser/renderer_host/backing_store.h"
6 6
7 #include <stdlib.h> 7 #include <stdlib.h>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/compiler_specific.h" 10 #include "base/compiler_specific.h"
(...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after
306 306
307 PaintRect(process, bitmap, bitmap_rect); 307 PaintRect(process, bitmap, bitmap_rect);
308 } 308 }
309 309
310 void BackingStore::ShowRect(const gfx::Rect& rect, XID target) { 310 void BackingStore::ShowRect(const gfx::Rect& rect, XID target) {
311 XCopyArea(display_, pixmap_, target, static_cast<GC>(pixmap_gc_), 311 XCopyArea(display_, pixmap_, target, static_cast<GC>(pixmap_gc_),
312 rect.x(), rect.y(), rect.width(), rect.height(), 312 rect.x(), rect.y(), rect.width(), rect.height(),
313 rect.x(), rect.y()); 313 rect.x(), rect.y());
314 } 314 }
315 315
316 SkBitmap* BackingStore::PaintRectToBitmap(const gfx::Rect& rect) { 316 SkBitmap BackingStore::PaintRectToBitmap(const gfx::Rect& rect) {
317 static const int kBytesPerPixel = 4; 317 static const int kBytesPerPixel = 4;
318 318
319 const int width = rect.width(); 319 const int width = rect.width();
320 const int height = rect.height(); 320 const int height = rect.height();
321 XImage* image = XGetImage(display_, pixmap_, 321 XImage* image = XGetImage(display_, pixmap_,
322 rect.x(), rect.y(), 322 rect.x(), rect.y(),
323 width, height, 323 width, height,
324 AllPlanes, ZPixmap); 324 AllPlanes, ZPixmap);
325
326 SkBitmap bitmap;
327
325 // TODO(jhawkins): Need to convert the image data if the image bits per pixel 328 // TODO(jhawkins): Need to convert the image data if the image bits per pixel
326 // is not 32. 329 // is not 32.
327 if (image->bits_per_pixel != 32) { 330 if (image->bits_per_pixel != 32) {
328 XFree(image); 331 XFree(image);
329 return NULL; 332 return bitmap; // Return the empty bitmap to indicate failure.
330 } 333 }
331 334
332 SkBitmap* bitmap = new SkBitmap(); 335 bitmap.setConfig(SkBitmap::kARGB_8888_Config, width, height);
333 bitmap->setConfig(SkBitmap::kARGB_8888_Config, width, height); 336 bitmap.allocPixels();
334 bitmap->allocPixels();
335 unsigned char* bitmap_data = 337 unsigned char* bitmap_data =
336 reinterpret_cast<unsigned char*>(bitmap->getAddr32(0, 0)); 338 reinterpret_cast<unsigned char*>(bitmap.getAddr32(0, 0));
337 memcpy(bitmap_data, image->data, width * height * kBytesPerPixel); 339 memcpy(bitmap_data, image->data, width * height * kBytesPerPixel);
338 340
339 XFree(image); 341 XFree(image);
340 return bitmap; 342 return bitmap;
341 } 343 }
OLDNEW
« no previous file with comments | « chrome/browser/renderer_host/backing_store.h ('k') | chrome/browser/tab_contents/thumbnail_generator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698