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

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

Issue 18052011: Fix CopyFromBackingStore when there's no cg_layer_. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 7 years, 5 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "content/browser/renderer_host/backing_store_mac.h" 7 #include "content/browser/renderer_host/backing_store_mac.h"
8 8
9 #include <cmath> 9 #include <cmath>
10 10
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 CGContextDrawImage(layer, paint_rect.ToCGRect(), image); 155 CGContextDrawImage(layer, paint_rect.ToCGRect(), image);
156 } else { 156 } else {
157 // The layer hasn't been created yet, so draw into the cache bitmap. 157 // The layer hasn't been created yet, so draw into the cache bitmap.
158 gfx::Rect paint_rect = copy_rect; 158 gfx::Rect paint_rect = copy_rect;
159 paint_rect.set_y(size().height() - copy_rect.bottom()); 159 paint_rect.set_y(size().height() - copy_rect.bottom());
160 CGContextDrawImage(cg_bitmap_, paint_rect.ToCGRect(), image); 160 CGContextDrawImage(cg_bitmap_, paint_rect.ToCGRect(), image);
161 } 161 }
162 } 162 }
163 } 163 }
164 164
165 bool BackingStoreMac::CopyFromBackingStore(const gfx::Rect& rect, 165 bool BackingStoreMac::CopyFromBackingStore(const gfx::Rect& rect,
Nico 2013/07/01 16:55:00 for hidpi: one probably would hand in a scale fact
166 skia::PlatformBitmap* output) { 166 skia::PlatformBitmap* output) {
167 // TODO(thakis): Make sure this works with HiDPI backing stores. 167 // TODO(thakis): Make sure this works with HiDPI backing stores.
168 if (!output->Allocate(rect.width(), rect.height(), true)) 168 if (!output->Allocate(rect.width(), rect.height(), true))
169 return false; 169 return false;
170 170
171 CGContextRef temp_context = output->GetSurface(); 171 CGContextRef temp_context = output->GetSurface();
172 gfx::ScopedCGContextSaveGState save_gstate(temp_context); 172 gfx::ScopedCGContextSaveGState save_gstate(temp_context);
173 CGContextTranslateCTM(temp_context, 0.0, size().height()); 173 CGContextTranslateCTM(temp_context, 0.0, size().height());
Nico 2013/07/01 16:55:00 size() returns logical size, which isn't right for
174 CGContextScaleCTM(temp_context, 1.0, -1.0); 174 CGContextScaleCTM(temp_context, 1.0, -1.0);
175 CGContextDrawLayerAtPoint(temp_context, CGPointMake(-rect.x(), -rect.y()), 175 if (cg_layer()) {
176 cg_layer()); 176 CGContextDrawLayerAtPoint(temp_context, CGPointMake(-rect.x(), -rect.y()),
177 cg_layer());
178 } else {
179 base::ScopedCFTypeRef<CGImageRef> bitmap_image(
180 CGBitmapContextCreateImage(cg_bitmap_));
181 CGContextDrawImage(
182 temp_context,
183 CGRectMake(-rect.x(), -rect.y(), rect.width(), rect.height()),
184 bitmap_image);
185 }
186
177 return true; 187 return true;
178 } 188 }
179 189
180 // Scroll the contents of our CGLayer 190 // Scroll the contents of our CGLayer
181 void BackingStoreMac::ScrollBackingStore(const gfx::Vector2d& delta, 191 void BackingStoreMac::ScrollBackingStore(const gfx::Vector2d& delta,
182 const gfx::Rect& clip_rect, 192 const gfx::Rect& clip_rect,
183 const gfx::Size& view_size) { 193 const gfx::Size& view_size) {
184 DCHECK_NE(static_cast<bool>(cg_layer()), static_cast<bool>(cg_bitmap())); 194 DCHECK_NE(static_cast<bool>(cg_layer()), static_cast<bool>(cg_bitmap()));
185 195
186 // "Scroll" the contents of the layer by creating a new CGLayer, 196 // "Scroll" the contents of the layer by creating a new CGLayer,
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
278 8, pixel_size.width() * 4, 288 8, pixel_size.width() * 4,
279 base::mac::GetSystemColorSpace(), 289 base::mac::GetSystemColorSpace(),
280 kCGImageAlphaPremultipliedFirst | 290 kCGImageAlphaPremultipliedFirst |
281 kCGBitmapByteOrder32Host); 291 kCGBitmapByteOrder32Host);
282 DCHECK(context); 292 DCHECK(context);
283 293
284 return context; 294 return context;
285 } 295 }
286 296
287 } // namespace content 297 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698