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

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

Issue 506075: Revert 34951 - 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(int dx, int dy, 102 void BackingStore::ScrollRect(base::ProcessHandle process,
103 TransportDIB* bitmap,
104 const gfx::Rect& bitmap_rect,
105 int dx, int dy,
103 const gfx::Rect& clip_rect, 106 const gfx::Rect& clip_rect,
104 const gfx::Size& view_size) { 107 const gfx::Size& view_size) {
105 DCHECK_NE(static_cast<bool>(cg_layer()), static_cast<bool>(cg_bitmap())); 108 DCHECK_NE(static_cast<bool>(cg_layer()), static_cast<bool>(cg_bitmap()));
106 109
107 // "Scroll" the contents of the layer by creating a new CGLayer, 110 // "Scroll" the contents of the layer by creating a new CGLayer,
108 // copying the contents of the old one into the new one offset by the scroll 111 // copying the contents of the old one into the new one offset by the scroll
109 // amount, swapping in the new CGLayer, and then painting in the new data. 112 // amount, swapping in the new CGLayer, and then painting in the new data.
110 // 113 //
111 // The Windows code always sets the whole backing store as the source of the 114 // The Windows code always sets the whole backing store as the source of the
112 // scroll. Thus, we only have to worry about pixels which will end up inside 115 // 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
148 size_.height() - clip_rect.bottom(), 151 size_.height() - clip_rect.bottom(),
149 clip_rect.width(), 152 clip_rect.width(),
150 clip_rect.height())); 153 clip_rect.height()));
151 CGContextDrawImage(new_bitmap, 154 CGContextDrawImage(new_bitmap,
152 CGRectMake(dx, -dy, size_.width(), size_.height()), 155 CGRectMake(dx, -dy, size_.width(), size_.height()),
153 bitmap_image); 156 bitmap_image);
154 CGContextRestoreGState(new_bitmap); 157 CGContextRestoreGState(new_bitmap);
155 cg_bitmap_.swap(new_bitmap); 158 cg_bitmap_.swap(new_bitmap);
156 } 159 }
157 } 160 }
161 // Now paint the new bitmap data
162 PaintRect(process, bitmap, bitmap_rect, bitmap_rect);
163 return;
158 } 164 }
159 165
160 CGLayerRef BackingStore::CreateCGLayer() { 166 CGLayerRef BackingStore::CreateCGLayer() {
161 // The CGLayer should be optimized for drawing into the containing window, 167 // The CGLayer should be optimized for drawing into the containing window,
162 // so extract a CGContext corresponding to the window to be passed to 168 // so extract a CGContext corresponding to the window to be passed to
163 // CGLayerCreateWithContext. 169 // CGLayerCreateWithContext.
164 NSWindow* window = [render_widget_host()->view()->GetNativeView() window]; 170 NSWindow* window = [render_widget_host()->view()->GetNativeView() window];
165 if ([window windowNumber] <= 0) { 171 if ([window windowNumber] <= 0) {
166 // This catches a nil |window|, as well as windows that exist but that 172 // This catches a nil |window|, as well as windows that exist but that
167 // aren't yet connected to WindowServer. 173 // aren't yet connected to WindowServer.
(...skipping 21 matching lines...) Expand all
189 CGContextRef context = CGBitmapContextCreate(NULL, 195 CGContextRef context = CGBitmapContextCreate(NULL,
190 size_.width(), size_.height(), 196 size_.width(), size_.height(),
191 8, size_.width() * 4, 197 8, size_.width() * 4,
192 mac_util::GetSystemColorSpace(), 198 mac_util::GetSystemColorSpace(),
193 kCGImageAlphaPremultipliedFirst | 199 kCGImageAlphaPremultipliedFirst |
194 kCGBitmapByteOrder32Host); 200 kCGBitmapByteOrder32Host);
195 DCHECK(context); 201 DCHECK(context);
196 202
197 return context; 203 return context;
198 } 204 }
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