From d5ac6499850ca38facd91b2c746556c217554eaf Mon Sep 17 00:00:00 2001 From: AaronShea Date: Tue, 17 Feb 2015 11:05:40 -0500 Subject: [PATCH] revert back to old update method, was more efficient --- Source/Blu/Private/BluEye.cpp | 23 +++++------------------ Source/Blu/Private/RenderHandler.cpp | 2 +- Source/Blu/Public/BluEye.h | 11 ++--------- 3 files changed, 8 insertions(+), 28 deletions(-) diff --git a/Source/Blu/Private/BluEye.cpp b/Source/Blu/Private/BluEye.cpp index 9f14749..5ab8e40 100644 --- a/Source/Blu/Private/BluEye.cpp +++ b/Source/Blu/Private/BluEye.cpp @@ -63,20 +63,12 @@ void UBluEye::ResetTexture() // init the new Texture2D Texture = UTexture2D::CreateTransient(Width, Height, PF_B8G8R8A8); Texture->AddToRoot(); - Texture->LODGroup = TEXTUREGROUP_UI; - Texture->CompressionSettings = TC_EditorIcon; - Texture->Filter = TF_Default; - Texture->UpdateResource(); + Texture->UpdateResourceW(); ResetMatInstance(); } -void UBluEye::updateBuffer(const void* buffer) -{ - texBuffer = buffer; -} - void UBluEye::DestroyTexture() { // Here we destory the texture and its resource @@ -95,7 +87,7 @@ void UBluEye::DestroyTexture() } } -void UBluEye::TextureUpdate() +void UBluEye::TextureUpdate(const void *buffer) { if (!browser || !bEnabled) { @@ -114,7 +106,7 @@ void UBluEye::TextureUpdate() return; } - if (texBuffer == nullptr) + if (buffer == nullptr) { UE_LOG(LogBlu, Warning, TEXT("NO TEXTDATA")) return; @@ -125,7 +117,7 @@ void UBluEye::TextureUpdate() // @TODO This is a bit heavy to keep reallocating/deallocating, but not a big deal. Maybe we can ping pong between buffers instead. TArray ViewBuffer; ViewBuffer.Init(Width * Height); - FMemory::Memcpy(ViewBuffer.GetData(), texBuffer, size); + FMemory::Memcpy(ViewBuffer.GetData(), buffer, size); TextureDataPtr dataPtr = MakeShareable(new TextureData); @@ -133,7 +125,7 @@ void UBluEye::TextureUpdate() // Clean up from the per-render ViewBuffer.Empty(); - //texBuffer = 0; + buffer = 0; ENQUEUE_UNIQUE_RENDER_COMMAND_THREEPARAMETER( TextureData, @@ -406,9 +398,4 @@ void UBluEye::BeginDestroy() DestroyTexture(); Super::BeginDestroy(); -} - -void UBluEye::RunTick() -{ - TextureUpdate(); } \ No newline at end of file diff --git a/Source/Blu/Private/RenderHandler.cpp b/Source/Blu/Private/RenderHandler.cpp index 99b82c8..cedc034 100644 --- a/Source/Blu/Private/RenderHandler.cpp +++ b/Source/Blu/Private/RenderHandler.cpp @@ -16,7 +16,7 @@ bool RenderHandler::GetViewRect(CefRefPtr browser, CefRect &rect) void RenderHandler::OnPaint(CefRefPtr browser, PaintElementType type, const RectList &dirtyRects, const void *buffer, int width, int height) { // Trigger our parent UIs Texture to update - parentUI->updateBuffer(buffer); + parentUI->TextureUpdate(buffer); } bool BrowserClient::OnProcessMessageReceived(CefRefPtr browser, CefProcessId source_process, CefRefPtr message) diff --git a/Source/Blu/Public/BluEye.h b/Source/Blu/Public/BluEye.h index d0c223c..f146adc 100644 --- a/Source/Blu/Public/BluEye.h +++ b/Source/Blu/Public/BluEye.h @@ -180,19 +180,15 @@ class BLU_API UBluEye : public UObject UFUNCTION(BlueprintCallable, Category = "Blu") void CharKeyPress(FCharacterEvent CharEvent); - /* Trigger texture update, should be called every tick */ - UFUNCTION(BlueprintCallable, Category = "Blu") - void RunTick(); - /* Close the browser */ UFUNCTION(BlueprintCallable, Category = "Blu") void CloseBrowser(); CefRefPtr browser; - void BeginDestroy() override; + void TextureUpdate(const void* buffer); - void updateBuffer(const void *newBuffer); + void BeginDestroy() override; // protected: CefWindowInfo info; @@ -203,7 +199,6 @@ class BLU_API UBluEye : public UObject void ResetTexture(); void DestroyTexture(); void ResetMatInstance(); - void TextureUpdate(); // Parse UE4 key events, helper void processKeyCode(FKeyEvent InKey); @@ -218,6 +213,4 @@ class BLU_API UBluEye : public UObject CefMouseEvent mouse_event; CefKeyEvent key_event; - const void *texBuffer; - }; \ No newline at end of file