Skip to content

Commit

Permalink
revert back to old update method, was more efficient
Browse files Browse the repository at this point in the history
  • Loading branch information
ashea-code committed Feb 17, 2015
1 parent 7c02cd7 commit d5ac649
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 28 deletions.
23 changes: 5 additions & 18 deletions Source/Blu/Private/BluEye.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -95,7 +87,7 @@ void UBluEye::DestroyTexture()
}
}

void UBluEye::TextureUpdate()
void UBluEye::TextureUpdate(const void *buffer)
{
if (!browser || !bEnabled)
{
Expand All @@ -114,7 +106,7 @@ void UBluEye::TextureUpdate()
return;
}

if (texBuffer == nullptr)
if (buffer == nullptr)
{
UE_LOG(LogBlu, Warning, TEXT("NO TEXTDATA"))
return;
Expand All @@ -125,15 +117,15 @@ 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<uint32> ViewBuffer;
ViewBuffer.Init(Width * Height);
FMemory::Memcpy(ViewBuffer.GetData(), texBuffer, size);
FMemory::Memcpy(ViewBuffer.GetData(), buffer, size);

TextureDataPtr dataPtr = MakeShareable(new TextureData);

dataPtr->SetRawData(Width, Height, sizeof(uint32), ViewBuffer);

// Clean up from the per-render
ViewBuffer.Empty();
//texBuffer = 0;
buffer = 0;

ENQUEUE_UNIQUE_RENDER_COMMAND_THREEPARAMETER(
TextureData,
Expand Down Expand Up @@ -406,9 +398,4 @@ void UBluEye::BeginDestroy()

DestroyTexture();
Super::BeginDestroy();
}

void UBluEye::RunTick()
{
TextureUpdate();
}
2 changes: 1 addition & 1 deletion Source/Blu/Private/RenderHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ bool RenderHandler::GetViewRect(CefRefPtr<CefBrowser> browser, CefRect &rect)
void RenderHandler::OnPaint(CefRefPtr<CefBrowser> 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<CefBrowser> browser, CefProcessId source_process, CefRefPtr<CefProcessMessage> message)
Expand Down
11 changes: 2 additions & 9 deletions Source/Blu/Public/BluEye.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<CefBrowser> browser;

void BeginDestroy() override;
void TextureUpdate(const void* buffer);

void updateBuffer(const void *newBuffer);
void BeginDestroy() override; //

protected:
CefWindowInfo info;
Expand All @@ -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);
Expand All @@ -218,6 +213,4 @@ class BLU_API UBluEye : public UObject
CefMouseEvent mouse_event;
CefKeyEvent key_event;

const void *texBuffer;

};

0 comments on commit d5ac649

Please sign in to comment.