[aseprite] 48/196: Merge she::LockedSurface/NonDisposableSurface with she::Surface

Tobias Hansen thansen at moszumanska.debian.org
Wed Apr 20 18:49:59 UTC 2016


This is an automated email from the git hooks/post-receive script.

thansen pushed a commit to branch master
in repository aseprite.

commit 0abe01c5f430942985e4498135310ebe2bdba71b
Author: David Capello <davidcapello at gmail.com>
Date:   Wed Mar 9 11:00:17 2016 -0300

    Merge she::LockedSurface/NonDisposableSurface with she::Surface
---
 src/app/ui/brush_popup.cpp                         |  6 +-
 src/app/ui/skin/skin_theme.cpp                     |  7 +--
 src/app/ui/tabs.cpp                                | 15 +++--
 src/doc/conversion_she.cpp                         | 19 +++---
 src/she/alleg4/alleg_display.cpp                   |  4 +-
 src/she/alleg4/alleg_display.h                     |  4 +-
 src/she/alleg4/alleg_surface.cpp                   | 43 ++++++--------
 src/she/alleg4/alleg_surface.h                     | 22 +++----
 .../common/{locked_surface.h => generic_surface.h} | 20 +++----
 src/she/common/sprite_sheet_font.h                 |  8 +--
 src/she/display.h                                  |  5 +-
 src/she/locked_surface.h                           | 58 -------------------
 src/she/scoped_surface_lock.h                      | 29 ----------
 src/she/she.h                                      |  4 +-
 src/she/skia/skia_display.cpp                      |  6 +-
 src/she/skia/skia_display.h                        |  4 +-
 src/she/skia/skia_surface.h                        | 57 +++++++++---------
 src/she/surface.h                                  | 48 ++++++++++++++--
 src/ui/graphics.cpp                                | 67 +++++++++++-----------
 src/ui/manager.cpp                                 | 17 +++---
 src/ui/move_region.cpp                             | 26 ++++-----
 src/ui/overlay.cpp                                 | 25 ++++----
 src/ui/overlay.h                                   |  9 ++-
 src/ui/overlay_manager.cpp                         | 16 +++---
 src/ui/view.cpp                                    |  7 ++-
 src/ui/widget.cpp                                  | 11 ++--
 26 files changed, 230 insertions(+), 307 deletions(-)

diff --git a/src/app/ui/brush_popup.cpp b/src/app/ui/brush_popup.cpp
index fffe167..9f6e598 100644
--- a/src/app/ui/brush_popup.cpp
+++ b/src/app/ui/brush_popup.cpp
@@ -1,5 +1,5 @@
 // Aseprite
-// Copyright (C) 2001-2015  David Capello
+// Copyright (C) 2001-2016  David Capello
 //
 // This program is free software; you can redistribute it and/or modify
 // it under the terms of the GNU General Public License version 2 as
@@ -33,7 +33,6 @@
 #include "doc/palette.h"
 #include "gfx/border.h"
 #include "gfx/region.h"
-#include "she/scoped_surface_lock.h"
 #include "she/surface.h"
 #include "she/system.h"
 #include "ui/button.h"
@@ -457,8 +456,7 @@ she::Surface* BrushPopup::createSurfaceForBrush(const BrushRef& origBrush)
       delete palette;
   }
   else {
-    she::ScopedSurfaceLock lock(surface);
-    lock->clear();
+    surface->clear();
   }
 
   return surface;
diff --git a/src/app/ui/skin/skin_theme.cpp b/src/app/ui/skin/skin_theme.cpp
index 9fe68b3..fb1f8fc 100644
--- a/src/app/ui/skin/skin_theme.cpp
+++ b/src/app/ui/skin/skin_theme.cpp
@@ -33,7 +33,6 @@
 #include "gfx/rect.h"
 #include "gfx/size.h"
 #include "she/font.h"
-#include "she/scoped_surface_lock.h"
 #include "she/surface.h"
 #include "she/system.h"
 #include "ui/intern.h"
@@ -504,9 +503,9 @@ she::Surface* SkinTheme::sliceSheet(she::Surface* sur, const gfx::Rect& bounds)
     sur = she::instance()->createRgbaSurface(bounds.w, bounds.h);
 
   {
-    she::ScopedSurfaceLock src(m_sheet);
-    she::ScopedSurfaceLock dst(sur);
-    src->blitTo(dst, bounds.x, bounds.y, 0, 0, bounds.w, bounds.h);
+    she::SurfaceLock lockSrc(m_sheet);
+    she::SurfaceLock lockDst(sur);
+    m_sheet->blitTo(sur, bounds.x, bounds.y, 0, 0, bounds.w, bounds.h);
   }
 
   sur->applyScale(guiscale());
diff --git a/src/app/ui/tabs.cpp b/src/app/ui/tabs.cpp
index 60529fb..9bd2ddd 100644
--- a/src/app/ui/tabs.cpp
+++ b/src/app/ui/tabs.cpp
@@ -1,5 +1,5 @@
 // Aseprite
-// Copyright (C) 2001-2015  David Capello
+// Copyright (C) 2001-2016  David Capello
 //
 // This program is free software; you can redistribute it and/or modify
 // it under the terms of the GNU General Public License version 2 as
@@ -17,7 +17,6 @@
 #include "app/ui/skin/skin_theme.h"
 #include "app/ui/skin/style.h"
 #include "she/font.h"
-#include "she/scoped_surface_lock.h"
 #include "she/surface.h"
 #include "she/system.h"
 #include "ui/intern.h"
@@ -918,11 +917,11 @@ void Tabs::createFloatingOverlay(Tab* tab)
 
   // Fill the surface with pink color
   {
-    she::ScopedSurfaceLock lock(surface);
+    she::SurfaceLock lock(surface);
 #ifdef USE_ALLEG4_BACKEND
-    lock->fillRect(gfx::rgba(255, 0, 255), gfx::Rect(0, 0, surface->width(), surface->height()));
+    surface->fillRect(gfx::rgba(255, 0, 255), gfx::Rect(0, 0, surface->width(), surface->height()));
 #else
-    lock->fillRect(gfx::rgba(0, 0, 0, 0), gfx::Rect(0, 0, surface->width(), surface->height()));
+    surface->fillRect(gfx::rgba(0, 0, 0, 0), gfx::Rect(0, 0, surface->width(), surface->height()));
 #endif
   }
   {
@@ -933,16 +932,16 @@ void Tabs::createFloatingOverlay(Tab* tab)
 #ifdef USE_ALLEG4_BACKEND
   // Make pink parts transparent (TODO remove this hack when we change the back-end to Skia)
   {
-    she::ScopedSurfaceLock lock(surface);
+    she::SurfaceLock lock(surface);
 
     for (int y=0; y<surface->height(); ++y)
       for (int x=0; x<surface->width(); ++x) {
-        gfx::Color c = lock->getPixel(x, y);
+        gfx::Color c = surface->getPixel(x, y);
         c = (c != gfx::rgba(255, 0, 255, 0) &&
              c != gfx::rgba(255, 0, 255, 255) ?
              gfx::rgba(gfx::getr(c), gfx::getg(c), gfx::getb(c), 255):
              gfx::ColorNone);
-        lock->putPixel(c, x, y);
+        surface->putPixel(c, x, y);
       }
   }
 #endif
diff --git a/src/doc/conversion_she.cpp b/src/doc/conversion_she.cpp
index 2bc7427..5fe3f9a 100644
--- a/src/doc/conversion_she.cpp
+++ b/src/doc/conversion_she.cpp
@@ -1,5 +1,5 @@
 // Aseprite Document Library
-// Copyright (c) 2001-2015 David Capello
+// Copyright (c) 2001-2016 David Capello
 //
 // This file is released under the terms of the MIT license.
 // Read LICENSE.txt for more information.
@@ -18,7 +18,6 @@
 #include "doc/rgbmap.h"
 #include "she/surface.h"
 #include "she/surface_format.h"
-#include "she/scoped_surface_lock.h"
 
 #include <stdexcept>
 
@@ -71,7 +70,7 @@ uint32_t convert_color_to_surface<BitmapTraits, she::kRgbaSurfaceFormat>(color_t
 }
 
 template<typename ImageTraits, typename AddressType>
-void convert_image_to_surface_templ(const Image* image, she::LockedSurface* dst,
+void convert_image_to_surface_templ(const Image* image, she::Surface* dst,
   int src_x, int src_y, int dst_x, int dst_y, int w, int h, const Palette* palette, const she::SurfaceFormatData* fd)
 {
   const LockImageBits<ImageTraits> bits(image, gfx::Rect(src_x, src_y, w, h));
@@ -105,7 +104,7 @@ struct Address24bpp
 };
 
 template<typename ImageTraits>
-void convert_image_to_surface_selector(const Image* image, she::LockedSurface* surface,
+void convert_image_to_surface_selector(const Image* image, she::Surface* surface,
   int src_x, int src_y, int dst_x, int dst_y, int w, int h, const Palette* palette, const she::SurfaceFormatData* fd)
 {
   switch (fd->bitsPerPixel) {
@@ -156,26 +155,26 @@ void convert_image_to_surface(const Image* image, const Palette* palette,
   w = dstBounds.w;
   h = dstBounds.h;
 
-  she::ScopedSurfaceLock dst(surface);
+  she::SurfaceLock lockDst(surface);
   she::SurfaceFormatData fd;
-  dst->getFormat(&fd);
+  surface->getFormat(&fd);
 
   switch (image->pixelFormat()) {
 
     case IMAGE_RGB:
-      convert_image_to_surface_selector<RgbTraits>(image, dst, src_x, src_y, dst_x, dst_y, w, h, palette, &fd);
+      convert_image_to_surface_selector<RgbTraits>(image, surface, src_x, src_y, dst_x, dst_y, w, h, palette, &fd);
       break;
 
     case IMAGE_GRAYSCALE:
-      convert_image_to_surface_selector<GrayscaleTraits>(image, dst, src_x, src_y, dst_x, dst_y, w, h, palette, &fd);
+      convert_image_to_surface_selector<GrayscaleTraits>(image, surface, src_x, src_y, dst_x, dst_y, w, h, palette, &fd);
       break;
 
     case IMAGE_INDEXED:
-      convert_image_to_surface_selector<IndexedTraits>(image, dst, src_x, src_y, dst_x, dst_y, w, h, palette, &fd);
+      convert_image_to_surface_selector<IndexedTraits>(image, surface, src_x, src_y, dst_x, dst_y, w, h, palette, &fd);
       break;
 
     case IMAGE_BITMAP:
-      convert_image_to_surface_selector<BitmapTraits>(image, dst, src_x, src_y, dst_x, dst_y, w, h, palette, &fd);
+      convert_image_to_surface_selector<BitmapTraits>(image, surface, src_x, src_y, dst_x, dst_y, w, h, palette, &fd);
       break;
 
     default:
diff --git a/src/she/alleg4/alleg_display.cpp b/src/she/alleg4/alleg_display.cpp
index 61bbb53..92cf219 100644
--- a/src/she/alleg4/alleg_display.cpp
+++ b/src/she/alleg4/alleg_display.cpp
@@ -478,9 +478,9 @@ void Alleg4Display::recreateSurface()
   m_surface = newSurface;
 }
 
-NonDisposableSurface* Alleg4Display::getSurface()
+Surface* Alleg4Display::getSurface()
 {
-  return static_cast<NonDisposableSurface*>(m_surface);
+  return m_surface;
 }
 
 void Alleg4Display::flip(const gfx::Rect& bounds)
diff --git a/src/she/alleg4/alleg_display.h b/src/she/alleg4/alleg_display.h
index 5a608aa..948a415 100644
--- a/src/she/alleg4/alleg_display.h
+++ b/src/she/alleg4/alleg_display.h
@@ -1,5 +1,5 @@
 // SHE library
-// Copyright (C) 2012-2015  David Capello
+// Copyright (C) 2012-2016  David Capello
 //
 // This file is released under the terms of the MIT license.
 // Read LICENSE.txt for more information.
@@ -27,7 +27,7 @@ namespace she {
     int scale() const override;
     void setScale(int scale) override;
     void recreateSurface();
-    NonDisposableSurface* getSurface() override;
+    Surface* getSurface() override;
     void flip(const gfx::Rect& bounds) override;
     void maximize() override;
     bool isMaximized() const override;
diff --git a/src/she/alleg4/alleg_surface.cpp b/src/she/alleg4/alleg_surface.cpp
index 0daa734..6355aa1 100644
--- a/src/she/alleg4/alleg_surface.cpp
+++ b/src/she/alleg4/alleg_surface.cpp
@@ -1,5 +1,5 @@
 // SHE library
-// Copyright (C) 2012-2015  David Capello
+// Copyright (C) 2012-2016  David Capello
 //
 // This file is released under the terms of the MIT license.
 // Read LICENSE.txt for more information.
@@ -80,23 +80,27 @@ inline gfx::Color from_allegro(int color_depth, int color)
 Alleg4Surface::Alleg4Surface(BITMAP* bmp, DestroyFlag destroy)
   : m_bmp(bmp)
   , m_destroy(destroy)
+  , m_lock(0)
 {
 }
 
 Alleg4Surface::Alleg4Surface(int width, int height, DestroyFlag destroy)
   : m_bmp(create_bitmap(width, height))
   , m_destroy(destroy)
+  , m_lock(0)
 {
 }
 
 Alleg4Surface::Alleg4Surface(int width, int height, int bpp, DestroyFlag destroy)
   : m_bmp(create_bitmap_ex(bpp, width, height))
   , m_destroy(destroy)
+  , m_lock(0)
 {
 }
 
 Alleg4Surface::~Alleg4Surface()
 {
+  ASSERT(m_lock == 0);
   if (m_destroy & DestroyHandle) {
     if (m_bmp)
       destroy_bitmap(m_bmp);
@@ -157,10 +161,18 @@ bool Alleg4Surface::intersectClipRect(const gfx::Rect& rc)
      m_bmp->ct < m_bmp->cb);
 }
 
-LockedSurface* Alleg4Surface::lock()
+void Alleg4Surface::lock()
 {
-  acquire_bitmap(m_bmp);
-  return this;
+  ASSERT(m_lock >= 0);
+  if (m_lock++ == 0)
+    acquire_bitmap(m_bmp);
+}
+
+void Alleg4Surface::unlock()
+{
+  ASSERT(m_lock > 0);
+  if (--m_lock == 0)
+    release_bitmap(m_bmp);
 }
 
 void Alleg4Surface::setDrawMode(DrawMode mode, int param)
@@ -198,23 +210,6 @@ void* Alleg4Surface::nativeHandle()
   return reinterpret_cast<void*>(m_bmp);
 }
 
-// LockedSurface implementation
-
-int Alleg4Surface::lockedWidth() const
-{
-  return m_bmp->w;
-}
-
-int Alleg4Surface::lockedHeight() const
-{
-  return m_bmp->h;
-}
-
-void Alleg4Surface::unlock()
-{
-  release_bitmap(m_bmp);
-}
-
 void Alleg4Surface::clear()
 {
   clear_to_color(m_bmp, 0);
@@ -358,7 +353,7 @@ void Alleg4Surface::fillRect(gfx::Color color, const gfx::Rect& rc)
   solid_mode();
 }
 
-void Alleg4Surface::blitTo(LockedSurface* dest, int srcx, int srcy, int dstx, int dsty, int width, int height) const
+void Alleg4Surface::blitTo(Surface* dest, int srcx, int srcy, int dstx, int dsty, int width, int height) const
 {
   ASSERT(m_bmp);
   ASSERT(dest);
@@ -379,12 +374,12 @@ void Alleg4Surface::scrollTo(const gfx::Rect& rc, int dx, int dy)
        rc.w, rc.h);
 }
 
-void Alleg4Surface::drawSurface(const LockedSurface* src, int dstx, int dsty)
+void Alleg4Surface::drawSurface(const Surface* src, int dstx, int dsty)
 {
   draw_sprite(m_bmp, static_cast<const Alleg4Surface*>(src)->m_bmp, dstx, dsty);
 }
 
-void Alleg4Surface::drawRgbaSurface(const LockedSurface* src, int dstx, int dsty)
+void Alleg4Surface::drawRgbaSurface(const Surface* src, int dstx, int dsty)
 {
   set_alpha_blender();
   draw_trans_sprite(m_bmp, static_cast<const Alleg4Surface*>(src)->m_bmp, dstx, dsty);
diff --git a/src/she/alleg4/alleg_surface.h b/src/she/alleg4/alleg_surface.h
index d0e6369..2636bd4 100644
--- a/src/she/alleg4/alleg_surface.h
+++ b/src/she/alleg4/alleg_surface.h
@@ -1,5 +1,5 @@
 // SHE library
-// Copyright (C) 2012-2015  David Capello
+// Copyright (C) 2012-2016  David Capello
 //
 // This file is released under the terms of the MIT license.
 // Read LICENSE.txt for more information.
@@ -11,12 +11,11 @@
 #include <allegro.h>
 
 #include "she/surface.h"
-#include "she/common/locked_surface.h"
+#include "she/common/generic_surface.h"
 
 namespace she {
 
-  class Alleg4Surface : public Surface
-                      , public CommonLockedSurface {
+  class Alleg4Surface : public GenericSurface<Surface> {
   public:
     enum DestroyFlag {
       None = 0,
@@ -38,15 +37,11 @@ namespace she {
     gfx::Rect getClipBounds() override;
     void setClipBounds(const gfx::Rect& rc) override;
     bool intersectClipRect(const gfx::Rect& rc) override;
-    LockedSurface* lock() override;
+    void lock() override;
+    void unlock() override;
     void setDrawMode(DrawMode mode, int param) override;
     void applyScale(int scale) override;
     void* nativeHandle() override;
-
-    // LockedSurface implementation
-    int lockedWidth() const override;
-    int lockedHeight() const override;
-    void unlock() override;
     void clear() override;
     uint8_t* getData(int x, int y) const override;
     void getFormat(SurfaceFormatData* formatData) const override;
@@ -57,14 +52,15 @@ namespace she {
     void drawLine(gfx::Color color, const gfx::Point& a, const gfx::Point& b) override;
     void drawRect(gfx::Color color, const gfx::Rect& rc) override;
     void fillRect(gfx::Color color, const gfx::Rect& rc) override;
-    void blitTo(LockedSurface* dest, int srcx, int srcy, int dstx, int dsty, int width, int height) const override;
+    void blitTo(Surface* dest, int srcx, int srcy, int dstx, int dsty, int width, int height) const override;
     void scrollTo(const gfx::Rect& rc, int dx, int dy) override;
-    void drawSurface(const LockedSurface* src, int dstx, int dsty) override;
-    void drawRgbaSurface(const LockedSurface* src, int dstx, int dsty) override;
+    void drawSurface(const Surface* src, int dstx, int dsty) override;
+    void drawRgbaSurface(const Surface* src, int dstx, int dsty) override;
 
   private:
     BITMAP* m_bmp;
     DestroyFlag m_destroy;
+    int m_lock;
   };
 
 } // namespace she
diff --git a/src/she/common/locked_surface.h b/src/she/common/generic_surface.h
similarity index 81%
rename from src/she/common/locked_surface.h
rename to src/she/common/generic_surface.h
index 04e7e80..de18e33 100644
--- a/src/she/common/locked_surface.h
+++ b/src/she/common/generic_surface.h
@@ -4,14 +4,12 @@
 // This file is released under the terms of the MIT license.
 // Read LICENSE.txt for more information.
 
-#ifndef SHE_COMMON_LOCKED_SURFACE_H
-#define SHE_COMMON_LOCKED_SURFACE_H
+#ifndef SHE_COMMON_GENERIC_SURFACE_H
+#define SHE_COMMON_GENERIC_SURFACE_H
 #pragma once
 
 #include "gfx/clip.h"
-#include "she/common/font.h"
-#include "she/locked_surface.h"
-#include "she/scoped_surface_lock.h"
+#include "she/common/sprite_sheet_font.h"
 
 namespace she {
 
@@ -52,12 +50,13 @@ gfx::Color blend(const gfx::Color backdrop, gfx::Color src)
 
 } // anoynmous namespace
 
-class CommonLockedSurface : public LockedSurface {
+template<typename Base>
+class GenericSurface : public Base {
 public:
 
-  void drawColoredRgbaSurface(const LockedSurface* src, gfx::Color fg, gfx::Color bg, const gfx::Clip& clipbase) override {
+  void drawColoredRgbaSurface(const Surface* src, gfx::Color fg, gfx::Color bg, const gfx::Clip& clipbase) override {
     gfx::Clip clip(clipbase);
-    if (!clip.clip(lockedWidth(), lockedHeight(), src->lockedWidth(), src->lockedHeight()))
+    if (!clip.clip(width(), height(), src->width(), src->height()))
       return;
 
     SurfaceFormatData format;
@@ -94,8 +93,9 @@ public:
 
     gfx::Rect charBounds = ssFont->getCharBounds(chr);
     if (!charBounds.isEmpty()) {
-      ScopedSurfaceLock lock(ssFont->getSurfaceSheet());
-      drawColoredRgbaSurface(lock, fg, bg, gfx::Clip(x, y, charBounds));
+      Surface* sheet = ssFont->getSurfaceSheet();
+      SurfaceLock lock(sheet);
+      drawColoredRgbaSurface(sheet, fg, bg, gfx::Clip(x, y, charBounds));
     }
   }
 
diff --git a/src/she/common/sprite_sheet_font.h b/src/she/common/sprite_sheet_font.h
index 09a0fdf..5f5206d 100644
--- a/src/she/common/sprite_sheet_font.h
+++ b/src/she/common/sprite_sheet_font.h
@@ -12,8 +12,6 @@
 #include "base/string.h"
 #include "gfx/rect.h"
 #include "she/font.h"
-#include "she/locked_surface.h"
-#include "she/scoped_surface_lock.h"
 #include "she/surface.h"
 
 #include <vector>
@@ -77,10 +75,10 @@ public:
     SpriteSheetFont* font = new SpriteSheetFont;
     font->m_sheet = sur;
 
-    ScopedSurfaceLock surLock(sur);
+    SurfaceLock lock(sur);
     gfx::Rect bounds(0, 0, 1, 1);
 
-    while (font->findChar(surLock, sur->width(), sur->height(), bounds)) {
+    while (font->findChar(sur, sur->width(), sur->height(), bounds)) {
       font->m_chars.push_back(bounds);
       bounds.x += bounds.w;
     }
@@ -90,7 +88,7 @@ public:
 
 private:
 
-  bool findChar(const LockedSurface* sur, int width, int height, gfx::Rect& bounds) {
+  bool findChar(const Surface* sur, int width, int height, gfx::Rect& bounds) {
     gfx::Color keyColor = sur->getPixel(0, 0);
 
     while (sur->getPixel(bounds.x, bounds.y) == keyColor) {
diff --git a/src/she/display.h b/src/she/display.h
index 4c614af..c7aab63 100644
--- a/src/she/display.h
+++ b/src/she/display.h
@@ -1,5 +1,5 @@
 // SHE library
-// Copyright (C) 2012-2015  David Capello
+// Copyright (C) 2012-2016  David Capello
 //
 // This file is released under the terms of the MIT license.
 // Read LICENSE.txt for more information.
@@ -16,7 +16,6 @@
 
 namespace she {
 
-  class NonDisposableSurface;
   class Surface;
   class Font;
 
@@ -46,7 +45,7 @@ namespace she {
 
     // Returns the main surface to draw into this display.
     // You must not dispose this surface.
-    virtual NonDisposableSurface* getSurface() = 0;
+    virtual Surface* getSurface() = 0;
 
     // Flips all graphics in the surface to the real display.
     virtual void flip(const gfx::Rect& bounds) = 0;
diff --git a/src/she/locked_surface.h b/src/she/locked_surface.h
deleted file mode 100644
index bee2615..0000000
--- a/src/she/locked_surface.h
+++ /dev/null
@@ -1,58 +0,0 @@
-// SHE library
-// Copyright (C) 2012-2013, 2015  David Capello
-//
-// This file is released under the terms of the MIT license.
-// Read LICENSE.txt for more information.
-
-#ifndef SHE_LOCKED_SURFACE_H_INCLUDED
-#define SHE_LOCKED_SURFACE_H_INCLUDED
-#pragma once
-
-#include "gfx/color.h"
-#include "gfx/fwd.h"
-#include "she/surface_format.h"
-
-#include <string>
-
-namespace gfx {
-  class Clip;
-}
-
-namespace she {
-
-  class Font;
-
-  class LockedSurface {
-  public:
-    virtual ~LockedSurface() { }
-    virtual int lockedWidth() const = 0;
-    virtual int lockedHeight() const = 0;
-    virtual void unlock() = 0;
-    virtual void clear() = 0;
-
-    virtual uint8_t* getData(int x, int y) const = 0;
-    virtual void getFormat(SurfaceFormatData* formatData) const = 0;
-
-    virtual gfx::Color getPixel(int x, int y) const = 0;
-    virtual void putPixel(gfx::Color color, int x, int y) = 0;
-
-    virtual void drawHLine(gfx::Color color, int x, int y, int w) = 0;
-    virtual void drawVLine(gfx::Color color, int x, int y, int h) = 0;
-    virtual void drawLine(gfx::Color color, const gfx::Point& a, const gfx::Point& b) = 0;
-
-    virtual void drawRect(gfx::Color color, const gfx::Rect& rc) = 0;
-    virtual void fillRect(gfx::Color color, const gfx::Rect& rc) = 0;
-
-    virtual void blitTo(LockedSurface* dest, int srcx, int srcy, int dstx, int dsty, int width, int height) const = 0;
-    virtual void scrollTo(const gfx::Rect& rc, int dx, int dy) = 0;
-    virtual void drawSurface(const LockedSurface* src, int dstx, int dsty) = 0;
-    virtual void drawRgbaSurface(const LockedSurface* src, int dstx, int dsty) = 0;
-    virtual void drawColoredRgbaSurface(const LockedSurface* src, gfx::Color fg, gfx::Color bg, const gfx::Clip& clip) = 0;
-
-    virtual void drawChar(Font* font, gfx::Color fg, gfx::Color bg, int x, int y, int chr) = 0;
-    virtual void drawString(Font* font, gfx::Color fg, gfx::Color bg, int x, int y, const std::string& str) = 0;
-  };
-
-} // namespace she
-
-#endif
diff --git a/src/she/scoped_surface_lock.h b/src/she/scoped_surface_lock.h
deleted file mode 100644
index b780e08..0000000
--- a/src/she/scoped_surface_lock.h
+++ /dev/null
@@ -1,29 +0,0 @@
-// SHE library
-// Copyright (C) 2012-2013  David Capello
-//
-// This file is released under the terms of the MIT license.
-// Read LICENSE.txt for more information.
-
-#ifndef SHE_SCOPED_SURFACE_LOCK_H_INCLUDED
-#define SHE_SCOPED_SURFACE_LOCK_H_INCLUDED
-#pragma once
-
-#include "she/surface.h"
-#include "she/locked_surface.h"
-
-namespace she {
-
-  class ScopedSurfaceLock {
-  public:
-    ScopedSurfaceLock(Surface* surface) : m_lock(surface->lock()) { }
-    ~ScopedSurfaceLock() { m_lock->unlock(); }
-
-    LockedSurface* operator->() { return m_lock; }
-    operator LockedSurface*() { return m_lock; }
-  private:
-    LockedSurface* m_lock;
-  };
-
-} // namespace she
-
-#endif
diff --git a/src/she/she.h b/src/she/she.h
index 97c452e..44d0bec 100644
--- a/src/she/she.h
+++ b/src/she/she.h
@@ -1,5 +1,5 @@
 // SHE library
-// Copyright (C) 2012-2015  David Capello
+// Copyright (C) 2012-2016  David Capello
 //
 // This file is released under the terms of the MIT license.
 // Read LICENSE.txt for more information.
@@ -14,9 +14,7 @@
 #include "she/event.h"
 #include "she/event_queue.h"
 #include "she/font.h"
-#include "she/locked_surface.h"
 #include "she/scoped_handle.h"
-#include "she/scoped_surface_lock.h"
 #include "she/surface.h"
 #include "she/system.h"
 
diff --git a/src/she/skia/skia_display.cpp b/src/she/skia/skia_display.cpp
index 5dc70ae..5389499 100644
--- a/src/she/skia/skia_display.cpp
+++ b/src/she/skia/skia_display.cpp
@@ -1,5 +1,5 @@
 // SHE library
-// Copyright (C) 2012-2015  David Capello
+// Copyright (C) 2012-2016  David Capello
 //
 // This file is released under the terms of the MIT license.
 // Read LICENSE.txt for more information.
@@ -100,9 +100,9 @@ void SkiaDisplay::setScale(int scale)
   m_window.setScale(scale);
 }
 
-NonDisposableSurface* SkiaDisplay::getSurface()
+Surface* SkiaDisplay::getSurface()
 {
-  return static_cast<NonDisposableSurface*>(m_surface);
+  return m_surface;
 }
 
 // Flips all graphics in the surface to the real display.  Returns
diff --git a/src/she/skia/skia_display.h b/src/she/skia/skia_display.h
index b980391..5e78223 100644
--- a/src/she/skia/skia_display.h
+++ b/src/she/skia/skia_display.h
@@ -1,5 +1,5 @@
 // SHE library
-// Copyright (C) 2012-2015  David Capello
+// Copyright (C) 2012-2016  David Capello
 //
 // This file is released under the terms of the MIT license.
 // Read LICENSE.txt for more information.
@@ -39,7 +39,7 @@ public:
 
   // Returns the main surface to draw into this display.
   // You must not dispose this surface.
-  NonDisposableSurface* getSurface() override;
+  Surface* getSurface() override;
 
   // Flips all graphics in the surface to the real display.
   void flip(const gfx::Rect& bounds) override;
diff --git a/src/she/skia/skia_surface.h b/src/she/skia/skia_surface.h
index d2c1d75..e005331 100644
--- a/src/she/skia/skia_surface.h
+++ b/src/she/skia/skia_surface.h
@@ -10,8 +10,6 @@
 
 #include "gfx/clip.h"
 #include "she/common/sprite_sheet_font.h"
-#include "she/locked_surface.h"
-#include "she/scoped_surface_lock.h"
 
 #include "SkBitmap.h"
 #include "SkCanvas.h"
@@ -31,17 +29,18 @@ inline SkIRect to_skia(const gfx::Rect& rc) {
   return SkIRect::MakeXYWH(rc.x, rc.y, rc.w, rc.h);
 }
 
-class SkiaSurface : public NonDisposableSurface
-                  , public LockedSurface {
+class SkiaSurface : public Surface {
 public:
   SkiaSurface() : m_surface(nullptr)
-                , m_canvas(nullptr) {
+                , m_canvas(nullptr)
+                , m_lock(0) {
   }
 
   SkiaSurface(SkSurface* surface)
     : m_surface(surface)
     , m_canvas(nullptr)
     , m_clip(0, 0, width(), height())
+    , m_lock(0)
   {
     ASSERT(m_surface);
     if (m_surface)
@@ -49,6 +48,7 @@ public:
   }
 
   ~SkiaSurface() {
+    ASSERT(m_lock == 0);
     if (!m_surface)
       delete m_canvas;
   }
@@ -155,9 +155,16 @@ public:
     }
   }
 
-  LockedSurface* lock() override {
-    m_bitmap.lockPixels();
-    return this;
+  void lock() override {
+    ASSERT(m_lock >= 0);
+    if (m_lock++ == 0)
+      m_bitmap.lockPixels();
+  }
+
+  void unlock() override {
+    ASSERT(m_lock > 0);
+    if (--m_lock == 0)
+      m_bitmap.unlockPixels();
   }
 
   void applyScale(int scaleFactor) override {
@@ -183,20 +190,6 @@ public:
     return (void*)this;
   }
 
-  // LockedSurface impl
-
-  int lockedWidth() const override {
-    return width();
-  }
-
-  int lockedHeight() const override {
-    return height();
-  }
-
-  void unlock() override {
-    m_bitmap.unlockPixels();
-  }
-
   void clear() override {
     m_canvas->clear(0);
   }
@@ -321,11 +314,12 @@ public:
     m_canvas->drawIRect(to_skia(rc), m_paint);
   }
 
-  void blitTo(LockedSurface* dest, int srcx, int srcy, int dstx, int dsty, int width, int height) const override {
+  void blitTo(Surface* dest, int srcx, int srcy, int dstx, int dsty, int width, int height) const override {
     SkImageInfo info = SkImageInfo::MakeN32Premul(width, height);
     std::vector<uint32_t> pixels(width * height * 4);
     m_canvas->readPixels(info, (void*)&pixels[0], 4*width, srcx, srcy);
-    ((SkiaSurface*)dest)->m_canvas->writePixels(info, (void*)&pixels[0], 4*width, dstx, dsty);
+    static_cast<SkiaSurface*>(dest)
+      ->m_canvas->writePixels(info, (void*)&pixels[0], 4*width, dstx, dsty);
   }
 
   void scrollTo(const gfx::Rect& rc, int dx, int dy) override {
@@ -336,6 +330,7 @@ public:
       return;
 
     if (m_surface) {
+      SurfaceLock lock(this);
       blitTo(this, clip.src.x, clip.src.y, clip.dst.x, clip.dst.y, clip.size.w, clip.size.h);
       return;
     }
@@ -366,7 +361,7 @@ public:
     }
   }
 
-  void drawSurface(const LockedSurface* src, int dstx, int dsty) override {
+  void drawSurface(const Surface* src, int dstx, int dsty) override {
     gfx::Clip clip(dstx, dsty, 0, 0,
       ((SkiaSurface*)src)->width(),
       ((SkiaSurface*)src)->height());
@@ -385,7 +380,7 @@ public:
       SkCanvas::kStrict_SrcRectConstraint);
   }
 
-  void drawRgbaSurface(const LockedSurface* src, int dstx, int dsty) override {
+  void drawRgbaSurface(const Surface* src, int dstx, int dsty) override {
     gfx::Clip clip(dstx, dsty, 0, 0,
       ((SkiaSurface*)src)->width(),
       ((SkiaSurface*)src)->height());
@@ -404,9 +399,9 @@ public:
       SkCanvas::kStrict_SrcRectConstraint);
   }
 
-  void drawColoredRgbaSurface(const LockedSurface* src, gfx::Color fg, gfx::Color bg, const gfx::Clip& clipbase) override {
+  void drawColoredRgbaSurface(const Surface* src, gfx::Color fg, gfx::Color bg, const gfx::Clip& clipbase) override {
     gfx::Clip clip(clipbase);
-    if (!clip.clip(lockedWidth(), lockedHeight(), src->lockedWidth(), src->lockedHeight()))
+    if (!clip.clip(width(), height(), src->width(), src->height()))
       return;
 
     SkRect srcRect = SkRect::Make(SkIRect::MakeXYWH(clip.src.x, clip.src.y, clip.size.w, clip.size.h));
@@ -437,8 +432,9 @@ public:
 
     gfx::Rect charBounds = commonFont->getCharBounds(chr);
     if (!charBounds.isEmpty()) {
-      ScopedSurfaceLock lock(commonFont->getSurfaceSheet());
-      drawColoredRgbaSurface(lock, fg, bg, gfx::Clip(x, y, charBounds));
+      Surface* sheet = commonFont->getSurfaceSheet();
+      SurfaceLock lock(sheet);
+      drawColoredRgbaSurface(sheet, fg, bg, gfx::Clip(x, y, charBounds));
     }
   }
 
@@ -476,6 +472,7 @@ private:
   SkCanvas* m_canvas;
   SkPaint m_paint;
   gfx::Rect m_clip;
+  int m_lock;
 };
 
 } // namespace she
diff --git a/src/she/surface.h b/src/she/surface.h
index f70ee09..1739031 100644
--- a/src/she/surface.h
+++ b/src/she/surface.h
@@ -1,5 +1,5 @@
 // SHE library
-// Copyright (C) 2012-2013, 2015  David Capello
+// Copyright (C) 2012-2016  David Capello
 //
 // This file is released under the terms of the MIT license.
 // Read LICENSE.txt for more information.
@@ -8,11 +8,20 @@
 #define SHE_SURFACE_H_INCLUDED
 #pragma once
 
+#include "gfx/color.h"
 #include "gfx/fwd.h"
+#include "she/surface_format.h"
+
+#include <string>
+
+namespace gfx {
+  class Clip;
+}
 
 namespace she {
 
-  class LockedSurface;
+  class Font;
+  class SurfaceLock;
 
   enum class DrawMode {
     Solid,
@@ -34,16 +43,43 @@ namespace she {
 
     virtual void setDrawMode(DrawMode mode, int param = 0) = 0;
 
-    virtual LockedSurface* lock() = 0;
+    virtual void lock() = 0;
+    virtual void unlock() = 0;
+
+    virtual void clear() = 0;
+
+    virtual uint8_t* getData(int x, int y) const = 0;
+    virtual void getFormat(SurfaceFormatData* formatData) const = 0;
+
+    virtual gfx::Color getPixel(int x, int y) const = 0;
+    virtual void putPixel(gfx::Color color, int x, int y) = 0;
+
+    virtual void drawHLine(gfx::Color color, int x, int y, int w) = 0;
+    virtual void drawVLine(gfx::Color color, int x, int y, int h) = 0;
+    virtual void drawLine(gfx::Color color, const gfx::Point& a, const gfx::Point& b) = 0;
+
+    virtual void drawRect(gfx::Color color, const gfx::Rect& rc) = 0;
+    virtual void fillRect(gfx::Color color, const gfx::Rect& rc) = 0;
+
+    virtual void blitTo(Surface* dest, int srcx, int srcy, int dstx, int dsty, int width, int height) const = 0;
+    virtual void scrollTo(const gfx::Rect& rc, int dx, int dy) = 0;
+    virtual void drawSurface(const Surface* src, int dstx, int dsty) = 0;
+    virtual void drawRgbaSurface(const Surface* src, int dstx, int dsty) = 0;
+    virtual void drawColoredRgbaSurface(const Surface* src, gfx::Color fg, gfx::Color bg, const gfx::Clip& clip) = 0;
+
+    virtual void drawChar(Font* font, gfx::Color fg, gfx::Color bg, int x, int y, int chr) = 0;
+    virtual void drawString(Font* font, gfx::Color fg, gfx::Color bg, int x, int y, const std::string& str) = 0;
+
     virtual void applyScale(int scaleFactor) = 0;
     virtual void* nativeHandle() = 0;
   };
 
-  class NonDisposableSurface : public Surface {
+  class SurfaceLock {
   public:
-    virtual ~NonDisposableSurface() { }
+    SurfaceLock(Surface* surface) : m_surface(surface) { m_surface->lock(); }
+    ~SurfaceLock() { m_surface->unlock(); }
   private:
-    virtual void dispose() = 0;
+    Surface* m_surface;
   };
 
 } // namespace she
diff --git a/src/ui/graphics.cpp b/src/ui/graphics.cpp
index a6dcb97..57dd676 100644
--- a/src/ui/graphics.cpp
+++ b/src/ui/graphics.cpp
@@ -18,7 +18,6 @@
 #include "gfx/size.h"
 #include "she/display.h"
 #include "she/font.h"
-#include "she/scoped_surface_lock.h"
 #include "she/surface.h"
 #include "she/system.h"
 #include "ui/manager.h"
@@ -83,32 +82,32 @@ void Graphics::setDrawMode(DrawMode mode, int param)
 
 gfx::Color Graphics::getPixel(int x, int y)
 {
-  she::ScopedSurfaceLock dst(m_surface);
-  return dst->getPixel(m_dx+x, m_dy+y);
+  she::SurfaceLock lock(m_surface);
+  return m_surface->getPixel(m_dx+x, m_dy+y);
 }
 
 void Graphics::putPixel(gfx::Color color, int x, int y)
 {
   dirty(gfx::Rect(m_dx+x, m_dy+y, 1, 1));
 
-  she::ScopedSurfaceLock dst(m_surface);
-  dst->putPixel(color, m_dx+x, m_dy+y);
+  she::SurfaceLock lock(m_surface);
+  m_surface->putPixel(color, m_dx+x, m_dy+y);
 }
 
 void Graphics::drawHLine(gfx::Color color, int x, int y, int w)
 {
   dirty(gfx::Rect(m_dx+x, m_dy+y, w, 1));
 
-  she::ScopedSurfaceLock dst(m_surface);
-  dst->drawHLine(color, m_dx+x, m_dy+y, w);
+  she::SurfaceLock lock(m_surface);
+  m_surface->drawHLine(color, m_dx+x, m_dy+y, w);
 }
 
 void Graphics::drawVLine(gfx::Color color, int x, int y, int h)
 {
   dirty(gfx::Rect(m_dx+x, m_dy+y, 1, h));
 
-  she::ScopedSurfaceLock dst(m_surface);
-  dst->drawVLine(color, m_dx+x, m_dy+y, h);
+  she::SurfaceLock lock(m_surface);
+  m_surface->drawVLine(color, m_dx+x, m_dy+y, h);
 }
 
 void Graphics::drawLine(gfx::Color color, const gfx::Point& _a, const gfx::Point& _b)
@@ -117,8 +116,8 @@ void Graphics::drawLine(gfx::Color color, const gfx::Point& _a, const gfx::Point
   gfx::Point b(m_dx+_b.x, m_dy+_b.y);
   dirty(gfx::Rect(a, b));
 
-  she::ScopedSurfaceLock dst(m_surface);
-  dst->drawLine(color, a, b);
+  she::SurfaceLock lock(m_surface);
+  m_surface->drawLine(color, a, b);
 }
 
 void Graphics::drawRect(gfx::Color color, const gfx::Rect& rcOrig)
@@ -127,8 +126,8 @@ void Graphics::drawRect(gfx::Color color, const gfx::Rect& rcOrig)
   rc.offset(m_dx, m_dy);
   dirty(rc);
 
-  she::ScopedSurfaceLock dst(m_surface);
-  dst->drawRect(color, rc);
+  she::SurfaceLock lock(m_surface);
+  m_surface->drawRect(color, rc);
 }
 
 void Graphics::fillRect(gfx::Color color, const gfx::Rect& rcOrig)
@@ -137,8 +136,8 @@ void Graphics::fillRect(gfx::Color color, const gfx::Rect& rcOrig)
   rc.offset(m_dx, m_dy);
   dirty(rc);
 
-  she::ScopedSurfaceLock dst(m_surface);
-  dst->fillRect(color, rc);
+  she::SurfaceLock lock(m_surface);
+  m_surface->fillRect(color, rc);
 }
 
 void Graphics::fillRegion(gfx::Color color, const gfx::Region& rgn)
@@ -163,27 +162,27 @@ void Graphics::drawSurface(she::Surface* surface, int x, int y)
 {
   dirty(gfx::Rect(m_dx+x, m_dy+y, surface->width(), surface->height()));
 
-  she::ScopedSurfaceLock src(surface);
-  she::ScopedSurfaceLock dst(m_surface);
-  dst->drawSurface(src, m_dx+x, m_dy+y);
+  she::SurfaceLock lockSrc(surface);
+  she::SurfaceLock lockDst(m_surface);
+  m_surface->drawSurface(surface, m_dx+x, m_dy+y);
 }
 
 void Graphics::drawRgbaSurface(she::Surface* surface, int x, int y)
 {
   dirty(gfx::Rect(m_dx+x, m_dy+y, surface->width(), surface->height()));
 
-  she::ScopedSurfaceLock src(surface);
-  she::ScopedSurfaceLock dst(m_surface);
-  dst->drawRgbaSurface(src, m_dx+x, m_dy+y);
+  she::SurfaceLock lockSrc(surface);
+  she::SurfaceLock lockDst(m_surface);
+  m_surface->drawRgbaSurface(surface, m_dx+x, m_dy+y);
 }
 
 void Graphics::drawColoredRgbaSurface(she::Surface* surface, gfx::Color color, int x, int y)
 {
   dirty(gfx::Rect(m_dx+x, m_dy+y, surface->width(), surface->height()));
 
-  she::ScopedSurfaceLock src(surface);
-  she::ScopedSurfaceLock dst(m_surface);
-  dst->drawColoredRgbaSurface(src, color, gfx::ColorNone,
+  she::SurfaceLock lockSrc(surface);
+  she::SurfaceLock lockDst(m_surface);
+  m_surface->drawColoredRgbaSurface(surface, color, gfx::ColorNone,
     gfx::Clip(m_dx+x, m_dy+y, 0, 0, surface->width(), surface->height()));
 }
 
@@ -191,9 +190,9 @@ void Graphics::blit(she::Surface* srcSurface, int srcx, int srcy, int dstx, int
 {
   dirty(gfx::Rect(m_dx+dstx, m_dy+dsty, w, h));
 
-  she::ScopedSurfaceLock src(srcSurface);
-  she::ScopedSurfaceLock dst(m_surface);
-  src->blitTo(dst, srcx, srcy, m_dx+dstx, m_dy+dsty, w, h);
+  she::SurfaceLock lockSrc(srcSurface);
+  she::SurfaceLock lockDst(m_surface);
+  srcSurface->blitTo(m_surface, srcx, srcy, m_dx+dstx, m_dy+dsty, w, h);
 }
 
 void Graphics::setFont(she::Font* font)
@@ -205,8 +204,8 @@ void Graphics::drawChar(int chr, gfx::Color fg, gfx::Color bg, int x, int y)
 {
   dirty(gfx::Rect(gfx::Point(m_dx+x, m_dy+y), measureChar(chr)));
 
-  she::ScopedSurfaceLock dst(m_surface);
-  dst->drawChar(m_font, fg, bg, m_dx+x, m_dy+y, chr);
+  she::SurfaceLock lock(m_surface);
+  m_surface->drawChar(m_font, fg, bg, m_dx+x, m_dy+y, chr);
 }
 
 void Graphics::drawString(const std::string& str, gfx::Color fg, gfx::Color bg, const gfx::Point& ptOrig)
@@ -214,14 +213,14 @@ void Graphics::drawString(const std::string& str, gfx::Color fg, gfx::Color bg,
   gfx::Point pt(m_dx+ptOrig.x, m_dy+ptOrig.y);
   dirty(gfx::Rect(pt.x, pt.y, m_font->textLength(str), m_font->height()));
 
-  she::ScopedSurfaceLock dst(m_surface);
-  dst->drawString(m_font, fg, bg, pt.x, pt.y, str);
+  she::SurfaceLock lock(m_surface);
+  m_surface->drawString(m_font, fg, bg, pt.x, pt.y, str);
 }
 
 void Graphics::drawUIString(const std::string& str, gfx::Color fg, gfx::Color bg, const gfx::Point& pt,
                             bool drawUnderscore)
 {
-  she::ScopedSurfaceLock dst(m_surface);
+  she::SurfaceLock lock(m_surface);
   base::utf8_const_iterator it(str.begin()), end(str.end());
   int x = m_dx+pt.x;
   int y = m_dy+pt.y;
@@ -236,14 +235,14 @@ void Graphics::drawUIString(const std::string& str, gfx::Color fg, gfx::Color bg
         underscored_w = m_font->charWidth(*it);
       }
     }
-    dst->drawChar(m_font, fg, bg, x, y, *it);
+    m_surface->drawChar(m_font, fg, bg, x, y, *it);
     x += m_font->charWidth(*it);
     ++it;
   }
 
   y += m_font->height();
   if (drawUnderscore && underscored_w > 0) {
-    dst->fillRect(fg,
+    m_surface->fillRect(fg,
       gfx::Rect(underscored_x, y, underscored_w, guiscale()));
     y += guiscale();
   }
diff --git a/src/ui/manager.cpp b/src/ui/manager.cpp
index 4b583f1..a2a1ee5 100644
--- a/src/ui/manager.cpp
+++ b/src/ui/manager.cpp
@@ -18,7 +18,6 @@
 #include "she/display.h"
 #include "she/event.h"
 #include "she/event_queue.h"
-#include "she/scoped_surface_lock.h"
 #include "she/surface.h"
 #include "she/system.h"
 #include "ui/intern.h"
@@ -573,7 +572,7 @@ void Manager::enqueueMessage(Message* msg)
 #ifdef REPORT_EVENTS
   if (msg->type() == kKeyDownMessage ||
       msg->type() == kKeyUpMessage) {
-    int mods = (int)static_cast<KeyMessage*>(msg)->keyModifiers();
+    int mods = (int)static_cast<KeyMessage*>(msg)->modifiers();
     TRACE("Key%s scancode=%d unicode=%d mods=%s%s%s\n",
           (msg->type() == kKeyDownMessage ? "Down": "Up"),
           static_cast<KeyMessage*>(msg)->scancode(),
@@ -715,8 +714,8 @@ void Manager::setMouse(Widget* widget)
   std::cout << "Manager::setMouse ";
   if (widget) {
     std::cout << typeid(*widget).name();
-    if (!widget->getId().empty())
-      std::cout << " (" << widget->getId() << ")";
+    if (!widget->id().empty())
+      std::cout << " (" << widget->id() << ")";
   }
   else {
     std::cout << "null";
@@ -1257,8 +1256,8 @@ void Manager::pumpQueue()
 
         std::cout << "Event " << msg->type() << " (" << string << ") "
                   << "for " << typeid(*widget).name();
-        if (!widget->getId().empty())
-          std::cout << " (" << widget->getId() << ")";
+        if (!widget->id().empty())
+          std::cout << " (" << widget->id() << ")";
         std::cout << std::endl;
       }
 #endif
@@ -1270,7 +1269,7 @@ void Manager::pumpQueue()
           continue;
 
         PaintMessage* paintMsg = static_cast<PaintMessage*>(msg);
-        she::NonDisposableSurface* surface = m_display->getSurface();
+        she::Surface* surface = m_display->getSurface();
         gfx::Rect oldClip = surface->getClipBounds();
 
         if (surface->intersectClipRect(paintMsg->rect())) {
@@ -1285,8 +1284,8 @@ void Manager::pumpQueue()
 
 #ifdef DEBUG_PAINT_EVENTS
           {
-            she::ScopedSurfaceLock lock(surface);
-            lock->fillRect(gfx::rgba(0, 0, 255), paintMsg->rect());
+            she::SurfaceLock lock(surface);
+            surface->fillRect(gfx::rgba(0, 0, 255), paintMsg->rect());
           }
 
           if (m_display)
diff --git a/src/ui/move_region.cpp b/src/ui/move_region.cpp
index f39836e..fe7f804 100644
--- a/src/ui/move_region.cpp
+++ b/src/ui/move_region.cpp
@@ -1,5 +1,5 @@
 // Aseprite UI Library
-// Copyright (C) 2001-2015  David Capello
+// Copyright (C) 2001-2016  David Capello
 //
 // This file is released under the terms of the MIT license.
 // Read LICENSE.txt for more information.
@@ -11,8 +11,6 @@
 #include "ui/manager.h"
 
 #include "she/display.h"
-#include "she/locked_surface.h"
-#include "she/scoped_surface_lock.h"
 #include "she/surface.h"
 #include "she/system.h"
 
@@ -30,13 +28,14 @@ void move_region(Manager* manager, const Region& region, int dx, int dy)
   if (!display)
     return;
 
-  she::ScopedSurfaceLock lock(display->getSurface());
+  she::Surface* surface = display->getSurface();
+  she::SurfaceLock lock(surface);
   std::size_t nrects = region.size();
 
   // Blit directly screen to screen.
   if (nrects == 1) {
     gfx::Rect rc = region[0];
-    lock->scrollTo(rc, dx, dy);
+    surface->scrollTo(rc, dx, dy);
 
     rc.offset(dx, dy);
     Manager::getDefault()->dirtyRect(rc);
@@ -45,28 +44,27 @@ void move_region(Manager* manager, const Region& region, int dx, int dy)
   else if (nrects > 1) {
     std::vector<she::Surface*> images(nrects);
     Region::const_iterator it, begin=region.begin(), end=region.end();
-    she::Surface* sur;
     int c;
 
     for (c=0, it=begin; it != end; ++it, ++c) {
       const Rect& rc = *it;
-      sur = system->createSurface(rc.w, rc.h);
+      she::Surface* tmpSur = system->createSurface(rc.w, rc.h);
       {
-        she::ScopedSurfaceLock surlock(sur);
-        lock->blitTo(surlock, rc.x, rc.y, 0, 0, rc.w, rc.h);
+        she::SurfaceLock tmpSurLock(tmpSur);
+        surface->blitTo(tmpSur, rc.x, rc.y, 0, 0, rc.w, rc.h);
       }
-      images[c] = sur;
+      images[c] = tmpSur;
     }
 
     for (c=0, it=begin; it != end; ++it, ++c) {
       gfx::Rect rc((*it).x+dx, (*it).y+dy, (*it).w, (*it).h);
-      sur = images[c];
+      she::Surface* tmpSur = images[c];
       {
-        she::ScopedSurfaceLock surlock(sur);
-        surlock->blitTo(lock, 0, 0, rc.x, rc.y, rc.w, rc.h);
+        she::SurfaceLock tmpSurLock(tmpSur);
+        tmpSur->blitTo(surface, 0, 0, rc.x, rc.y, rc.w, rc.h);
         manager->dirtyRect(rc);
       }
-      sur->dispose();
+      tmpSur->dispose();
     }
   }
 }
diff --git a/src/ui/overlay.cpp b/src/ui/overlay.cpp
index 5e9fe69..7f8c92d 100644
--- a/src/ui/overlay.cpp
+++ b/src/ui/overlay.cpp
@@ -1,5 +1,5 @@
 // Aseprite UI Library
-// Copyright (C) 2001-2013, 2015  David Capello
+// Copyright (C) 2001-2016  David Capello
 //
 // This file is released under the terms of the MIT license.
 // Read LICENSE.txt for more information.
@@ -10,8 +10,7 @@
 
 #include "ui/overlay.h"
 
-#include "she/locked_surface.h"
-#include "she/scoped_surface_lock.h"
+#include "she/surface.h"
 #include "she/system.h"
 #include "ui/manager.h"
 
@@ -55,13 +54,13 @@ gfx::Rect Overlay::bounds() const
     return gfx::Rect(0, 0, 0, 0);
 }
 
-void Overlay::drawOverlay(she::LockedSurface* screen)
+void Overlay::drawOverlay(she::Surface* screen)
 {
   if (!m_surface)
     return;
 
-  she::ScopedSurfaceLock lockedSurface(m_surface);
-  screen->drawRgbaSurface(lockedSurface, m_pos.x, m_pos.y);
+  she::SurfaceLock lock(m_surface);
+  screen->drawRgbaSurface(m_surface, m_pos.x, m_pos.y);
 
   Manager::getDefault()->dirtyRect(
     gfx::Rect(m_pos.x, m_pos.y,
@@ -74,7 +73,7 @@ void Overlay::moveOverlay(const gfx::Point& newPos)
   m_pos = newPos;
 }
 
-void Overlay::captureOverlappedArea(she::LockedSurface* screen)
+void Overlay::captureOverlappedArea(she::Surface* screen)
 {
   if (!m_surface)
     return;
@@ -82,12 +81,12 @@ void Overlay::captureOverlappedArea(she::LockedSurface* screen)
   if (!m_overlap)
     m_overlap = she::instance()->createSurface(m_surface->width(), m_surface->height());
 
-  she::ScopedSurfaceLock lock(m_overlap);
-  screen->blitTo(lock, m_pos.x, m_pos.y, 0, 0,
+  she::SurfaceLock lock(m_overlap);
+  screen->blitTo(m_overlap, m_pos.x, m_pos.y, 0, 0,
                  m_overlap->width(), m_overlap->height());
 }
 
-void Overlay::restoreOverlappedArea(she::LockedSurface* screen)
+void Overlay::restoreOverlappedArea(she::Surface* screen)
 {
   if (!m_surface)
     return;
@@ -95,9 +94,9 @@ void Overlay::restoreOverlappedArea(she::LockedSurface* screen)
   if (!m_overlap)
     return;
 
-  she::ScopedSurfaceLock lock(m_overlap);
-  lock->blitTo(screen, 0, 0, m_pos.x, m_pos.y,
-               m_overlap->width(), m_overlap->height());
+  she::SurfaceLock lock(m_overlap);
+  m_overlap->blitTo(screen, 0, 0, m_pos.x, m_pos.y,
+                    m_overlap->width(), m_overlap->height());
 
   Manager::getDefault()->dirtyRect(
     gfx::Rect(m_pos.x, m_pos.y,
diff --git a/src/ui/overlay.h b/src/ui/overlay.h
index 48f250a..d07cfe5 100644
--- a/src/ui/overlay.h
+++ b/src/ui/overlay.h
@@ -1,5 +1,5 @@
 // Aseprite UI Library
-// Copyright (C) 2001-2013, 2015  David Capello
+// Copyright (C) 2001-2016  David Capello
 //
 // This file is released under the terms of the MIT license.
 // Read LICENSE.txt for more information.
@@ -14,7 +14,6 @@
 
 namespace she {
   class Surface;
-  class LockedSurface;
 }
 
 namespace ui {
@@ -34,10 +33,10 @@ namespace ui {
     const gfx::Point& position() const { return m_pos; }
     gfx::Rect bounds() const;
 
-    void captureOverlappedArea(she::LockedSurface* screen);
-    void restoreOverlappedArea(she::LockedSurface* screen);
+    void captureOverlappedArea(she::Surface* screen);
+    void restoreOverlappedArea(she::Surface* screen);
 
-    void drawOverlay(she::LockedSurface* screen);
+    void drawOverlay(she::Surface* screen);
     void moveOverlay(const gfx::Point& newPos);
 
     bool operator<(const Overlay& other) const {
diff --git a/src/ui/overlay_manager.cpp b/src/ui/overlay_manager.cpp
index 2b07316..a60e951 100644
--- a/src/ui/overlay_manager.cpp
+++ b/src/ui/overlay_manager.cpp
@@ -1,5 +1,5 @@
 // Aseprite UI Library
-// Copyright (C) 2001-2013, 2015  David Capello
+// Copyright (C) 2001-2013, 2015, 2016  David Capello
 //
 // This file is released under the terms of the MIT license.
 // Read LICENSE.txt for more information.
@@ -11,7 +11,7 @@
 #include "ui/overlay_manager.h"
 
 #include "she/display.h"
-#include "she/scoped_surface_lock.h"
+#include "she/surface.h"
 #include "ui/manager.h"
 #include "ui/overlay.h"
 
@@ -66,9 +66,9 @@ void OverlayManager::captureOverlappedAreas()
     return;
 
   she::Surface* displaySurface = manager->getDisplay()->getSurface();
-  she::ScopedSurfaceLock lockedDisplaySurface(displaySurface);
+  she::SurfaceLock lock(displaySurface);
   for (Overlay* overlay : *this)
-    overlay->captureOverlappedArea(lockedDisplaySurface);
+    overlay->captureOverlappedArea(displaySurface);
 }
 
 void OverlayManager::restoreOverlappedAreas()
@@ -78,9 +78,9 @@ void OverlayManager::restoreOverlappedAreas()
     return;
 
   she::Surface* displaySurface = manager->getDisplay()->getSurface();
-  she::ScopedSurfaceLock lockedDisplaySurface(displaySurface);
+  she::SurfaceLock lock(displaySurface);
   for (Overlay* overlay : *this)
-    overlay->restoreOverlappedArea(lockedDisplaySurface);
+    overlay->restoreOverlappedArea(displaySurface);
 }
 
 void OverlayManager::drawOverlays()
@@ -90,9 +90,9 @@ void OverlayManager::drawOverlays()
     return;
 
   she::Surface* displaySurface = manager->getDisplay()->getSurface();
-  she::ScopedSurfaceLock lockedDisplaySurface(displaySurface);
+  she::SurfaceLock lock(displaySurface);
   for (Overlay* overlay : *this)
-    overlay->drawOverlay(lockedDisplaySurface);
+    overlay->drawOverlay(displaySurface);
 }
 
 } // namespace ui
diff --git a/src/ui/view.cpp b/src/ui/view.cpp
index d9b4c82..87b57e8 100644
--- a/src/ui/view.cpp
+++ b/src/ui/view.cpp
@@ -27,7 +27,7 @@
 #ifdef DEBUG_SCROLL_EVENTS
 #include "base/thread.h"
 #include "she/display.h"
-#include "she/scoped_surface_lock.h"
+#include "she/surface.h"
 #endif
 
 #include <queue>
@@ -326,9 +326,10 @@ void View::onSetViewScroll(const gfx::Point& pt)
       display->flip(gfx::Rect(0, 0, display_w(), display_h()));
     base::this_thread::sleep_for(0.002);
     {
-      she::ScopedSurfaceLock lock(display->getSurface());
+      she::Surface* surface = display->getSurface();
+      she::SurfaceLock lock(surface);
       for (const auto& rc : invalidRegion)
-        lock->fillRect(gfx::rgba(255, 0, 0), rc);
+        surface->fillRect(gfx::rgba(255, 0, 0), rc);
     }
     if (display)
       display->flip(gfx::Rect(0, 0, display_w(), display_h()));
diff --git a/src/ui/widget.cpp b/src/ui/widget.cpp
index fe34114..7c3c2db 100644
--- a/src/ui/widget.cpp
+++ b/src/ui/widget.cpp
@@ -4,7 +4,7 @@
 // This file is released under the terms of the MIT license.
 // Read LICENSE.txt for more information.
 
-/* #define REPORT_SIGNALS */
+// #define REPORT_SIGNALS
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -15,7 +15,6 @@
 #include "base/memory.h"
 #include "she/display.h"
 #include "she/font.h"
-#include "she/scoped_surface_lock.h"
 #include "she/surface.h"
 #include "she/system.h"
 #include "ui/init_theme_event.h"
@@ -1055,9 +1054,11 @@ public:
 
   void operator()(Graphics* graphics) {
     {
-      she::ScopedSurfaceLock src(m_surface);
-      she::ScopedSurfaceLock dst(she::instance()->defaultDisplay()->getSurface());
-      src->blitTo(dst, 0, 0, m_pt.x, m_pt.y,
+      she::Surface* dst = she::instance()->defaultDisplay()->getSurface();
+      she::SurfaceLock lockSrc(m_surface);
+      she::SurfaceLock lockDst(dst);
+      m_surface->blitTo(
+        dst, 0, 0, m_pt.x, m_pt.y,
         m_surface->width(), m_surface->height());
     }
     m_surface->dispose();

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-games/aseprite.git



More information about the Pkg-games-commits mailing list