| 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 #ifndef CONTENT_BROWSER_RENDERER_HOST_BACKING_STORE_MAC_H_ | 5 #ifndef CONTENT_BROWSER_RENDERER_HOST_BACKING_STORE_MAC_H_ |
| 6 #define CONTENT_BROWSER_RENDERER_HOST_BACKING_STORE_MAC_H_ | 6 #define CONTENT_BROWSER_RENDERER_HOST_BACKING_STORE_MAC_H_ |
| 7 | 7 |
| 8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 #include "base/mac/scoped_cftyperef.h" | 9 #include "base/mac/scoped_cftyperef.h" |
| 10 #include "content/browser/renderer_host/backing_store.h" | 10 #include "content/browser/renderer_host/backing_store.h" |
| 11 | 11 |
| 12 namespace content { |
| 13 |
| 12 class BackingStoreMac : public BackingStore { | 14 class BackingStoreMac : public BackingStore { |
| 13 public: | 15 public: |
| 14 // |size| is in view units, |device_scale_factor| is the backingScaleFactor. | 16 // |size| is in view units, |device_scale_factor| is the backingScaleFactor. |
| 15 // The pixel size of the backing store is size.Scale(device_scale_factor). | 17 // The pixel size of the backing store is size.Scale(device_scale_factor). |
| 16 BackingStoreMac(content::RenderWidgetHost* widget, | 18 BackingStoreMac(RenderWidgetHost* widget, |
| 17 const gfx::Size& size, | 19 const gfx::Size& size, |
| 18 float device_scale_factor); | 20 float device_scale_factor); |
| 19 virtual ~BackingStoreMac(); | 21 virtual ~BackingStoreMac(); |
| 20 | 22 |
| 21 // A CGLayer that stores the contents of the backing store, cached in GPU | 23 // A CGLayer that stores the contents of the backing store, cached in GPU |
| 22 // memory if possible. | 24 // memory if possible. |
| 23 CGLayerRef cg_layer() { return cg_layer_; } | 25 CGLayerRef cg_layer() { return cg_layer_; } |
| 24 | 26 |
| 25 // A CGBitmapContext that stores the contents of the backing store if the | 27 // A CGBitmapContext that stores the contents of the backing store if the |
| 26 // corresponding Cocoa view has not been inserted into an NSWindow yet. | 28 // corresponding Cocoa view has not been inserted into an NSWindow yet. |
| 27 CGContextRef cg_bitmap() { return cg_bitmap_; } | 29 CGContextRef cg_bitmap() { return cg_bitmap_; } |
| 28 | 30 |
| 29 // Called when the view's backing scale factor changes. | 31 // Called when the view's backing scale factor changes. |
| 30 void ScaleFactorChanged(float device_scale_factor); | 32 void ScaleFactorChanged(float device_scale_factor); |
| 31 | 33 |
| 32 // BackingStore implementation. | 34 // BackingStore implementation. |
| 33 virtual size_t MemorySize() OVERRIDE; | 35 virtual size_t MemorySize() OVERRIDE; |
| 34 virtual void PaintToBackingStore( | 36 virtual void PaintToBackingStore( |
| 35 content::RenderProcessHost* process, | 37 RenderProcessHost* process, |
| 36 TransportDIB::Id bitmap, | 38 TransportDIB::Id bitmap, |
| 37 const gfx::Rect& bitmap_rect, | 39 const gfx::Rect& bitmap_rect, |
| 38 const std::vector<gfx::Rect>& copy_rects, | 40 const std::vector<gfx::Rect>& copy_rects, |
| 39 float scale_factor, | 41 float scale_factor, |
| 40 const base::Closure& completion_callback, | 42 const base::Closure& completion_callback, |
| 41 bool* scheduled_completion_callback) OVERRIDE; | 43 bool* scheduled_completion_callback) OVERRIDE; |
| 42 virtual bool CopyFromBackingStore(const gfx::Rect& rect, | 44 virtual bool CopyFromBackingStore(const gfx::Rect& rect, |
| 43 skia::PlatformCanvas* output) OVERRIDE; | 45 skia::PlatformCanvas* output) OVERRIDE; |
| 44 virtual void ScrollBackingStore(int dx, int dy, | 46 virtual void ScrollBackingStore(int dx, int dy, |
| 45 const gfx::Rect& clip_rect, | 47 const gfx::Rect& clip_rect, |
| (...skipping 16 matching lines...) Expand all Loading... |
| 62 | 64 |
| 63 base::mac::ScopedCFTypeRef<CGContextRef> cg_bitmap_; | 65 base::mac::ScopedCFTypeRef<CGContextRef> cg_bitmap_; |
| 64 base::mac::ScopedCFTypeRef<CGLayerRef> cg_layer_; | 66 base::mac::ScopedCFTypeRef<CGLayerRef> cg_layer_; |
| 65 | 67 |
| 66 // Number of physical pixels per view unit. This is 1 or 2 in practice. | 68 // Number of physical pixels per view unit. This is 1 or 2 in practice. |
| 67 float device_scale_factor_; | 69 float device_scale_factor_; |
| 68 | 70 |
| 69 DISALLOW_COPY_AND_ASSIGN(BackingStoreMac); | 71 DISALLOW_COPY_AND_ASSIGN(BackingStoreMac); |
| 70 }; | 72 }; |
| 71 | 73 |
| 74 } // namespace content |
| 75 |
| 72 #endif // CONTENT_BROWSER_RENDERER_HOST_BACKING_STORE_MAC_H_ | 76 #endif // CONTENT_BROWSER_RENDERER_HOST_BACKING_STORE_MAC_H_ |
| OLD | NEW |