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

Side by Side Diff: content/browser/compositor/browser_compositor_ca_layer_tree_mac.mm

Issue 750173002: Move dip utils to gfx/geometry (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add missed android change Created 6 years 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
« no previous file with comments | « no previous file | content/browser/compositor/delegated_frame_host.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/browser/compositor/browser_compositor_ca_layer_tree_mac.h" 5 #include "content/browser/compositor/browser_compositor_ca_layer_tree_mac.h"
6 6
7 #include <map> 7 #include <map>
8 8
9 #include "cc/output/software_frame_data.h" 9 #include "cc/output/software_frame_data.h"
10 #include "base/debug/trace_event.h" 10 #include "base/debug/trace_event.h"
11 #include "base/lazy_instance.h" 11 #include "base/lazy_instance.h"
12 #include "base/message_loop/message_loop.h" 12 #include "base/message_loop/message_loop.h"
13 #include "content/browser/compositor/io_surface_layer_mac.h" 13 #include "content/browser/compositor/io_surface_layer_mac.h"
14 #include "content/browser/compositor/software_layer_mac.h" 14 #include "content/browser/compositor/software_layer_mac.h"
15 #include "content/browser/renderer_host/dip_util.h"
16 #include "content/common/gpu/surface_handle_types_mac.h" 15 #include "content/common/gpu/surface_handle_types_mac.h"
17 #include "content/public/browser/context_factory.h" 16 #include "content/public/browser/context_factory.h"
18 #include "ui/base/cocoa/animation_utils.h" 17 #include "ui/base/cocoa/animation_utils.h"
18 #include "ui/gfx/geometry/dip_util.h"
19 #include "ui/gl/scoped_cgl.h" 19 #include "ui/gl/scoped_cgl.h"
20 20
21 namespace content { 21 namespace content {
22 namespace { 22 namespace {
23 23
24 typedef std::map<gfx::AcceleratedWidget,AcceleratedWidgetMac*> 24 typedef std::map<gfx::AcceleratedWidget,AcceleratedWidgetMac*>
25 WidgetToHelperMap; 25 WidgetToHelperMap;
26 base::LazyInstance<WidgetToHelperMap> g_widget_to_helper_map; 26 base::LazyInstance<WidgetToHelperMap> g_widget_to_helper_map;
27 27
28 AcceleratedWidgetMac* GetHelperFromAcceleratedWidget( 28 AcceleratedWidgetMac* GetHelperFromAcceleratedWidget(
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 138
139 // If there is no view and therefore no superview to draw into, early-out. 139 // If there is no view and therefore no superview to draw into, early-out.
140 if (!view_) { 140 if (!view_) {
141 AcknowledgeAcceleratedFrame(); 141 AcknowledgeAcceleratedFrame();
142 return; 142 return;
143 } 143 }
144 144
145 // Disable the fade-in or fade-out effect if we create or remove layers. 145 // Disable the fade-in or fade-out effect if we create or remove layers.
146 ScopedCAActionDisabler disabler; 146 ScopedCAActionDisabler disabler;
147 147
148 last_swap_size_dip_ = ConvertSizeToDIP(scale_factor, pixel_size); 148 last_swap_size_dip_ = gfx::ConvertSizeToDIP(scale_factor, pixel_size);
149 switch (GetSurfaceHandleType(surface_handle)) { 149 switch (GetSurfaceHandleType(surface_handle)) {
150 case kSurfaceHandleTypeIOSurface: { 150 case kSurfaceHandleTypeIOSurface: {
151 IOSurfaceID io_surface_id = IOSurfaceIDFromSurfaceHandle(surface_handle); 151 IOSurfaceID io_surface_id = IOSurfaceIDFromSurfaceHandle(surface_handle);
152 GotAcceleratedIOSurfaceFrame(io_surface_id, pixel_size, scale_factor); 152 GotAcceleratedIOSurfaceFrame(io_surface_id, pixel_size, scale_factor);
153 break; 153 break;
154 } 154 }
155 case kSurfaceHandleTypeCAContext: { 155 case kSurfaceHandleTypeCAContext: {
156 CAContextID ca_context_id = CAContextIDFromSurfaceHandle(surface_handle); 156 CAContextID ca_context_id = CAContextIDFromSurfaceHandle(surface_handle);
157 GotAcceleratedCAContextFrame(ca_context_id, pixel_size, scale_factor); 157 GotAcceleratedCAContextFrame(ca_context_id, pixel_size, scale_factor);
158 break; 158 break;
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
284 284
285 // Set the software layer to draw the provided canvas. 285 // Set the software layer to draw the provided canvas.
286 SkImageInfo info; 286 SkImageInfo info;
287 size_t row_bytes; 287 size_t row_bytes;
288 const void* pixels = canvas->peekPixels(&info, &row_bytes); 288 const void* pixels = canvas->peekPixels(&info, &row_bytes);
289 gfx::Size pixel_size(info.fWidth, info.fHeight); 289 gfx::Size pixel_size(info.fWidth, info.fHeight);
290 [software_layer_ setContentsToData:pixels 290 [software_layer_ setContentsToData:pixels
291 withRowBytes:row_bytes 291 withRowBytes:row_bytes
292 withPixelSize:pixel_size 292 withPixelSize:pixel_size
293 withScaleFactor:scale_factor]; 293 withScaleFactor:scale_factor];
294 last_swap_size_dip_ = ConvertSizeToDIP(scale_factor, pixel_size); 294 last_swap_size_dip_ = gfx::ConvertSizeToDIP(scale_factor, pixel_size);
295 295
296 // Remove any different-type layers that this is replacing. 296 // Remove any different-type layers that this is replacing.
297 DestroyCAContextLayer(ca_context_layer_); 297 DestroyCAContextLayer(ca_context_layer_);
298 DestroyIOSurfaceLayer(io_surface_layer_); 298 DestroyIOSurfaceLayer(io_surface_layer_);
299 } 299 }
300 300
301 void AcceleratedWidgetMac::DestroyCAContextLayer( 301 void AcceleratedWidgetMac::DestroyCAContextLayer(
302 base::scoped_nsobject<CALayerHost> ca_context_layer) { 302 base::scoped_nsobject<CALayerHost> ca_context_layer) {
303 if (!ca_context_layer) 303 if (!ca_context_layer)
304 return; 304 return;
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
381 void AcceleratedWidgetMacGotSoftwareFrame( 381 void AcceleratedWidgetMacGotSoftwareFrame(
382 gfx::AcceleratedWidget widget, 382 gfx::AcceleratedWidget widget,
383 cc::SoftwareFrameData* frame_data, float scale_factor, SkCanvas* canvas) { 383 cc::SoftwareFrameData* frame_data, float scale_factor, SkCanvas* canvas) {
384 AcceleratedWidgetMac* accelerated_widget_mac = 384 AcceleratedWidgetMac* accelerated_widget_mac =
385 GetHelperFromAcceleratedWidget(widget); 385 GetHelperFromAcceleratedWidget(widget);
386 if (accelerated_widget_mac) 386 if (accelerated_widget_mac)
387 accelerated_widget_mac->GotSoftwareFrame(frame_data, scale_factor, canvas); 387 accelerated_widget_mac->GotSoftwareFrame(frame_data, scale_factor, canvas);
388 } 388 }
389 389
390 } // namespace content 390 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | content/browser/compositor/delegated_frame_host.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698