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

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

Issue 506013: Combine ViewHostMsg_{Paint,Scroll}Rect into one IPC.... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 11 years 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 #import <Cocoa/Cocoa.h> 5 #import <Cocoa/Cocoa.h>
6 6
7 #include "chrome/browser/renderer_host/backing_store.h" 7 #include "chrome/browser/renderer_host/backing_store.h"
8 #include "chrome/browser/renderer_host/render_widget_host.h" 8 #include "chrome/browser/renderer_host/render_widget_host.h"
9 #include "chrome/browser/renderer_host/render_widget_host_view.h" 9 #include "chrome/browser/renderer_host/render_widget_host_view.h"
10 10
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 CGContextDrawImage(layer, paint_rect.ToCGRect(), image); 92 CGContextDrawImage(layer, paint_rect.ToCGRect(), image);
93 } else { 93 } else {
94 // The layer hasn't been created yet, so draw into the cache bitmap. 94 // The layer hasn't been created yet, so draw into the cache bitmap.
95 gfx::Rect paint_rect = copy_rect; 95 gfx::Rect paint_rect = copy_rect;
96 paint_rect.set_y(size_.height() - copy_rect.bottom()); 96 paint_rect.set_y(size_.height() - copy_rect.bottom());
97 CGContextDrawImage(cg_bitmap_, paint_rect.ToCGRect(), image); 97 CGContextDrawImage(cg_bitmap_, paint_rect.ToCGRect(), image);
98 } 98 }
99 } 99 }
100 100
101 // Scroll the contents of our CGLayer 101 // Scroll the contents of our CGLayer
102 void BackingStore::ScrollRect(base::ProcessHandle process, 102 void BackingStore::ScrollRect(int dx, int dy,
103 TransportDIB* bitmap,
104 const gfx::Rect& bitmap_rect,
105 int dx, int dy,
106 const gfx::Rect& clip_rect, 103 const gfx::Rect& clip_rect,
107 const gfx::Size& view_size) { 104 const gfx::Size& view_size) {
108 DCHECK_NE(static_cast<bool>(cg_layer()), static_cast<bool>(cg_bitmap())); 105 DCHECK_NE(static_cast<bool>(cg_layer()), static_cast<bool>(cg_bitmap()));
109 106
110 // "Scroll" the contents of the layer by creating a new CGLayer, 107 // "Scroll" the contents of the layer by creating a new CGLayer,
111 // copying the contents of the old one into the new one offset by the scroll 108 // copying the contents of the old one into the new one offset by the scroll
112 // amount, swapping in the new CGLayer, and then painting in the new data. 109 // amount, swapping in the new CGLayer, and then painting in the new data.
113 // 110 //
114 // The Windows code always sets the whole backing store as the source of the 111 // The Windows code always sets the whole backing store as the source of the
115 // scroll. Thus, we only have to worry about pixels which will end up inside 112 // scroll. Thus, we only have to worry about pixels which will end up inside
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 size_.height() - clip_rect.bottom(), 148 size_.height() - clip_rect.bottom(),
152 clip_rect.width(), 149 clip_rect.width(),
153 clip_rect.height())); 150 clip_rect.height()));
154 CGContextDrawImage(new_bitmap, 151 CGContextDrawImage(new_bitmap,
155 CGRectMake(dx, -dy, size_.width(), size_.height()), 152 CGRectMake(dx, -dy, size_.width(), size_.height()),
156 bitmap_image); 153 bitmap_image);
157 CGContextRestoreGState(new_bitmap); 154 CGContextRestoreGState(new_bitmap);
158 cg_bitmap_.swap(new_bitmap); 155 cg_bitmap_.swap(new_bitmap);
159 } 156 }
160 } 157 }
161 // Now paint the new bitmap data
162 PaintRect(process, bitmap, bitmap_rect, bitmap_rect);
163 return;
164 } 158 }
165 159
166 CGLayerRef BackingStore::CreateCGLayer() { 160 CGLayerRef BackingStore::CreateCGLayer() {
167 // The CGLayer should be optimized for drawing into the containing window, 161 // The CGLayer should be optimized for drawing into the containing window,
168 // so extract a CGContext corresponding to the window to be passed to 162 // so extract a CGContext corresponding to the window to be passed to
169 // CGLayerCreateWithContext. 163 // CGLayerCreateWithContext.
170 NSWindow* window = [render_widget_host()->view()->GetNativeView() window]; 164 NSWindow* window = [render_widget_host()->view()->GetNativeView() window];
171 if ([window windowNumber] <= 0) { 165 if ([window windowNumber] <= 0) {
172 // This catches a nil |window|, as well as windows that exist but that 166 // This catches a nil |window|, as well as windows that exist but that
173 // aren't yet connected to WindowServer. 167 // aren't yet connected to WindowServer.
(...skipping 21 matching lines...) Expand all
195 CGContextRef context = CGBitmapContextCreate(NULL, 189 CGContextRef context = CGBitmapContextCreate(NULL,
196 size_.width(), size_.height(), 190 size_.width(), size_.height(),
197 8, size_.width() * 4, 191 8, size_.width() * 4,
198 mac_util::GetSystemColorSpace(), 192 mac_util::GetSystemColorSpace(),
199 kCGImageAlphaPremultipliedFirst | 193 kCGImageAlphaPremultipliedFirst |
200 kCGBitmapByteOrder32Host); 194 kCGBitmapByteOrder32Host);
201 DCHECK(context); 195 DCHECK(context);
202 196
203 return context; 197 return context;
204 } 198 }
OLDNEW
« no previous file with comments | « chrome/browser/renderer_host/backing_store.h ('k') | chrome/browser/renderer_host/backing_store_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698