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

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

Issue 108040: Send array of paint rects and bitmaps as opposed to a Union (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' 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 | Annotate | Revision Log
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 "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(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 void 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 const gfx::Rect& paint_rect) {
26 DCHECK(bitmap_rect.Contains(paint_rect) &&
27 paint_rect.x() < kMaxBitmapLengthAllowed &&
28 paint_rect.y() < kMaxBitmapLengthAllowed);
25 SkBitmap skbitmap; 29 SkBitmap skbitmap;
26 skbitmap.setConfig(SkBitmap::kARGB_8888_Config, bitmap_rect.width(), 30 skbitmap.setConfig(SkBitmap::kARGB_8888_Config, bitmap_rect.width(),
27 bitmap_rect.height(), 4 * bitmap_rect.width()); 31 bitmap_rect.height(), 4 * bitmap_rect.width());
28 32
29 skbitmap.setPixels(bitmap->memory()); 33 skbitmap.setPixels(bitmap->memory());
30 34 SkIRect src_rect;
31 canvas_.drawBitmap(skbitmap, bitmap_rect.x(), bitmap_rect.y()); 35 src_rect.set(paint_rect.x(), paint_rect.y(),
36 paint_rect.right(), paint_rect.bottom());
37 src_rect.offset(-bitmap_rect.x(), -bitmap_rect.y());
38 SkRect dst_rect;
39 dst_rect.iset(paint_rect.x(), paint_rect.y(),
40 paint_rect.right(), paint_rect.bottom());
41 canvas_.drawBitmapRect(skbitmap, &src_rect, dst_rect);
32 } 42 }
33 43
34 void BackingStore::ScrollRect(base::ProcessHandle process, 44 void BackingStore::ScrollRect(base::ProcessHandle process,
35 TransportDIB* bitmap, 45 TransportDIB* bitmap,
36 const gfx::Rect& bitmap_rect, 46 const gfx::Rect& bitmap_rect,
37 int dx, int dy, 47 int dx, int dy,
38 const gfx::Rect& clip_rect, 48 const gfx::Rect& clip_rect,
39 const gfx::Size& view_size) { 49 const gfx::Size& view_size) {
40 // WARNING: this is temporary code until a real solution is found for Mac and 50 // WARNING: this is temporary code until a real solution is found for Mac and
41 // Linux. 51 // Linux.
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 x += (clip_rect.bottom() - 1) * stride; 120 x += (clip_rect.bottom() - 1) * stride;
111 121
112 for (int i = clip_rect.y(); i < clip_rect.height() + dy; ++i) { 122 for (int i = clip_rect.y(); i < clip_rect.height() + dy; ++i) {
113 memcpy(x, x + stride * dy, len); 123 memcpy(x, x + stride * dy, len);
114 x -= stride; 124 x -= stride;
115 } 125 }
116 } 126 }
117 } 127 }
118 128
119 // Now paint the new bitmap data. 129 // Now paint the new bitmap data.
120 PaintRect(process, bitmap, bitmap_rect); 130 PaintRect(process, bitmap, bitmap_rect, bitmap_rect);
121 return; 131 return;
122 } 132 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698