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

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

Issue 10540144: Tag TransportDIBs with the device scale factor they expect. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: comments Created 8 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) 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 "base/logging.h" 9 #include "base/logging.h"
10 #include "base/mac/mac_util.h" 10 #include "base/mac/mac_util.h"
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 43
44 size_t BackingStoreMac::MemorySize() { 44 size_t BackingStoreMac::MemorySize() {
45 return size().Scale(device_scale_factor_).GetArea() * 4; 45 return size().Scale(device_scale_factor_).GetArea() * 4;
46 } 46 }
47 47
48 void BackingStoreMac::PaintToBackingStore( 48 void BackingStoreMac::PaintToBackingStore(
49 content::RenderProcessHost* process, 49 content::RenderProcessHost* process,
50 TransportDIB::Id bitmap, 50 TransportDIB::Id bitmap,
51 const gfx::Rect& bitmap_rect, 51 const gfx::Rect& bitmap_rect,
52 const std::vector<gfx::Rect>& copy_rects, 52 const std::vector<gfx::Rect>& copy_rects,
53 float scale_factor,
53 const base::Closure& completion_callback, 54 const base::Closure& completion_callback,
54 bool* scheduled_completion_callback) { 55 bool* scheduled_completion_callback) {
55 *scheduled_completion_callback = false; 56 *scheduled_completion_callback = false;
56 DCHECK_NE(static_cast<bool>(cg_layer()), static_cast<bool>(cg_bitmap())); 57 DCHECK_NE(static_cast<bool>(cg_layer()), static_cast<bool>(cg_bitmap()));
57 58
58 TransportDIB* dib = process->GetTransportDIB(bitmap); 59 TransportDIB* dib = process->GetTransportDIB(bitmap);
59 if (!dib) 60 if (!dib)
60 return; 61 return;
61 62
62 gfx::Size pixel_size = size().Scale(device_scale_factor_); 63 gfx::Size pixel_size = size().Scale(device_scale_factor_);
63 gfx::Rect pixel_bitmap_rect = bitmap_rect.Scale(device_scale_factor_); 64 gfx::Rect pixel_bitmap_rect = bitmap_rect.Scale(scale_factor);
64 65
65 base::mac::ScopedCFTypeRef<CGDataProviderRef> data_provider( 66 base::mac::ScopedCFTypeRef<CGDataProviderRef> data_provider(
66 CGDataProviderCreateWithData(NULL, dib->memory(), 67 CGDataProviderCreateWithData(NULL, dib->memory(),
67 pixel_bitmap_rect.width() * pixel_bitmap_rect.height() * 4, NULL)); 68 pixel_bitmap_rect.width() * pixel_bitmap_rect.height() * 4, NULL));
68 69
69 base::mac::ScopedCFTypeRef<CGImageRef> bitmap_image( 70 base::mac::ScopedCFTypeRef<CGImageRef> bitmap_image(
70 CGImageCreate(pixel_bitmap_rect.width(), pixel_bitmap_rect.height(), 71 CGImageCreate(pixel_bitmap_rect.width(), pixel_bitmap_rect.height(),
71 8, 32, 4 * pixel_bitmap_rect.width(), 72 8, 32, 4 * pixel_bitmap_rect.width(),
72 base::mac::GetSystemColorSpace(), 73 base::mac::GetSystemColorSpace(),
73 kCGImageAlphaPremultipliedFirst | kCGBitmapByteOrder32Host, 74 kCGImageAlphaPremultipliedFirst | kCGBitmapByteOrder32Host,
74 data_provider, NULL, false, kCGRenderingIntentDefault)); 75 data_provider, NULL, false, kCGRenderingIntentDefault));
75 76
76 for (size_t i = 0; i < copy_rects.size(); i++) { 77 for (size_t i = 0; i < copy_rects.size(); i++) {
77 const gfx::Rect& copy_rect = copy_rects[i]; 78 const gfx::Rect& copy_rect = copy_rects[i];
78 gfx::Rect pixel_copy_rect = copy_rect.Scale(device_scale_factor_); 79 gfx::Rect pixel_copy_rect = copy_rect.Scale(scale_factor);
79 80
80 // Only the subpixels given by copy_rect have pixels to copy. 81 // Only the subpixels given by copy_rect have pixels to copy.
81 base::mac::ScopedCFTypeRef<CGImageRef> image( 82 base::mac::ScopedCFTypeRef<CGImageRef> image(
82 CGImageCreateWithImageInRect(bitmap_image, CGRectMake( 83 CGImageCreateWithImageInRect(bitmap_image, CGRectMake(
83 pixel_copy_rect.x() - pixel_bitmap_rect.x(), 84 pixel_copy_rect.x() - pixel_bitmap_rect.x(),
84 pixel_copy_rect.y() - pixel_bitmap_rect.y(), 85 pixel_copy_rect.y() - pixel_bitmap_rect.y(),
85 pixel_copy_rect.width(), 86 pixel_copy_rect.width(),
86 pixel_copy_rect.height()))); 87 pixel_copy_rect.height())));
87 88
88 if (!cg_layer()) { 89 if (!cg_layer()) {
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
253 pixel_size.width(), 254 pixel_size.width(),
254 pixel_size.height(), 255 pixel_size.height(),
255 8, pixel_size.width() * 4, 256 8, pixel_size.width() * 4,
256 base::mac::GetSystemColorSpace(), 257 base::mac::GetSystemColorSpace(),
257 kCGImageAlphaPremultipliedFirst | 258 kCGImageAlphaPremultipliedFirst |
258 kCGBitmapByteOrder32Host); 259 kCGBitmapByteOrder32Host);
259 DCHECK(context); 260 DCHECK(context);
260 261
261 return context; 262 return context;
262 } 263 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698