Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Convert TileController and TileGrid from ObjC to C++
https://bugs.webkit.org/show_bug.cgi?id=133819
<rdar://problem/17291841>

Reviewed by Tim Horton.

Convert TileGrid.mm and TileController.mm into C++ implementations. This required creating a 'frameForLayer'
wrapper to call the 'frame' method of the CALayer object.

* WebCore.xcodeproj/project.pbxproj:
* platform/graphics/ca/mac/TileController.cpp: Copied from platform/graphics/ca/mac/TileController.mm.
(WebCore::TileController::blankPixelCountForTiles):
* platform/graphics/ca/mac/TileController.mm: Removed.
* platform/graphics/ca/mac/TileGrid.cpp: Copied from platform/graphics/ca/mac/TileGrid.mm.
* platform/graphics/ca/mac/TileGrid.h:
* platform/graphics/ca/mac/TileGrid.mm: Removed.
* platform/graphics/mac/WebLayer.h:
* platform/graphics/mac/WebLayer.mm:
(WebCore::frameForLayer): Wrapper function to hide ObjC call from C++ compilation unit.


Canonical link: https://commits.webkit.org/151794@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@169914 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
brentfulgham committed Jun 12, 2014
1 parent 9a75605 commit 72da96f
Show file tree
Hide file tree
Showing 7 changed files with 72 additions and 37 deletions.
22 changes: 22 additions & 0 deletions Source/WebCore/ChangeLog
@@ -1,3 +1,25 @@
2014-06-12 Brent Fulgham <bfulgham@apple.com>

Convert TileController and TileGrid from ObjC to C++
https://bugs.webkit.org/show_bug.cgi?id=133819
<rdar://problem/17291841>

Reviewed by Tim Horton.

Convert TileGrid.mm and TileController.mm into C++ implementations. This required creating a 'frameForLayer'
wrapper to call the 'frame' method of the CALayer object.

* WebCore.xcodeproj/project.pbxproj:
* platform/graphics/ca/mac/TileController.cpp: Copied from platform/graphics/ca/mac/TileController.mm.
(WebCore::TileController::blankPixelCountForTiles):
* platform/graphics/ca/mac/TileController.mm: Removed.
* platform/graphics/ca/mac/TileGrid.cpp: Copied from platform/graphics/ca/mac/TileGrid.mm.
* platform/graphics/ca/mac/TileGrid.h:
* platform/graphics/ca/mac/TileGrid.mm: Removed.
* platform/graphics/mac/WebLayer.h:
* platform/graphics/mac/WebLayer.mm:
(WebCore::frameForLayer): Wrapper function to hide ObjC call from C++ compilation unit.

2014-06-12 Simon Fraser <simon.fraser@apple.com>

[iOS WK2] Fix crash on back/foward swipe
Expand Down
20 changes: 10 additions & 10 deletions Source/WebCore/WebCore.xcodeproj/project.pbxproj
Expand Up @@ -777,7 +777,7 @@
1A927FD31416A15B003A83C8 /* npruntime.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A927FD01416A15B003A83C8 /* npruntime.h */; settings = {ATTRIBUTES = (Private, ); }; };
1A927FD41416A15B003A83C8 /* nptypes.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A927FD11416A15B003A83C8 /* nptypes.h */; settings = {ATTRIBUTES = (Private, ); }; };
1A98956B0AA78F80005EF5EF /* URLCF.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A98956A0AA78F80005EF5EF /* URLCF.cpp */; };
1AA7160A149BC4DB0016EC19 /* TileController.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1AA71608149BC4DA0016EC19 /* TileController.mm */; };
1AA7160A149BC4DB0016EC19 /* TileController.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AA71608149BC4DA0016EC19 /* TileController.cpp */; };
1AA7160B149BC4DB0016EC19 /* TileController.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AA71609149BC4DB0016EC19 /* TileController.h */; settings = {ATTRIBUTES = (Private, ); }; };
1AA84F04143BA7BD0051D153 /* ScrollElasticityController.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1AA84F02143BA7BD0051D153 /* ScrollElasticityController.mm */; };
1AA84F05143BA7BD0051D153 /* ScrollElasticityController.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AA84F03143BA7BD0051D153 /* ScrollElasticityController.h */; settings = {ATTRIBUTES = (Private, ); }; };
Expand Down Expand Up @@ -6145,7 +6145,7 @@
E4BBED4D14FCDBA1003F0B98 /* StyleRule.h in Headers */ = {isa = PBXBuildFile; fileRef = E4BBED4B14FCDBA1003F0B98 /* StyleRule.h */; settings = {ATTRIBUTES = (Private, ); }; };
E4C1789A0EE6903800824D69 /* CSSSelectorList.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E4C178950EE6903800824D69 /* CSSSelectorList.cpp */; };
E4C1789B0EE6903800824D69 /* CSSSelectorList.h in Headers */ = {isa = PBXBuildFile; fileRef = E4C178960EE6903800824D69 /* CSSSelectorList.h */; settings = {ATTRIBUTES = (Private, ); }; };
E4C274CA18E988EA00602C76 /* TileGrid.mm in Sources */ = {isa = PBXBuildFile; fileRef = E4C274C918E988EA00602C76 /* TileGrid.mm */; };
E4C274CA18E988EA00602C76 /* TileGrid.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E4C274C918E988EA00602C76 /* TileGrid.cpp */; };
E4C274CC18E988F500602C76 /* TileGrid.h in Headers */ = {isa = PBXBuildFile; fileRef = E4C274CB18E988F500602C76 /* TileGrid.h */; };
E4C279580CF9741900E97B98 /* RenderMedia.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E4C279560CF9741900E97B98 /* RenderMedia.cpp */; };
E4C279590CF9741900E97B98 /* RenderMedia.h in Headers */ = {isa = PBXBuildFile; fileRef = E4C279570CF9741900E97B98 /* RenderMedia.h */; };
Expand Down Expand Up @@ -7704,7 +7704,7 @@
1A927FD01416A15B003A83C8 /* npruntime.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = npruntime.h; sourceTree = "<group>"; };
1A927FD11416A15B003A83C8 /* nptypes.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = nptypes.h; sourceTree = "<group>"; };
1A98956A0AA78F80005EF5EF /* URLCF.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = URLCF.cpp; sourceTree = "<group>"; };
1AA71608149BC4DA0016EC19 /* TileController.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = TileController.mm; path = ca/mac/TileController.mm; sourceTree = "<group>"; };
1AA71608149BC4DA0016EC19 /* TileController.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = TileController.cpp; path = ca/mac/TileController.cpp; sourceTree = "<group>"; };
1AA71609149BC4DB0016EC19 /* TileController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = TileController.h; path = ca/mac/TileController.h; sourceTree = "<group>"; };
1AA84F02143BA7BD0051D153 /* ScrollElasticityController.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ScrollElasticityController.mm; sourceTree = "<group>"; };
1AA84F03143BA7BD0051D153 /* ScrollElasticityController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ScrollElasticityController.h; sourceTree = "<group>"; };
Expand Down Expand Up @@ -13622,7 +13622,7 @@
E4BBED4B14FCDBA1003F0B98 /* StyleRule.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StyleRule.h; sourceTree = "<group>"; };
E4C178950EE6903800824D69 /* CSSSelectorList.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CSSSelectorList.cpp; sourceTree = "<group>"; };
E4C178960EE6903800824D69 /* CSSSelectorList.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CSSSelectorList.h; sourceTree = "<group>"; };
E4C274C918E988EA00602C76 /* TileGrid.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = TileGrid.mm; path = ca/mac/TileGrid.mm; sourceTree = "<group>"; };
E4C274C918E988EA00602C76 /* TileGrid.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = TileGrid.cpp; path = ca/mac/TileGrid.cpp; sourceTree = "<group>"; };
E4C274CB18E988F500602C76 /* TileGrid.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = TileGrid.h; path = ca/mac/TileGrid.h; sourceTree = "<group>"; };
E4C279560CF9741900E97B98 /* RenderMedia.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RenderMedia.cpp; sourceTree = "<group>"; };
E4C279570CF9741900E97B98 /* RenderMedia.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RenderMedia.h; sourceTree = "<group>"; };
Expand Down Expand Up @@ -15787,12 +15787,8 @@
0F13163F16ED0CDE0035CC04 /* PlatformCAFiltersMac.mm */,
2D70BA1218074DDF0001908A /* PlatformCALayerMac.h */,
4958782012A57DDF007238AC /* PlatformCALayerMac.mm */,
1AA71609149BC4DB0016EC19 /* TileController.h */,
1AA71608149BC4DA0016EC19 /* TileController.mm */,
E4830A3C18F4C5B700154A1B /* TileCoverageMap.h */,
E4830A3818F4C59400154A1B /* TileCoverageMap.mm */,
E4C274CB18E988F500602C76 /* TileGrid.h */,
E4C274C918E988EA00602C76 /* TileGrid.mm */,
0F580FA11496939100FB5BD8 /* WebTiledBackingLayer.h */,
0F580FA21496939100FB5BD8 /* WebTiledBackingLayer.mm */,
);
Expand Down Expand Up @@ -15836,6 +15832,10 @@
2D70BA1418074F850001908A /* PlatformCALayer.cpp */,
499B3EC3128CCC4700E726C2 /* PlatformCALayer.h */,
493E5E0812D6420500020081 /* PlatformCALayerClient.h */,
1AA71609149BC4DB0016EC19 /* TileController.h */,
1AA71608149BC4DA0016EC19 /* TileController.cpp */,
E4C274CB18E988F500602C76 /* TileGrid.h */,
E4C274C918E988EA00602C76 /* TileGrid.cpp */,
494BC40C12AEDD9E00743BD2 /* TransformationMatrixCA.cpp */,
);
name = ca;
Expand Down Expand Up @@ -28519,7 +28519,7 @@
516BB7940CE91E6800512F79 /* JSTreeWalkerCustom.cpp in Sources */,
A86629D009DA2B48009633A5 /* JSUIEvent.cpp in Sources */,
AAA4FAD3175D5CB300743873 /* JSUIRequestEvent.cpp in Sources */,
E4C274CA18E988EA00602C76 /* TileGrid.mm in Sources */,
E4C274CA18E988EA00602C76 /* TileGrid.cpp in Sources */,
15C77094100D3CA8005BA267 /* JSValidityState.cpp in Sources */,
CDE83DB6183D352A0031EAA3 /* JSVideoPlaybackQuality.cpp in Sources */,
07C59B5F17F4B208000FBCBB /* JSVideoStreamTrack.cpp in Sources */,
Expand Down Expand Up @@ -29525,7 +29525,7 @@
E1FF57A60F01256B00891EBB /* ThreadGlobalData.cpp in Sources */,
185BCF280F3279CE000EA262 /* ThreadTimers.cpp in Sources */,
E4C3B1FC0F0E4170009693F6 /* LegacyTileCache.mm in Sources */,
1AA7160A149BC4DB0016EC19 /* TileController.mm in Sources */,
1AA7160A149BC4DB0016EC19 /* TileController.cpp in Sources */,
1F72BF0A187FD4490009BCB3 /* TileControllerMemoryHandlerIOS.cpp in Sources */,
E4B65A5A132FAAF90070E7BE /* LegacyTileGrid.mm in Sources */,
E424A3A01330DF1E00CF6DC9 /* LegacyTileGridTile.mm in Sources */,
Expand Down
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2011, 2012, 2013 Apple Inc. All rights reserved.
* Copyright (C) 2011-2014 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
Expand All @@ -23,21 +23,21 @@
* THE POSSIBILITY OF SUCH DAMAGE.
*/

#import "config.h"
#import "TileController.h"
#include "config.h"
#include "TileController.h"

#import "IntRect.h"
#import "PlatformCALayer.h"
#import "Region.h"
#import "TileCoverageMap.h"
#import "TileGrid.h"
#import "WebLayer.h"
#import "LayerPool.h"
#import <wtf/MainThread.h>
#import <utility>
#include "IntRect.h"
#include "LayerPool.h"
#include "PlatformCALayer.h"
#include "Region.h"
#include "TileCoverageMap.h"
#include "TileGrid.h"
#include "WebLayer.h"
#include <utility>
#include <wtf/MainThread.h>

#if PLATFORM(IOS)
#import "TileControllerMemoryHandlerIOS.h"
#include "TileControllerMemoryHandlerIOS.h"
#endif

namespace WebCore {
Expand Down Expand Up @@ -383,7 +383,7 @@
for (PlatformLayerList::const_iterator it = tiles.begin(), end = tiles.end(); it != end; ++it) {
const PlatformLayer* tileLayer = it->get();

FloatRect visiblePart(CGRectOffset([tileLayer frame], tileTranslation.x(), tileTranslation.y()));
FloatRect visiblePart(CGRectOffset(frameForLayer(tileLayer), tileTranslation.x(), tileTranslation.y()));
visiblePart.intersect(visibleRect);

if (!visiblePart.isEmpty())
Expand Down
Expand Up @@ -23,18 +23,18 @@
* THE POSSIBILITY OF SUCH DAMAGE.
*/

#import "config.h"
#import "TileGrid.h"
#include "config.h"
#include "TileGrid.h"

#import "GraphicsContext.h"
#import "LayerPool.h"
#import "PlatformCALayer.h"
#import "TileController.h"
#import "WebLayer.h"
#import <wtf/MainThread.h>
#include "GraphicsContext.h"
#include "LayerPool.h"
#include "PlatformCALayer.h"
#include "TileController.h"
#include "WebLayer.h"
#include <wtf/MainThread.h>

#if PLATFORM(IOS)
#import "TileControllerMemoryHandlerIOS.h"
#include "TileControllerMemoryHandlerIOS.h"
#endif

namespace WebCore {
Expand Down Expand Up @@ -256,7 +256,7 @@
tiles.append(layer);
}

return TileController::blankPixelCountForTiles(tiles, m_controller.visibleRect(), IntPoint(0,0));
return TileController::blankPixelCountForTiles(tiles, m_controller.visibleRect(), IntPoint(0, 0));
}

void TileGrid::removeTiles(Vector<TileGrid::TileIndex>& toRemove)
Expand Down
4 changes: 4 additions & 0 deletions Source/WebCore/platform/graphics/ca/mac/TileGrid.h
Expand Up @@ -35,6 +35,10 @@
#include <wtf/Noncopyable.h>
#include <wtf/Ref.h>

#if PLATFORM(COCOA)
typedef struct CGContext *CGContextRef;
#endif

namespace WebCore {

class GraphicsContext;
Expand Down
10 changes: 7 additions & 3 deletions Source/WebCore/platform/graphics/mac/WebLayer.h
Expand Up @@ -26,18 +26,21 @@
#ifndef WebLayer_h
#define WebLayer_h

#import <QuartzCore/QuartzCore.h>
#import <WebCore/FloatRect.h>
#import <wtf/Vector.h>
#include "FloatRect.h"
#include "PlatformLayer.h"
#include <QuartzCore/QuartzCore.h>
#include <wtf/Vector.h>

const unsigned webLayerMaxRectsToPaint = 5;
const float webLayerWastedSpaceThreshold = 0.75f;

#ifdef __OBJC__
@interface WebSimpleLayer : CALayer
@end

@interface WebLayer : WebSimpleLayer
@end
#endif

namespace WebCore {
class GraphicsLayer;
Expand All @@ -50,6 +53,7 @@ typedef Vector<FloatRect, webLayerMaxRectsToPaint> RepaintRectList;
RepaintRectList collectRectsToPaint(CGContextRef, PlatformCALayer*);
void drawLayerContents(CGContextRef, PlatformCALayer*, RepaintRectList& dirtyRects);
void drawRepaintIndicator(CGContextRef, PlatformCALayer*, int repaintCount, CGColorRef customBackgroundColor);
CGRect frameForLayer(const PlatformLayer*);
}

#endif // WebLayer_h
5 changes: 5 additions & 0 deletions Source/WebCore/platform/graphics/mac/WebLayer.mm
Expand Up @@ -195,6 +195,11 @@ void drawRepaintIndicator(CGContextRef context, PlatformCALayer* platformCALayer
CGContextRestoreGState(context);
}

CGRect frameForLayer(const PlatformLayer* tileLayer)
{
return [tileLayer frame];
}

}

@implementation WebLayer
Expand Down

0 comments on commit 72da96f

Please sign in to comment.