| 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 "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/scoped_cg_context_save_gstate_mac.h" | 19 #include "ui/gfx/scoped_cg_context_save_gstate_mac.h" |
| 20 #include "ui/gfx/surface/transport_dib.h" | 20 #include "ui/gfx/surface/transport_dib.h" |
| 21 | 21 |
| 22 // Mac Backing Stores: | 22 // Mac Backing Stores: |
| 23 // | 23 // |
| 24 // Since backing stores are only ever written to or drawn into windows, we keep | 24 // Since backing stores are only ever written to or drawn into windows, we keep |
| 25 // our backing store in a CGLayer that can get cached in GPU memory. This | 25 // our backing store in a CGLayer that can get cached in GPU memory. This |
| 26 // allows acclerated drawing into the layer and lets scrolling and such happen | 26 // allows acclerated drawing into the layer and lets scrolling and such happen |
| 27 // all or mostly on the GPU, which is good for performance. | 27 // all or mostly on the GPU, which is good for performance. |
| 28 | 28 |
| 29 BackingStoreMac::BackingStoreMac(RenderWidgetHost* widget, | 29 BackingStoreMac::BackingStoreMac(content::RenderWidgetHost* widget, |
| 30 const gfx::Size& size) | 30 const gfx::Size& size) |
| 31 : BackingStore(widget, size) { | 31 : BackingStore(widget, size) { |
| 32 cg_layer_.reset(CreateCGLayer()); | 32 cg_layer_.reset(CreateCGLayer()); |
| 33 if (!cg_layer_) { | 33 if (!cg_layer_) { |
| 34 // The view isn't in a window yet. Use a CGBitmapContext for now. | 34 // The view isn't in a window yet. Use a CGBitmapContext for now. |
| 35 cg_bitmap_.reset(CreateCGBitmapContext()); | 35 cg_bitmap_.reset(CreateCGBitmapContext()); |
| 36 } | 36 } |
| 37 } | 37 } |
| 38 | 38 |
| 39 BackingStoreMac::~BackingStoreMac() { | 39 BackingStoreMac::~BackingStoreMac() { |
| (...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 237 CGContextRef context = CGBitmapContextCreate(NULL, | 237 CGContextRef context = CGBitmapContextCreate(NULL, |
| 238 size().width(), size().height(), | 238 size().width(), size().height(), |
| 239 8, size().width() * 4, | 239 8, size().width() * 4, |
| 240 base::mac::GetSystemColorSpace(), | 240 base::mac::GetSystemColorSpace(), |
| 241 kCGImageAlphaPremultipliedFirst | | 241 kCGImageAlphaPremultipliedFirst | |
| 242 kCGBitmapByteOrder32Host); | 242 kCGBitmapByteOrder32Host); |
| 243 DCHECK(context); | 243 DCHECK(context); |
| 244 | 244 |
| 245 return context; | 245 return context; |
| 246 } | 246 } |
| OLD | NEW |