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

Side by Side Diff: content/common/gpu/image_transport_surface_iosurface_mac.cc

Issue 1420533005: Mac: Kill lots of AcceleratedWidget code (with fire) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 #include "content/common/gpu/image_transport_surface_iosurface_mac.h" 5 #include "content/common/gpu/image_transport_surface_iosurface_mac.h"
6 6
7 #include "content/common/gpu/gpu_messages.h" 7 #include "content/common/gpu/gpu_messages.h"
8 #include "ui/accelerated_widget_mac/surface_handle_types.h" 8 #include "ui/accelerated_widget_mac/surface_handle_types.h"
9 9
10 namespace content { 10 namespace content {
11 namespace { 11 namespace {
12 12
13 // IOSurface dimensions will be rounded up to a multiple of this value in order 13 // IOSurface dimensions will be rounded up to a multiple of this value in order
14 // to reduce memory thrashing during resize. This must be a power of 2. 14 // to reduce memory thrashing during resize. This must be a power of 2.
15 const uint32 kIOSurfaceDimensionRoundup = 64; 15 const uint32 kIOSurfaceDimensionRoundup = 1;
ccameron 2015/10/22 06:09:28 This is needed so that the IOSurface will always b
16 16
17 int RoundUpSurfaceDimension(int number) { 17 int RoundUpSurfaceDimension(int number) {
18 DCHECK(number >= 0); 18 DCHECK(number >= 0);
19 // Cast into unsigned space for portable bitwise ops. 19 // Cast into unsigned space for portable bitwise ops.
20 uint32 unsigned_number = static_cast<uint32>(number); 20 uint32 unsigned_number = static_cast<uint32>(number);
21 uint32 roundup_sub_1 = kIOSurfaceDimensionRoundup - 1; 21 uint32 roundup_sub_1 = kIOSurfaceDimensionRoundup - 1;
22 unsigned_number = (unsigned_number + roundup_sub_1) & ~roundup_sub_1; 22 unsigned_number = (unsigned_number + roundup_sub_1) & ~roundup_sub_1;
23 return static_cast<int>(unsigned_number); 23 return static_cast<int>(unsigned_number);
24 } 24 }
25 25
(...skipping 26 matching lines...) Expand all
52 gfx::Size IOSurfaceStorageProvider::GetRoundedSize(gfx::Size size) { 52 gfx::Size IOSurfaceStorageProvider::GetRoundedSize(gfx::Size size) {
53 return gfx::Size(RoundUpSurfaceDimension(size.width()), 53 return gfx::Size(RoundUpSurfaceDimension(size.width()),
54 RoundUpSurfaceDimension(size.height())); 54 RoundUpSurfaceDimension(size.height()));
55 } 55 }
56 56
57 bool IOSurfaceStorageProvider::AllocateColorBufferStorage( 57 bool IOSurfaceStorageProvider::AllocateColorBufferStorage(
58 CGLContextObj context, const base::Closure& context_dirtied_callback, 58 CGLContextObj context, const base::Closure& context_dirtied_callback,
59 GLuint texture, gfx::Size pixel_size, float scale_factor) { 59 GLuint texture, gfx::Size pixel_size, float scale_factor) {
60 // Allocate a new IOSurface, which is the GPU resource that can be 60 // Allocate a new IOSurface, which is the GPU resource that can be
61 // shared across processes. 61 // shared across processes.
62 int pixel_format = 'BGRA';
62 base::ScopedCFTypeRef<CFMutableDictionaryRef> properties; 63 base::ScopedCFTypeRef<CFMutableDictionaryRef> properties;
63 properties.reset(CFDictionaryCreateMutable(kCFAllocatorDefault, 64 properties.reset(CFDictionaryCreateMutable(kCFAllocatorDefault,
64 0, 65 0,
65 &kCFTypeDictionaryKeyCallBacks, 66 &kCFTypeDictionaryKeyCallBacks,
66 &kCFTypeDictionaryValueCallBacks)); 67 &kCFTypeDictionaryValueCallBacks));
68 AddIntegerValue(properties, kIOSurfacePixelFormat, pixel_format);
ccameron 2015/10/22 06:09:28 This property is needed for -[CALayer setContents:
67 AddIntegerValue(properties, 69 AddIntegerValue(properties,
68 kIOSurfaceWidth, 70 kIOSurfaceWidth,
69 pixel_size.width()); 71 pixel_size.width());
70 AddIntegerValue(properties, 72 AddIntegerValue(properties,
71 kIOSurfaceHeight, 73 kIOSurfaceHeight,
72 pixel_size.height()); 74 pixel_size.height());
73 AddIntegerValue(properties, 75 AddIntegerValue(properties,
74 kIOSurfaceBytesPerElement, 4); 76 kIOSurfaceBytesPerElement, 4);
75 AddBooleanValue(properties, 77 AddBooleanValue(properties,
76 kIOSurfaceIsGlobal, true); 78 kIOSurfaceIsGlobal, true);
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 void IOSurfaceStorageProvider::DiscardBackbuffer() { 134 void IOSurfaceStorageProvider::DiscardBackbuffer() {
133 } 135 }
134 136
135 void IOSurfaceStorageProvider::SwapBuffersAckedByBrowser( 137 void IOSurfaceStorageProvider::SwapBuffersAckedByBrowser(
136 bool disable_throttling) { 138 bool disable_throttling) {
137 DCHECK(!pending_swapped_surfaces_.empty()); 139 DCHECK(!pending_swapped_surfaces_.empty());
138 pending_swapped_surfaces_.pop_front(); 140 pending_swapped_surfaces_.pop_front();
139 } 141 }
140 142
141 } // namespace content 143 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/renderer_host/render_widget_host_view_mac.mm ('k') | ui/accelerated_widget_mac/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698