Changeset 213731 in webkit
- Timestamp:
- Mar 10, 2017 2:56:06 PM (7 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 1 added
- 5 edited
- 5 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r213727 r213731 1 2017-03-10 Dean Jackson <dino@apple.com> 2 3 WebGPU: Backend - Textures and TextureDescriptors 4 https://bugs.webkit.org/show_bug.cgi?id=169365 5 <rdar://problem/30928716> 6 7 Reviewed by Jon Lee with help from Anders Carlsson. 8 9 Backend implementation of textures for WebGPU, which adds 10 the GPUTexture and GPUTextureDescriptor classes, as well 11 as a creation method on GPUDevice. 12 13 * PlatformMac.cmake: 14 * WebCore.xcodeproj/project.pbxproj: 15 * platform/graphics/cocoa/GPUTextureDescriptorMetal.mm: Added. 16 (WebCore::GPUTextureDescriptor::GPUTextureDescriptor): 17 (WebCore::GPUTextureDescriptor::width): 18 (WebCore::GPUTextureDescriptor::setWidth): 19 (WebCore::GPUTextureDescriptor::height): 20 (WebCore::GPUTextureDescriptor::setHeight): 21 (WebCore::GPUTextureDescriptor::sampleCount): 22 (WebCore::GPUTextureDescriptor::setSampleCount): 23 (WebCore::GPUTextureDescriptor::textureType): 24 (WebCore::GPUTextureDescriptor::setTextureType): 25 (WebCore::GPUTextureDescriptor::storageMode): 26 (WebCore::GPUTextureDescriptor::setStorageMode): 27 (WebCore::GPUTextureDescriptor::usage): 28 (WebCore::GPUTextureDescriptor::setUsage): 29 (WebCore::GPUTextureDescriptor::platformTextureDescriptor): 30 * platform/graphics/cocoa/GPUTextureMetal.mm: 31 (WebCore::GPUTexture::GPUTexture): 32 (WebCore::GPUTexture::width): 33 (WebCore::GPUTexture::height): 34 (WebCore::GPUTexture::platformTexture): 35 * platform/graphics/gpu/GPUDevice.cpp: 36 (WebCore::GPUDevice::createTexture): 37 * platform/graphics/gpu/GPUDevice.h: 38 * platform/graphics/gpu/GPUTexture.cpp: 39 (WebCore::GPUTexture::create): 40 (WebCore::GPUTexture::createFromExistingTexture): 41 (WebCore::GPUTexture::~GPUTexture): 42 (WebCore::GPUTexture::width): 43 (WebCore::GPUTexture::height): 44 * platform/graphics/gpu/GPUTexture.h: 45 * platform/graphics/gpu/GPUTextureDescriptor.cpp: 46 (WebCore::GPUTextureDescriptor::create): 47 (WebCore::GPUTextureDescriptor::~GPUTextureDescriptor): 48 (WebCore::GPUTextureDescriptor::width): 49 (WebCore::GPUTextureDescriptor::setWidth): 50 (WebCore::GPUTextureDescriptor::height): 51 (WebCore::GPUTextureDescriptor::setHeight): 52 (WebCore::GPUTextureDescriptor::sampleCount): 53 (WebCore::GPUTextureDescriptor::setSampleCount): 54 (WebCore::GPUTextureDescriptor::textureType): 55 (WebCore::GPUTextureDescriptor::setTextureType): 56 (WebCore::GPUTextureDescriptor::storageMode): 57 (WebCore::GPUTextureDescriptor::setStorageMode): 58 (WebCore::GPUTextureDescriptor::usage): 59 (WebCore::GPUTextureDescriptor::setUsage): 60 * platform/graphics/gpu/GPUTextureDescriptor.h: 61 1 62 2017-03-10 Per Arne Vollan <pvollan@apple.com> 2 63 -
trunk/Source/WebCore/PlatformMac.cmake
r213699 r213731 428 428 platform/graphics/cocoa/GPUFunctionMetal.mm 429 429 platform/graphics/cocoa/GPULibraryMetal.mm 430 platform/graphics/cocoa/GPUTextureDescriptorMetal.mm 431 platform/graphics/cocoa/GPUTextureMetal.mm 430 432 platform/graphics/cocoa/FontCacheCoreText.cpp 431 433 platform/graphics/cocoa/FontCascadeCocoa.mm … … 446 448 platform/graphics/gpu/GPUFunction.cpp 447 449 platform/graphics/gpu/GPULibrary.cpp 450 platform/graphics/gpu/GPUTexture.cpp 451 platform/graphics/gpu/GPUTextureDescriptor.cpp 448 452 449 453 platform/graphics/mac/ColorMac.mm -
trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj
r213684 r213731 1375 1375 316BDBA91E71FA9300DE0D5A /* GPUBuffer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 316BDBA71E71FA9300DE0D5A /* GPUBuffer.cpp */; }; 1376 1376 316BDBAA1E71FA9300DE0D5A /* GPUBuffer.h in Headers */ = {isa = PBXBuildFile; fileRef = 316BDBA81E71FA9300DE0D5A /* GPUBuffer.h */; settings = {ATTRIBUTES = (Private, ); }; }; 1377 316BDBAE1E73549C00DE0D5A /* GPUTextureMetal.mm in Sources */ = {isa = PBXBuildFile; fileRef = 316BDBAD1E73549C00DE0D5A /* GPUTextureMetal.mm */; }; 1378 316BDBB11E7354BB00DE0D5A /* GPUTexture.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 316BDBAF1E7354BB00DE0D5A /* GPUTexture.cpp */; }; 1379 316BDBB21E7354BB00DE0D5A /* GPUTexture.h in Headers */ = {isa = PBXBuildFile; fileRef = 316BDBB01E7354BB00DE0D5A /* GPUTexture.h */; settings = {ATTRIBUTES = (Private, ); }; }; 1380 316BDBB41E7357B000DE0D5A /* GPUTextureDescriptorMetal.mm in Sources */ = {isa = PBXBuildFile; fileRef = 316BDBB31E7357B000DE0D5A /* GPUTextureDescriptorMetal.mm */; }; 1381 316BDBB71E7357CB00DE0D5A /* GPUTextureDescriptor.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 316BDBB51E7357CB00DE0D5A /* GPUTextureDescriptor.cpp */; }; 1382 316BDBB81E7357CB00DE0D5A /* GPUTextureDescriptor.h in Headers */ = {isa = PBXBuildFile; fileRef = 316BDBB61E7357CB00DE0D5A /* GPUTextureDescriptor.h */; settings = {ATTRIBUTES = (Private, ); }; }; 1377 1383 316FE0710E6CCBEE00BF6088 /* JSCSSKeyframeRule.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 316FE06D0E6CCBEE00BF6088 /* JSCSSKeyframeRule.cpp */; }; 1378 1384 316FE0720E6CCBEE00BF6088 /* JSCSSKeyframeRule.h in Headers */ = {isa = PBXBuildFile; fileRef = 316FE06E0E6CCBEE00BF6088 /* JSCSSKeyframeRule.h */; }; … … 8740 8746 316BDBA71E71FA9300DE0D5A /* GPUBuffer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = GPUBuffer.cpp; sourceTree = "<group>"; }; 8741 8747 316BDBA81E71FA9300DE0D5A /* GPUBuffer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GPUBuffer.h; sourceTree = "<group>"; }; 8748 316BDBAD1E73549C00DE0D5A /* GPUTextureMetal.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = GPUTextureMetal.mm; sourceTree = "<group>"; }; 8749 316BDBAF1E7354BB00DE0D5A /* GPUTexture.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = GPUTexture.cpp; sourceTree = "<group>"; }; 8750 316BDBB01E7354BB00DE0D5A /* GPUTexture.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GPUTexture.h; sourceTree = "<group>"; }; 8751 316BDBB31E7357B000DE0D5A /* GPUTextureDescriptorMetal.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = GPUTextureDescriptorMetal.mm; sourceTree = "<group>"; }; 8752 316BDBB51E7357CB00DE0D5A /* GPUTextureDescriptor.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = GPUTextureDescriptor.cpp; sourceTree = "<group>"; }; 8753 316BDBB61E7357CB00DE0D5A /* GPUTextureDescriptor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GPUTextureDescriptor.h; sourceTree = "<group>"; }; 8742 8754 316FE06D0E6CCBEE00BF6088 /* JSCSSKeyframeRule.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSCSSKeyframeRule.cpp; sourceTree = "<group>"; }; 8743 8755 316FE06E0E6CCBEE00BF6088 /* JSCSSKeyframeRule.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSCSSKeyframeRule.h; sourceTree = "<group>"; }; … … 17564 17576 316BDB981E70CBBF00DE0D5A /* GPULibrary.cpp */, 17565 17577 316BDB991E70CBBF00DE0D5A /* GPULibrary.h */, 17578 316BDBB51E7357CB00DE0D5A /* GPUTextureDescriptor.cpp */, 17579 316BDBB61E7357CB00DE0D5A /* GPUTextureDescriptor.h */, 17580 316BDBAF1E7354BB00DE0D5A /* GPUTexture.cpp */, 17581 316BDBB01E7354BB00DE0D5A /* GPUTexture.h */, 17566 17582 498770D71242C535002226BA /* Texture.cpp */, 17567 17583 498770D81242C535002226BA /* Texture.h */, … … 22659 22675 316BDB961E70CA2400DE0D5A /* GPUFunctionMetal.mm */, 22660 22676 316BDB9C1E70CD9000DE0D5A /* GPULibraryMetal.mm */, 22677 316BDBB31E7357B000DE0D5A /* GPUTextureDescriptorMetal.mm */, 22678 316BDBAD1E73549C00DE0D5A /* GPUTextureMetal.mm */, 22661 22679 2D0B4AA918DA1CCD00434DE1 /* IOSurface.h */, 22662 22680 2D0B4AAA18DA1CCD00434DE1 /* IOSurface.mm */, … … 28578 28596 BC2272870E82E70700E7F975 /* StyleReflection.h in Headers */, 28579 28597 E461802D1C8DD2900026C02C /* StyleRelations.h in Headers */, 28598 316BDBB81E7357CB00DE0D5A /* GPUTextureDescriptor.h in Headers */, 28580 28599 5750A9751E68D00000705C4A /* CryptoKeyEC.h in Headers */, 28581 28600 E4D58EB517B4DBDC00CBDCA8 /* StyleResolveForDocument.h in Headers */, … … 29290 29309 E1BE512E0CF6C512002EA959 /* XSLTUnicodeSort.h in Headers */, 29291 29310 977E2E0F12F0FC9C00C13379 /* XSSAuditor.h in Headers */, 29311 316BDBB21E7354BB00DE0D5A /* GPUTexture.h in Headers */, 29292 29312 977E2E0F12F0FC9C00C13380 /* XSSAuditorDelegate.h in Headers */, 29293 29313 A5416FE618810EF80009FC5F /* YouTubeEmbedShadowElement.h in Headers */, … … 30154 30174 49AF2D6C14435D210016A784 /* DisplayRefreshMonitorMac.cpp in Sources */, 30155 30175 2D29ECC7192ECC8300984B78 /* DisplayRefreshMonitorManager.cpp in Sources */, 30176 316BDBAE1E73549C00DE0D5A /* GPUTextureMetal.mm in Sources */, 30156 30177 CD52481A18E200ED0008A07D /* DisplaySleepDisabler.cpp in Sources */, 30157 30178 5D8C4DBF1428222C0026CE72 /* DisplaySleepDisablerCocoa.cpp in Sources */, … … 30679 30700 4F6FDD641341DEDD001F8EE3 /* InspectorPageAgent.cpp in Sources */, 30680 30701 99CC0B6618BE9F15006CEBCC /* InspectorReplayAgent.cpp in Sources */, 30702 316BDBB41E7357B000DE0D5A /* GPUTextureDescriptorMetal.mm in Sources */, 30681 30703 82AB1773125C826700C5069D /* InspectorStyleSheet.cpp in Sources */, 30682 30704 754133AA102E00F400075D00 /* InspectorTimelineAgent.cpp in Sources */, … … 31866 31888 1AF8E1C3125673E000230FF7 /* ProxyServerCFNet.cpp in Sources */, 31867 31889 FF945ECB161F7F3600971BC8 /* PseudoElement.cpp in Sources */, 31890 316BDBB11E7354BB00DE0D5A /* GPUTexture.cpp in Sources */, 31868 31891 0081FEFF16B0A2B6008AAA7A /* PublicSuffixMac.mm in Sources */, 31869 31892 CDEE393717974259001D7580 /* PublicURLManager.cpp in Sources */, … … 32669 32692 AA478A8016CD70C3007D1BB4 /* WebAccessibilityObjectWrapperMac.mm in Sources */, 32670 32693 2D3EF4491917915C00034184 /* WebActionDisablingCALayerDelegate.mm in Sources */, 32694 316BDBB71E7357CB00DE0D5A /* GPUTextureDescriptor.cpp in Sources */, 32671 32695 120DE3ED1C86CA3E00B6D4DD /* WebAnimation.cpp in Sources */, 32672 32696 CDE667A41E4BBF1500E8154A /* WebAudioBufferList.cpp in Sources */, -
trunk/Source/WebCore/platform/graphics/cocoa/GPUTextureMetal.mm
r213730 r213731 25 25 26 26 #include "config.h" 27 #include "GPU Device.h"27 #include "GPUTexture.h" 28 28 29 29 #if ENABLE(WEBGPU) 30 30 31 #include "GPUBuffer.h" 32 #include "GPULibrary.h" 33 #include "Logging.h" 31 #import "GPUDevice.h" 32 #import "GPUTextureDescriptor.h" 33 #import "Logging.h" 34 35 #import <Metal/Metal.h> 34 36 35 37 namespace WebCore { 36 38 37 RefPtr<GPUDevice> GPUDevice::create()39 GPUTexture::GPUTexture(GPUDevice* device, GPUTextureDescriptor* descriptor) 38 40 { 39 RefPtr<GPUDevice> device = adoptRef(new GPUDevice());41 LOG(WebGPU, "GPUTexture::GPUTexture()"); 40 42 41 #if PLATFORM(COCOA) 42 if (!device->platformDevice()) { 43 LOG(WebGPU, "GPUDevice::create() was unable to create the low-level device"); 44 return nullptr; 45 } 46 #endif 43 if (!device || !device->platformDevice() || !descriptor || !descriptor->platformTextureDescriptor()) 44 return; 47 45 48 LOG(WebGPU, "GPUDevice::create() device is %p", device.get()); 49 return device; 46 m_texture = (MTLTexture*)[device->platformDevice() newTextureWithDescriptor:descriptor->platformTextureDescriptor()]; 50 47 } 51 48 52 GPU Device::~GPUDevice()49 GPUTexture::GPUTexture(GPUTexture* other) 53 50 { 54 LOG(WebGPU, "GPUDevice::~GPUDevice()"); 51 LOG(WebGPU, "GPUTexture::GPUTexture()"); 52 53 if (!other || !other->platformTexture()) 54 return; 55 56 m_texture = other->platformTexture(); 55 57 } 56 58 57 RefPtr<GPULibrary> GPUDevice::createLibrary(const String& sourceCode) 59 unsigned long GPUTexture::width() const 58 60 { 59 return GPULibrary::create(this, sourceCode); 61 if (!m_texture) 62 return 0; 63 64 id<MTLTexture> texture = static_cast<id<MTLTexture>>(m_texture.get()); 65 return texture.width; 60 66 } 61 67 62 RefPtr<GPUBuffer> GPUDevice::createBufferFromData(ArrayBufferView* data) 68 unsigned long GPUTexture::height() const 63 69 { 64 return GPUBuffer::create(this, data); 70 if (!m_texture) 71 return 0; 72 73 id<MTLTexture> texture = static_cast<id<MTLTexture>>(m_texture.get()); 74 return texture.height; 65 75 } 66 76 67 #if !PLATFORM(COCOA) 68 69 GPUDevice::GPUDevice() 77 MTLTexture* GPUTexture::platformTexture() 70 78 { 71 79 return m_texture.get(); 72 80 } 73 74 void GPUDevice::reshape(int, int)75 {76 }77 78 #endif79 81 80 82 } // namespace WebCore -
trunk/Source/WebCore/platform/graphics/gpu/GPUDevice.cpp
r213684 r213731 31 31 #include "GPUBuffer.h" 32 32 #include "GPULibrary.h" 33 #include "GPUTexture.h" 34 #include "GPUTextureDescriptor.h" 33 35 #include "Logging.h" 34 36 … … 65 67 } 66 68 69 RefPtr<GPUTexture> GPUDevice::createTexture(GPUTextureDescriptor* descriptor) 70 { 71 return GPUTexture::create(this, descriptor); 72 } 73 67 74 #if !PLATFORM(COCOA) 68 75 -
trunk/Source/WebCore/platform/graphics/gpu/GPUDevice.h
r213684 r213731 49 49 class GPUBuffer; 50 50 class GPULibrary; 51 class GPUTexture; 52 class GPUTextureDescriptor; 51 53 52 54 class GPUDevice : public RefCounted<GPUDevice> { … … 66 68 WEBCORE_EXPORT RefPtr<GPULibrary> createLibrary(const String& sourceCode); 67 69 WEBCORE_EXPORT RefPtr<GPUBuffer> createBufferFromData(ArrayBufferView* data); 70 WEBCORE_EXPORT RefPtr<GPUTexture> createTexture(GPUTextureDescriptor*); 68 71 69 72 private: -
trunk/Source/WebCore/platform/graphics/gpu/GPUTexture.cpp
r213730 r213731 25 25 26 26 #include "config.h" 27 #include "GPU Device.h"27 #include "GPUTexture.h" 28 28 29 29 #if ENABLE(WEBGPU) 30 30 31 #include "GPUBuffer.h" 32 #include "GPULibrary.h" 33 #include "Logging.h" 31 #import "GPUDevice.h" 32 #import "Logging.h" 34 33 35 34 namespace WebCore { 36 35 37 RefPtr<GPU Device> GPUDevice::create()36 RefPtr<GPUTexture> GPUTexture::create(GPUDevice* device, GPUTextureDescriptor* descriptor) 38 37 { 39 RefPtr<GPUDevice> device = adoptRef(new GPUDevice()); 40 41 #if PLATFORM(COCOA) 42 if (!device->platformDevice()) { 43 LOG(WebGPU, "GPUDevice::create() was unable to create the low-level device"); 44 return nullptr; 45 } 46 #endif 47 48 LOG(WebGPU, "GPUDevice::create() device is %p", device.get()); 49 return device; 38 RefPtr<GPUTexture> texture = adoptRef(new GPUTexture(device, descriptor)); 39 return texture; 50 40 } 51 41 52 GPUDevice::~GPUDevice()42 RefPtr<GPUTexture> GPUTexture::createFromExistingTexture(GPUTexture* other) 53 43 { 54 LOG(WebGPU, "GPUDevice::~GPUDevice()"); 44 RefPtr<GPUTexture> texture = adoptRef(new GPUTexture(other)); 45 return texture; 55 46 } 56 47 57 RefPtr<GPULibrary> GPUDevice::createLibrary(const String& sourceCode)48 GPUTexture::~GPUTexture() 58 49 { 59 return GPULibrary::create(this, sourceCode); 60 } 61 62 RefPtr<GPUBuffer> GPUDevice::createBufferFromData(ArrayBufferView* data) 63 { 64 return GPUBuffer::create(this, data); 50 LOG(WebGPU, "GPUTexture::~GPUTexture()"); 65 51 } 66 52 67 53 #if !PLATFORM(COCOA) 68 69 GPUDevice::GPUDevice() 54 unsigned long GPUTexture::width() const 70 55 { 71 56 return 0; 72 57 } 73 58 74 void GPUDevice::reshape(int, int) 59 unsigned long GPUTexture::height() const 75 60 { 61 return 0; 76 62 } 77 78 63 #endif 79 64 -
trunk/Source/WebCore/platform/graphics/gpu/GPUTexture.h
r213730 r213731 28 28 #if ENABLE(WEBGPU) 29 29 30 #include "PlatformLayer.h"31 #include <runtime/ArrayBufferView.h>32 30 #include <wtf/RefCounted.h> 33 34 #if USE(CA) 35 #include "PlatformCALayer.h" 36 #endif 31 #include <wtf/RefPtr.h> 32 #include <wtf/RetainPtr.h> 37 33 38 34 #if PLATFORM(COCOA) 39 typedef struct objc_object* id; 40 OBJC_CLASS CALayer; 41 OBJC_CLASS WebGPULayer; 42 #else 43 class WebGPULayer; 44 typedef void PlatformGPUDevice; 35 OBJC_CLASS MTLTexture; 45 36 #endif 46 37 47 38 namespace WebCore { 48 39 49 class GPU Buffer;50 class GPU Library;40 class GPUDevice; 41 class GPUTextureDescriptor; 51 42 52 class GPU Device : public RefCounted<GPUDevice> {43 class GPUTexture : public RefCounted<GPUTexture> { 53 44 public: 54 WEBCORE_EXPORT static RefPtr<GPUDevice> create(); 55 WEBCORE_EXPORT ~GPUDevice(); 45 static RefPtr<GPUTexture> create(GPUDevice*, GPUTextureDescriptor*); 46 static RefPtr<GPUTexture> createFromExistingTexture(GPUTexture*); 47 WEBCORE_EXPORT ~GPUTexture(); 56 48 57 void reshape(int width, int height); 49 WEBCORE_EXPORT unsigned long width() const; 50 WEBCORE_EXPORT unsigned long height() const; 58 51 59 52 #if PLATFORM(COCOA) 60 CALayer* platformLayer() const { return reinterpret_cast<CALayer*>(m_layer.get()); } 61 WEBCORE_EXPORT id platformDevice(); 53 WEBCORE_EXPORT MTLTexture* platformTexture(); 62 54 #endif 63 55 64 WebGPULayer* layer() { return m_layer.get(); }65 66 WEBCORE_EXPORT RefPtr<GPULibrary> createLibrary(const String& sourceCode);67 WEBCORE_EXPORT RefPtr<GPUBuffer> createBufferFromData(ArrayBufferView* data);68 69 56 private: 70 GPU Device();71 72 RetainPtr<WebGPULayer> m_layer;57 GPUTexture(GPUDevice*, GPUTextureDescriptor*); 58 GPUTexture(GPUTexture*); 59 73 60 #if PLATFORM(COCOA) 74 RetainPtr< id> m_device;61 RetainPtr<MTLTexture> m_texture; 75 62 #endif 76 63 }; 77 64 78 65 } // namespace WebCore 79 80 66 #endif -
trunk/Source/WebCore/platform/graphics/gpu/GPUTextureDescriptor.cpp
r213730 r213731 25 25 26 26 #include "config.h" 27 #include "GPU Device.h"27 #include "GPUTextureDescriptor.h" 28 28 29 29 #if ENABLE(WEBGPU) 30 30 31 #include "GPUBuffer.h" 32 #include "GPULibrary.h" 33 #include "Logging.h" 31 #import "Logging.h" 34 32 35 33 namespace WebCore { 36 34 37 RefPtr<GPU Device> GPUDevice::create()35 RefPtr<GPUTextureDescriptor> GPUTextureDescriptor::create(unsigned long pixelFormat, unsigned long width, unsigned long height, bool mipmapped) 38 36 { 39 RefPtr<GPUDevice> device = adoptRef(new GPUDevice()); 40 41 #if PLATFORM(COCOA) 42 if (!device->platformDevice()) { 43 LOG(WebGPU, "GPUDevice::create() was unable to create the low-level device"); 44 return nullptr; 45 } 46 #endif 47 48 LOG(WebGPU, "GPUDevice::create() device is %p", device.get()); 49 return device; 37 RefPtr<GPUTextureDescriptor> descriptor = adoptRef(new GPUTextureDescriptor(pixelFormat, width, height, mipmapped)); 38 return descriptor; 50 39 } 51 40 52 GPU Device::~GPUDevice()41 GPUTextureDescriptor::~GPUTextureDescriptor() 53 42 { 54 LOG(WebGPU, "GPUDevice::~GPUDevice()"); 55 } 56 57 RefPtr<GPULibrary> GPUDevice::createLibrary(const String& sourceCode) 58 { 59 return GPULibrary::create(this, sourceCode); 60 } 61 62 RefPtr<GPUBuffer> GPUDevice::createBufferFromData(ArrayBufferView* data) 63 { 64 return GPUBuffer::create(this, data); 43 LOG(WebGPU, "GPUTextureDescriptor::~GPUTextureDescriptor()"); 65 44 } 66 45 67 46 #if !PLATFORM(COCOA) 68 69 GPUDevice::GPUDevice() 47 unsigned long GPUTextureDescriptor::width() const 70 48 { 71 49 return 0; 72 50 } 73 51 74 void GPU Device::reshape(int, int)52 void GPUTextureDescriptor::setWidth(unsigned long) 75 53 { 76 54 } 77 55 56 unsigned long GPUTextureDescriptor::height() const 57 { 58 return 0; 59 } 60 61 void GPUTextureDescriptor::setHeight(unsigned long) 62 { 63 } 64 65 unsigned long GPUTextureDescriptor::sampleCount() const 66 { 67 return 0; 68 } 69 70 void GPUTextureDescriptor::setSampleCount(unsigned long) 71 { 72 } 73 74 unsigned long GPUTextureDescriptor::textureType() const 75 { 76 return 0; 77 } 78 79 void GPUTextureDescriptor::setTextureType(unsigned long) 80 { 81 } 82 83 unsigned long GPUTextureDescriptor::storageMode() const 84 { 85 return 0; 86 } 87 88 void GPUTextureDescriptor::setStorageMode(unsigned long) 89 { 90 } 91 92 unsigned long GPUTextureDescriptor::usage() const 93 { 94 return 0; 95 } 96 97 void GPUTextureDescriptor::setUsage(unsigned long) 98 { 99 } 78 100 #endif 79 101 -
trunk/Source/WebCore/platform/graphics/gpu/GPUTextureDescriptor.h
r213730 r213731 28 28 #if ENABLE(WEBGPU) 29 29 30 #include "PlatformLayer.h"31 #include <runtime/ArrayBufferView.h>32 30 #include <wtf/RefCounted.h> 33 34 #if USE(CA) 35 #include "PlatformCALayer.h" 36 #endif 31 #include <wtf/RefPtr.h> 32 #include <wtf/RetainPtr.h> 37 33 38 34 #if PLATFORM(COCOA) 39 typedef struct objc_object* id; 40 OBJC_CLASS CALayer; 41 OBJC_CLASS WebGPULayer; 42 #else 43 class WebGPULayer; 44 typedef void PlatformGPUDevice; 35 OBJC_CLASS MTLTextureDescriptor; 45 36 #endif 46 37 47 38 namespace WebCore { 48 39 49 class GPUBuffer; 50 class GPULibrary; 40 class GPUTextureDescriptor : public RefCounted<GPUTextureDescriptor> { 41 public: 42 static RefPtr<GPUTextureDescriptor> create(unsigned long pixelFormat, unsigned long width, unsigned long height, bool mipmapped); 43 WEBCORE_EXPORT ~GPUTextureDescriptor(); 51 44 52 class GPUDevice : public RefCounted<GPUDevice> { 53 public: 54 WEBCORE_EXPORT static RefPtr<GPUDevice> create(); 55 WEBCORE_EXPORT ~GPUDevice(); 45 WEBCORE_EXPORT unsigned long width() const; 46 WEBCORE_EXPORT void setWidth(unsigned long); 56 47 57 void reshape(int width, int height); 48 WEBCORE_EXPORT unsigned long height() const; 49 WEBCORE_EXPORT void setHeight(unsigned long); 50 51 WEBCORE_EXPORT unsigned long sampleCount() const; 52 WEBCORE_EXPORT void setSampleCount(unsigned long); 53 54 WEBCORE_EXPORT unsigned long textureType() const; 55 WEBCORE_EXPORT void setTextureType(unsigned long); 56 57 WEBCORE_EXPORT unsigned long storageMode() const; 58 WEBCORE_EXPORT void setStorageMode(unsigned long); 59 60 WEBCORE_EXPORT unsigned long usage() const; 61 WEBCORE_EXPORT void setUsage(unsigned long); 58 62 59 63 #if PLATFORM(COCOA) 60 CALayer* platformLayer() const { return reinterpret_cast<CALayer*>(m_layer.get()); } 61 WEBCORE_EXPORT id platformDevice(); 64 WEBCORE_EXPORT MTLTextureDescriptor* platformTextureDescriptor(); 62 65 #endif 63 66 64 WebGPULayer* layer() { return m_layer.get(); } 67 private: 68 GPUTextureDescriptor(unsigned long pixelFormat, unsigned long width, unsigned long height, bool mipmapped); 65 69 66 WEBCORE_EXPORT RefPtr<GPULibrary> createLibrary(const String& sourceCode);67 WEBCORE_EXPORT RefPtr<GPUBuffer> createBufferFromData(ArrayBufferView* data);68 69 private:70 GPUDevice();71 72 RetainPtr<WebGPULayer> m_layer;73 70 #if PLATFORM(COCOA) 74 RetainPtr< id> m_device;71 RetainPtr<MTLTextureDescriptor> m_textureDescriptor; 75 72 #endif 76 73 }; 77 74 78 75 } // namespace WebCore 79 80 76 #endif
Note: See TracChangeset
for help on using the changeset viewer.