Skip to content

Commit

Permalink
Updated code
Browse files Browse the repository at this point in the history
  • Loading branch information
smasherprog committed Mar 6, 2017
2 parents d05526b + 762fea7 commit 2a854b8
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 14 deletions.
1 change: 1 addition & 0 deletions Example/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ set(Screen_Capture_EXAMPLE_SRC
)

include_directories(${SCREEN_CAPTURE_INCLUDE_DIRS})

add_executable(${PROJECT_NAME} ${Screen_Capture_EXAMPLE_SRC})
target_link_libraries(${PROJECT_NAME} ${SCREEN_CAPTURE_LIB})
target_link_libraries(${PROJECT_NAME} ${SYSTEM_LIBS})
Expand Down
2 changes: 1 addition & 1 deletion include/Internal/SCCommon.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ namespace SL {
//Offsets are the number of pixels that a monitor can be from the origin. For example, users can shuffle their monitors around so this affects their offset.
int OffsetX;
int OffsetY;
std::string Name;
char Name[128];
};
struct Image {
ImageRect Bounds;
Expand Down
3 changes: 2 additions & 1 deletion include/ScreenCapture.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include <string>
#include <ostream>


namespace SL {
namespace Screen_Capture {

Expand Down Expand Up @@ -37,7 +38,7 @@ namespace SL {
int Id(const Monitor& mointor);
int OffsetX(const Monitor& mointor);
int OffsetY(const Monitor& mointor);
const std::string& Name(const Monitor& mointor);
const char* Name(const Monitor& mointor);
int Height(const Monitor& mointor);
int Width(const Monitor& mointor);

Expand Down
17 changes: 8 additions & 9 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ endif()

if(WIN32)
set(SCREEN_CAPTURE_PLATFORM_SRC
${CMAKE_CURRENT_SOURCE_DIR}/../src/windows/GetMonitors.cpp
${CMAKE_CURRENT_SOURCE_DIR}/../include/windows/DXFrameProcessor.h
${CMAKE_CURRENT_SOURCE_DIR}/../src/windows/DXFrameProcessor.cpp
${CMAKE_CURRENT_SOURCE_DIR}/../src/windows/GetMonitors.cpp
${CMAKE_CURRENT_SOURCE_DIR}/../include/windows/DXFrameProcessor.h
${CMAKE_CURRENT_SOURCE_DIR}/../src/windows/DXFrameProcessor.cpp
${CMAKE_CURRENT_SOURCE_DIR}/../include/windows/GDIHelpers.h
${CMAKE_CURRENT_SOURCE_DIR}/../include/windows/GDIFrameProcessor.h
${CMAKE_CURRENT_SOURCE_DIR}/../src/windows/GDIFrameProcessor.cpp
${CMAKE_CURRENT_SOURCE_DIR}/../include/windows/GDIFrameProcessor.h
${CMAKE_CURRENT_SOURCE_DIR}/../src/windows/GDIFrameProcessor.cpp
${CMAKE_CURRENT_SOURCE_DIR}/../include/windows/GDIMouseProcessor.h
${CMAKE_CURRENT_SOURCE_DIR}/../src/windows/GDIMouseProcessor.cpp
${CMAKE_CURRENT_SOURCE_DIR}/../src/windows/ThreadRunner.cpp
${CMAKE_CURRENT_SOURCE_DIR}/../src/windows/GDIMouseProcessor.cpp
${CMAKE_CURRENT_SOURCE_DIR}/../src/windows/ThreadRunner.cpp
)

set(SCREEN_CAPTURE_PLATFORM_INC
Expand Down Expand Up @@ -98,10 +98,9 @@ set(SCREEN_CAPTURE_INCLUDE_DIRS
CACHE INTERNAL "${PROJECT_NAME}: Include Directories" FORCE
)


include_directories(${SCREEN_CAPTURE_INCLUDE_DIRS})

add_library(${PROJECT_NAME} ${SCREEN_CAPTURE_COMMON_SRC} ${SCREEN_CAPTURE_PLATFORM_SRC})

target_link_libraries(${PROJECT_NAME} ${SCREEN_CAPTURE_PLATFORM_LIBS})


5 changes: 3 additions & 2 deletions src/Internal/SCCommon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,8 @@ namespace SL {
ret->Index = index;
ret->Height = h;
ret->Id = id;
ret->Name = n;
assert(n.size() + 1 < sizeof(ret->Name));
memcpy(ret->Name, n.c_str(), n.size() + 1);
ret->OffsetX = ox;
ret->OffsetY = oy;
ret->Width = w;
Expand All @@ -152,7 +153,7 @@ namespace SL {
int Id(const Monitor& mointor) { return mointor.Id; }
int OffsetX(const Monitor& mointor) { return mointor.OffsetX; }
int OffsetY(const Monitor& mointor) { return mointor.OffsetY; }
const std::string& Name(const Monitor& mointor) { return mointor.Name; }
const char* Name(const Monitor& mointor) { return mointor.Name; }
int Height(const Monitor& mointor) { return mointor.Height; }
int Width(const Monitor& mointor) { return mointor.Width; }
int Height(const ImageRect& rect) { return rect.bottom - rect.top; }
Expand Down
6 changes: 5 additions & 1 deletion src/windows/DXFrameProcessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -356,13 +356,16 @@ namespace SL {
std::unique_ptr<char[]> OldImageBuffer, NewImageBuffer;
size_t ImageBufferSize;
bool FirstRun;

};


DXFrameProcessor::DXFrameProcessor()
{

DXFrameProcessorImpl_ = std::make_unique<DXFrameProcessorImpl>();
DXFrameProcessorImpl_->ImageBufferSize = 0;

}

DXFrameProcessor::~DXFrameProcessor()
Expand Down Expand Up @@ -392,6 +395,7 @@ namespace SL {
DXFrameProcessorImpl_->OldImageBuffer = std::make_unique<char[]>(DXFrameProcessorImpl_->ImageBufferSize);
}
DXFrameProcessorImpl_->NewImageBuffer = std::make_unique<char[]>(DXFrameProcessorImpl_->ImageBufferSize);

return ret;
}

Expand Down Expand Up @@ -493,6 +497,7 @@ namespace SL {
ret.right = Width(DXFrameProcessorImpl_->Data->SelectedMonitor);

auto startsrc = (char*)MappingDesc.pData;

auto startdst = DXFrameProcessorImpl_->NewImageBuffer.get();
auto rowstride = PixelStride*Width(DXFrameProcessorImpl_->Data->SelectedMonitor);
if (rowstride == static_cast<int>(MappingDesc.RowPitch)) {//no need for multiple calls, there is no padding here
Expand Down Expand Up @@ -551,7 +556,6 @@ namespace SL {
std::swap(DXFrameProcessorImpl_->NewImageBuffer, DXFrameProcessorImpl_->OldImageBuffer);
}


return Ret;
}

Expand Down

0 comments on commit 2a854b8

Please sign in to comment.