| 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 "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "chrome/common/transport_dib.h" | 8 #include "chrome/common/transport_dib.h" |
| 9 #include "skia/ext/platform_canvas.h" | 9 #include "skia/ext/platform_canvas.h" |
| 10 #include "third_party/skia/include/core/SkBitmap.h" | 10 #include "third_party/skia/include/core/SkBitmap.h" |
| 11 #include "third_party/skia/include/core/SkCanvas.h" | 11 #include "third_party/skia/include/core/SkCanvas.h" |
| 12 | 12 |
| 13 BackingStore::BackingStore(RenderWidgetHost* widget, const gfx::Size& size) | 13 BackingStore::BackingStore(RenderWidgetHost* widget, const gfx::Size& size) |
| 14 : render_widget_host_(widget), | 14 : render_widget_host_(widget), |
| 15 size_(size) { | 15 size_(size) { |
| 16 if (!canvas_.initialize(size.width(), size.height(), true)) | 16 if (!canvas_.initialize(size.width(), size.height(), true)) |
| 17 SK_CRASH(); | 17 SK_CRASH(); |
| 18 } | 18 } |
| 19 | 19 |
| 20 BackingStore::~BackingStore() { | 20 BackingStore::~BackingStore() { |
| 21 } | 21 } |
| 22 | 22 |
| 23 size_t BackingStore::MemorySize() { |
| 24 // Always 4 bytes per pixel. |
| 25 return size_.GetArea() * 4; |
| 26 } |
| 27 |
| 23 void BackingStore::PaintRect(base::ProcessHandle process, | 28 void BackingStore::PaintRect(base::ProcessHandle process, |
| 24 TransportDIB* bitmap, | 29 TransportDIB* bitmap, |
| 25 const gfx::Rect& bitmap_rect) { | 30 const gfx::Rect& bitmap_rect) { |
| 26 SkBitmap skbitmap; | 31 SkBitmap skbitmap; |
| 27 skbitmap.setConfig(SkBitmap::kARGB_8888_Config, bitmap_rect.width(), | 32 skbitmap.setConfig(SkBitmap::kARGB_8888_Config, bitmap_rect.width(), |
| 28 bitmap_rect.height(), 4 * bitmap_rect.width()); | 33 bitmap_rect.height(), 4 * bitmap_rect.width()); |
| 29 | 34 |
| 30 skbitmap.setPixels(bitmap->memory()); | 35 skbitmap.setPixels(bitmap->memory()); |
| 31 | 36 |
| 32 canvas_.drawBitmap(skbitmap, bitmap_rect.x(), bitmap_rect.y()); | 37 canvas_.drawBitmap(skbitmap, bitmap_rect.x(), bitmap_rect.y()); |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 126 memcpy(x, x + stride * dy, len); | 131 memcpy(x, x + stride * dy, len); |
| 127 x -= stride; | 132 x -= stride; |
| 128 } | 133 } |
| 129 } | 134 } |
| 130 } | 135 } |
| 131 | 136 |
| 132 // Now paint the new bitmap data. | 137 // Now paint the new bitmap data. |
| 133 PaintRect(process, bitmap, bitmap_rect); | 138 PaintRect(process, bitmap, bitmap_rect); |
| 134 return; | 139 return; |
| 135 } | 140 } |
| OLD | NEW |