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

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

Issue 146095: change backing store cache to be memory-based rather than count (Closed)
Patch Set: added better MemorySize() and comments 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 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
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 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698