Browse Source

Protect PlatformPixelBuffer from simultaneous access

The damage tracking region needs to be protected from multiple
threads accessing it at once. The rest should be fine though.
tags/v1.6.90
Pierre Ossman 8 years ago
parent
commit
0b5a06b8ca
2 changed files with 7 additions and 0 deletions
  1. 4
    0
      vncviewer/PlatformPixelBuffer.cxx
  2. 3
    0
      vncviewer/PlatformPixelBuffer.h

+ 4
- 0
vncviewer/PlatformPixelBuffer.cxx View File

@@ -28,15 +28,19 @@ PlatformPixelBuffer::PlatformPixelBuffer(const rfb::PixelFormat& pf,
void PlatformPixelBuffer::commitBufferRW(const rfb::Rect& r)
{
FullFramePixelBuffer::commitBufferRW(r);
mutex.lock();
damage.assign_union(rfb::Region(r));
mutex.unlock();
}

rfb::Rect PlatformPixelBuffer::getDamage(void)
{
rfb::Rect r;

mutex.lock();
r = damage.get_bounding_rect();
damage.clear();
mutex.unlock();

return r;
}

+ 3
- 0
vncviewer/PlatformPixelBuffer.h View File

@@ -19,6 +19,8 @@
#ifndef __PLATFORMPIXELBUFFER_H__
#define __PLATFORMPIXELBUFFER_H__

#include <os/Mutex.h>

#include <rfb/PixelBuffer.h>
#include <rfb/Region.h>

@@ -33,6 +35,7 @@ public:
rfb::Rect getDamage(void);

protected:
os::Mutex mutex;
rfb::Region damage;
};


Loading…
Cancel
Save