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

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

Issue 10996037: Do not convert from RectF to Rect by flooring. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixing mac build. Created 8 years, 2 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"
11 #include "base/mac/scoped_cftyperef.h" 11 #include "base/mac/scoped_cftyperef.h"
12 #include "content/browser/renderer_host/render_process_host_impl.h" 12 #include "content/browser/renderer_host/render_process_host_impl.h"
13 #include "content/browser/renderer_host/render_widget_host_impl.h" 13 #include "content/browser/renderer_host/render_widget_host_impl.h"
14 #include "content/public/browser/render_widget_host_view.h" 14 #include "content/public/browser/render_widget_host_view.h"
15 #include "skia/ext/platform_canvas.h" 15 #include "skia/ext/platform_canvas.h"
16 #include "third_party/skia/include/core/SkBitmap.h" 16 #include "third_party/skia/include/core/SkBitmap.h"
17 #include "third_party/skia/include/core/SkCanvas.h" 17 #include "third_party/skia/include/core/SkCanvas.h"
18 #include "ui/gfx/rect.h" 18 #include "ui/gfx/rect.h"
19 #include "ui/gfx/rect_conversions.h"
19 #include "ui/gfx/scoped_cg_context_save_gstate_mac.h" 20 #include "ui/gfx/scoped_cg_context_save_gstate_mac.h"
20 #include "ui/surface/transport_dib.h" 21 #include "ui/surface/transport_dib.h"
21 22
22 namespace content { 23 namespace content {
23 24
24 // Mac Backing Stores: 25 // Mac Backing Stores:
25 // 26 //
26 // Since backing stores are only ever written to or drawn into windows, we keep 27 // Since backing stores are only ever written to or drawn into windows, we keep
27 // our backing store in a CGLayer that can get cached in GPU memory. This 28 // our backing store in a CGLayer that can get cached in GPU memory. This
28 // allows acclerated drawing into the layer and lets scrolling and such happen 29 // allows acclerated drawing into the layer and lets scrolling and such happen
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 const base::Closure& completion_callback, 79 const base::Closure& completion_callback,
79 bool* scheduled_completion_callback) { 80 bool* scheduled_completion_callback) {
80 *scheduled_completion_callback = false; 81 *scheduled_completion_callback = false;
81 DCHECK_NE(static_cast<bool>(cg_layer()), static_cast<bool>(cg_bitmap())); 82 DCHECK_NE(static_cast<bool>(cg_layer()), static_cast<bool>(cg_bitmap()));
82 83
83 TransportDIB* dib = process->GetTransportDIB(bitmap); 84 TransportDIB* dib = process->GetTransportDIB(bitmap);
84 if (!dib) 85 if (!dib)
85 return; 86 return;
86 87
87 gfx::Size pixel_size = size().Scale(device_scale_factor_); 88 gfx::Size pixel_size = size().Scale(device_scale_factor_);
88 gfx::Rect pixel_bitmap_rect = bitmap_rect.Scale(scale_factor); 89 gfx::Rect pixel_bitmap_rect =
90 gfx::ToEnclosingRect(bitmap_rect.Scale(scale_factor));
89 91
90 size_t bitmap_byte_count = 92 size_t bitmap_byte_count =
91 pixel_bitmap_rect.width() * pixel_bitmap_rect.height() * 4; 93 pixel_bitmap_rect.width() * pixel_bitmap_rect.height() * 4;
92 DCHECK_GE(dib->size(), bitmap_byte_count); 94 DCHECK_GE(dib->size(), bitmap_byte_count);
93 95
94 base::mac::ScopedCFTypeRef<CGDataProviderRef> data_provider( 96 base::mac::ScopedCFTypeRef<CGDataProviderRef> data_provider(
95 CGDataProviderCreateWithData(NULL, dib->memory(), 97 CGDataProviderCreateWithData(NULL, dib->memory(),
96 bitmap_byte_count, NULL)); 98 bitmap_byte_count, NULL));
97 99
98 base::mac::ScopedCFTypeRef<CGImageRef> bitmap_image( 100 base::mac::ScopedCFTypeRef<CGImageRef> bitmap_image(
99 CGImageCreate(pixel_bitmap_rect.width(), pixel_bitmap_rect.height(), 101 CGImageCreate(pixel_bitmap_rect.width(), pixel_bitmap_rect.height(),
100 8, 32, 4 * pixel_bitmap_rect.width(), 102 8, 32, 4 * pixel_bitmap_rect.width(),
101 base::mac::GetSystemColorSpace(), 103 base::mac::GetSystemColorSpace(),
102 kCGImageAlphaPremultipliedFirst | kCGBitmapByteOrder32Host, 104 kCGImageAlphaPremultipliedFirst | kCGBitmapByteOrder32Host,
103 data_provider, NULL, false, kCGRenderingIntentDefault)); 105 data_provider, NULL, false, kCGRenderingIntentDefault));
104 106
105 for (size_t i = 0; i < copy_rects.size(); i++) { 107 for (size_t i = 0; i < copy_rects.size(); i++) {
106 const gfx::Rect& copy_rect = copy_rects[i]; 108 const gfx::Rect& copy_rect = copy_rects[i];
107 gfx::Rect pixel_copy_rect = copy_rect.Scale(scale_factor); 109 gfx::Rect pixel_copy_rect =
110 gfx::ToEnclosingRect(copy_rect.Scale(scale_factor));
108 111
109 // Only the subpixels given by copy_rect have pixels to copy. 112 // Only the subpixels given by copy_rect have pixels to copy.
110 base::mac::ScopedCFTypeRef<CGImageRef> image( 113 base::mac::ScopedCFTypeRef<CGImageRef> image(
111 CGImageCreateWithImageInRect(bitmap_image, CGRectMake( 114 CGImageCreateWithImageInRect(bitmap_image, CGRectMake(
112 pixel_copy_rect.x() - pixel_bitmap_rect.x(), 115 pixel_copy_rect.x() - pixel_bitmap_rect.x(),
113 pixel_copy_rect.y() - pixel_bitmap_rect.y(), 116 pixel_copy_rect.y() - pixel_bitmap_rect.y(),
114 pixel_copy_rect.width(), 117 pixel_copy_rect.width(),
115 pixel_copy_rect.height()))); 118 pixel_copy_rect.height())));
116 119
117 if (!cg_layer()) { 120 if (!cg_layer()) {
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
261 8, pixel_size.width() * 4, 264 8, pixel_size.width() * 4,
262 base::mac::GetSystemColorSpace(), 265 base::mac::GetSystemColorSpace(),
263 kCGImageAlphaPremultipliedFirst | 266 kCGImageAlphaPremultipliedFirst |
264 kCGBitmapByteOrder32Host); 267 kCGBitmapByteOrder32Host);
265 DCHECK(context); 268 DCHECK(context);
266 269
267 return context; 270 return context;
268 } 271 }
269 272
270 } // namespace content 273 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/renderer_host/backing_store_aura.cc ('k') | content/browser/renderer_host/render_widget_host_view_mac.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698