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 "skia/include/SkBitmap.h" | 10 #include "skia/include/SkBitmap.h" |
11 #include "skia/include/SkCanvas.h" | 11 #include "skia/include/SkCanvas.h" |
12 | 12 |
13 BackingStore::BackingStore(const gfx::Size& size) | 13 BackingStore::BackingStore(const gfx::Size& size) |
14 : size_(size) { | 14 : size_(size) { |
15 if (!canvas_.initialize(size.width(), size.height(), true)) | 15 if (!canvas_.initialize(size.width(), size.height(), true)) |
16 SK_CRASH(); | 16 SK_CRASH(); |
17 } | 17 } |
18 | 18 |
19 BackingStore::~BackingStore() { | 19 BackingStore::~BackingStore() { |
20 } | 20 } |
21 | 21 |
22 bool BackingStore::PaintRect(base::ProcessHandle process, | 22 void BackingStore::PaintRect(base::ProcessHandle process, |
23 TransportDIB* bitmap, | 23 TransportDIB* bitmap, |
24 const gfx::Rect& bitmap_rect) { | 24 const gfx::Rect& bitmap_rect) { |
25 SkBitmap skbitmap; | 25 SkBitmap skbitmap; |
26 skbitmap.setConfig(SkBitmap::kARGB_8888_Config, bitmap_rect.width(), | 26 skbitmap.setConfig(SkBitmap::kARGB_8888_Config, bitmap_rect.width(), |
27 bitmap_rect.height(), 4 * bitmap_rect.width()); | 27 bitmap_rect.height(), 4 * bitmap_rect.width()); |
28 | 28 |
29 skbitmap.setPixels(bitmap->memory()); | 29 skbitmap.setPixels(bitmap->memory()); |
30 | 30 |
31 canvas_.drawBitmap(skbitmap, bitmap_rect.x(), bitmap_rect.y()); | 31 canvas_.drawBitmap(skbitmap, bitmap_rect.x(), bitmap_rect.y()); |
32 return true; | |
33 } | 32 } |
34 | 33 |
35 void BackingStore::ScrollRect(base::ProcessHandle process, | 34 void BackingStore::ScrollRect(base::ProcessHandle process, |
36 TransportDIB* bitmap, | 35 TransportDIB* bitmap, |
37 const gfx::Rect& bitmap_rect, | 36 const gfx::Rect& bitmap_rect, |
38 int dx, int dy, | 37 int dx, int dy, |
39 const gfx::Rect& clip_rect, | 38 const gfx::Rect& clip_rect, |
40 const gfx::Size& view_size) { | 39 const gfx::Size& view_size) { |
41 // WARNING: this is temporary code until a real solution is found for Mac and | 40 // WARNING: this is temporary code until a real solution is found for Mac and |
42 // Linux. | 41 // Linux. |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
114 memcpy(x, x + stride * dy, len); | 113 memcpy(x, x + stride * dy, len); |
115 x -= stride; | 114 x -= stride; |
116 } | 115 } |
117 } | 116 } |
118 } | 117 } |
119 | 118 |
120 // Now paint the new bitmap data. | 119 // Now paint the new bitmap data. |
121 PaintRect(process, bitmap, bitmap_rect); | 120 PaintRect(process, bitmap, bitmap_rect); |
122 return; | 121 return; |
123 } | 122 } |
OLD | NEW |