Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 70 BackingStore::~BackingStore() { | 70 BackingStore::~BackingStore() { |
| 71 // In unit tests, display_ may be NULL. | 71 // In unit tests, display_ may be NULL. |
| 72 if (!display_) | 72 if (!display_) |
| 73 return; | 73 return; |
| 74 | 74 |
| 75 XRenderFreePicture(display_, picture_); | 75 XRenderFreePicture(display_, picture_); |
| 76 XFreePixmap(display_, pixmap_); | 76 XFreePixmap(display_, pixmap_); |
| 77 XFreeGC(display_, static_cast<GC>(pixmap_gc_)); | 77 XFreeGC(display_, static_cast<GC>(pixmap_gc_)); |
| 78 } | 78 } |
| 79 | 79 |
| 80 size_t BackingStore::MemorySize() { | |
| 81 if (use_render_) | |
|
agl
2009/06/24 18:53:01
!use_render_
| |
| 82 return size_.GetArea() * (pixmap_bpp_ / 8); | |
| 83 else | |
| 84 return size_.GetArea() * 4; // TODO(port) is this correct? | |
|
agl
2009/06/24 18:53:01
Yes it is, remove TODO
| |
| 85 } | |
| 86 | |
| 80 void BackingStore::PaintRectWithoutXrender(TransportDIB* bitmap, | 87 void BackingStore::PaintRectWithoutXrender(TransportDIB* bitmap, |
| 81 const gfx::Rect &bitmap_rect) { | 88 const gfx::Rect &bitmap_rect) { |
| 82 const int width = bitmap_rect.width(); | 89 const int width = bitmap_rect.width(); |
| 83 const int height = bitmap_rect.height(); | 90 const int height = bitmap_rect.height(); |
| 84 Pixmap pixmap = XCreatePixmap(display_, root_window_, width, height, | 91 Pixmap pixmap = XCreatePixmap(display_, root_window_, width, height, |
| 85 visual_depth_); | 92 visual_depth_); |
| 86 | 93 |
| 87 XImage image; | 94 XImage image; |
| 88 memset(&image, 0, sizeof(image)); | 95 memset(&image, 0, sizeof(image)); |
| 89 | 96 |
| (...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 334 | 341 |
| 335 bitmap.setConfig(SkBitmap::kARGB_8888_Config, width, height); | 342 bitmap.setConfig(SkBitmap::kARGB_8888_Config, width, height); |
| 336 bitmap.allocPixels(); | 343 bitmap.allocPixels(); |
| 337 unsigned char* bitmap_data = | 344 unsigned char* bitmap_data = |
| 338 reinterpret_cast<unsigned char*>(bitmap.getAddr32(0, 0)); | 345 reinterpret_cast<unsigned char*>(bitmap.getAddr32(0, 0)); |
| 339 memcpy(bitmap_data, image->data, width * height * kBytesPerPixel); | 346 memcpy(bitmap_data, image->data, width * height * kBytesPerPixel); |
| 340 | 347 |
| 341 XFree(image); | 348 XFree(image); |
| 342 return bitmap; | 349 return bitmap; |
| 343 } | 350 } |
| OLD | NEW |