| OLD | NEW |
| 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> |
| 10 |
| 9 #include "base/logging.h" | 11 #include "base/logging.h" |
| 10 #include "base/mac/mac_util.h" | 12 #include "base/mac/mac_util.h" |
| 11 #include "base/mac/scoped_cftyperef.h" | 13 #include "base/mac/scoped_cftyperef.h" |
| 12 #include "content/browser/renderer_host/render_process_host_impl.h" | 14 #include "content/browser/renderer_host/render_process_host_impl.h" |
| 13 #include "content/browser/renderer_host/render_widget_host_impl.h" | 15 #include "content/browser/renderer_host/render_widget_host_impl.h" |
| 14 #include "content/public/browser/render_widget_host_view.h" | 16 #include "content/public/browser/render_widget_host_view.h" |
| 15 #include "skia/ext/platform_canvas.h" | 17 #include "skia/ext/platform_canvas.h" |
| 16 #include "third_party/skia/include/core/SkBitmap.h" | 18 #include "third_party/skia/include/core/SkBitmap.h" |
| 17 #include "third_party/skia/include/core/SkCanvas.h" | 19 #include "third_party/skia/include/core/SkCanvas.h" |
| 18 #include "ui/gfx/rect.h" | 20 #include "ui/gfx/rect.h" |
| 19 #include "ui/gfx/scoped_cg_context_save_gstate_mac.h" | 21 #include "ui/gfx/scoped_cg_context_save_gstate_mac.h" |
| 20 #include "ui/surface/transport_dib.h" | 22 #include "ui/surface/transport_dib.h" |
| 21 | 23 |
| 22 namespace { | 24 namespace { |
| 23 | 25 |
| 24 // Returns a Rect obtained by flooring the values of the given RectF. | 26 // Returns a Rect obtained by flooring the values of the given RectF. |
| 25 gfx::Rect ToFlooredRect(const gfx::RectF& rect) { | 27 gfx::Rect ToFlooredRect(const gfx::RectF& rect) { |
| 26 return gfx::Rect(rect.origin().ToPoint(), rect.size().ToSize()); | 28 return gfx::Rect(static_cast<int>(std::floor(rect.x())), |
| 29 static_cast<int>(std::floor(rect.y())), |
| 30 static_cast<int>(std::floor(rect.width())), |
| 31 static_cast<int>(std::floor(rect.height()))); |
| 27 } | 32 } |
| 28 | 33 |
| 29 } // namespace | 34 } // namespace |
| 30 | 35 |
| 31 namespace content { | 36 namespace content { |
| 32 | 37 |
| 33 // Mac Backing Stores: | 38 // Mac Backing Stores: |
| 34 // | 39 // |
| 35 // Since backing stores are only ever written to or drawn into windows, we keep | 40 // Since backing stores are only ever written to or drawn into windows, we keep |
| 36 // our backing store in a CGLayer that can get cached in GPU memory. This | 41 // our backing store in a CGLayer that can get cached in GPU memory. This |
| (...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 272 8, pixel_size.width() * 4, | 277 8, pixel_size.width() * 4, |
| 273 base::mac::GetSystemColorSpace(), | 278 base::mac::GetSystemColorSpace(), |
| 274 kCGImageAlphaPremultipliedFirst | | 279 kCGImageAlphaPremultipliedFirst | |
| 275 kCGBitmapByteOrder32Host); | 280 kCGBitmapByteOrder32Host); |
| 276 DCHECK(context); | 281 DCHECK(context); |
| 277 | 282 |
| 278 return context; | 283 return context; |
| 279 } | 284 } |
| 280 | 285 |
| 281 } // namespace content | 286 } // namespace content |
| OLD | NEW |