mirror of
https://github.com/aseprite/aseprite.git
synced 2025-01-30 15:32:38 +00:00
Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
3b8cc3b8ea
@ -221,7 +221,6 @@ void ColorBar::onRemapButtonClick()
|
||||
try {
|
||||
ContextWriter writer(UIContext::instance());
|
||||
Sprite* sprite = writer.sprite();
|
||||
frame_t frame = writer.frame();
|
||||
if (sprite) {
|
||||
Transaction transaction(writer.context(), "Remap Colors", ModifyDocument);
|
||||
transaction.execute(new cmd::RemapColors(sprite, *m_remap));
|
||||
|
@ -293,7 +293,6 @@ void PaletteView::onPaint(ui::PaintEvent& ev)
|
||||
ui::Graphics* g = ev.getGraphics();
|
||||
gfx::Rect bounds = getClientBounds();
|
||||
Palette* palette = get_current_palette();
|
||||
gfx::Color bordercolor = gfx::rgba(255, 255, 255);
|
||||
|
||||
g->fillRect(gfx::rgba(0, 0, 0), bounds);
|
||||
|
||||
@ -458,7 +457,6 @@ gfx::Rect PaletteView::getPaletteEntryBounds(int index)
|
||||
gfx::Rect bounds = getClientBounds();
|
||||
div_t d = div(Palette::MaxColors, m_columns);
|
||||
int cols = m_columns;
|
||||
int rows = d.quot + (d.rem ? 1: 0);
|
||||
int col = index % cols;
|
||||
int row = index / cols;
|
||||
|
||||
|
@ -388,8 +388,6 @@ void Tabs::onPaint(PaintEvent& ev)
|
||||
g->fillRect(theme->colors.windowFace(), g->getClipBounds());
|
||||
drawFiller(g, box);
|
||||
|
||||
int startX = m_border*guiscale();
|
||||
|
||||
// For each tab...
|
||||
for (Tab* tab : m_list) {
|
||||
if (tab == m_floatingTab)
|
||||
|
@ -766,7 +766,6 @@ bool Timeline::onProcessMessage(Message* msg)
|
||||
|
||||
case kSetCursorMessage:
|
||||
if (m_document) {
|
||||
gfx::Point mousePos = static_cast<MouseMessage*>(msg)->position();
|
||||
setCursor(msg, m_hot);
|
||||
return true;
|
||||
}
|
||||
|
@ -254,12 +254,12 @@ public:
|
||||
}
|
||||
|
||||
const RectT& operator|=(const RectT& rc) {
|
||||
operator=(createUnion(rc));
|
||||
RectT::operator=(createUnion(rc));
|
||||
return *this;
|
||||
}
|
||||
|
||||
const RectT& operator&=(const RectT& rc) {
|
||||
operator=(createIntersect(rc));
|
||||
RectT::operator=(createIntersect(rc));
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
@ -21,8 +21,10 @@ endif()
|
||||
if(USE_SKIA_BACKEND)
|
||||
set(SKIA_BUILD_DIR "" CACHE PATH "Skia build directory")
|
||||
|
||||
add_definitions(-DSK_INTERNAL -DSK_GAMMA_SRGB -DSK_GAMMA_APPLY_TO_A8 -DSK_SCALAR_TO_FLOAT_EXCLUDED -DSK_ALLOW_STATIC_GLOBAL_INITIALIZERS=1 -DSK_SUPPORT_GPU=1 -DSK_SUPPORT_OPENCL=0 -DSK_FORCE_DISTANCE_FIELD_TEXT=0 -DSK_BUILD_FOR_WIN32 -DGR_GL_FUNCTION_TYPE=__stdcall)
|
||||
if(CMAKE_BUILD_TYPE STREQUAL Debug)
|
||||
set(SKIA_BUILD_OUT_DIR "${SKIA_BUILD_DIR}/out/Debug")
|
||||
add_definitions(-DSK_DEVELOPER=1)
|
||||
else()
|
||||
set(SKIA_BUILD_OUT_DIR "${SKIA_BUILD_DIR}/out/Release")
|
||||
endif()
|
||||
|
@ -16,6 +16,7 @@
|
||||
#include "she/osx/native_dialogs.h"
|
||||
#else
|
||||
#include "she/clipboard_simple.h"
|
||||
#include "she/native_dialogs.h"
|
||||
#endif
|
||||
|
||||
#include "she/common/font.h"
|
||||
|
@ -22,22 +22,10 @@
|
||||
#error There is no Window implementation
|
||||
#endif
|
||||
|
||||
// #include "SkApplication.h"
|
||||
// #include "SkCanvas.h"
|
||||
// #include "SkEvent.h"
|
||||
// #include "SkGradientShader.h"
|
||||
#include "SkBitmap.h"
|
||||
// #include "SkGraphics.h"
|
||||
#include "SkImageInfo.h"
|
||||
// #include "SkGr.h"
|
||||
|
||||
#include <queue>
|
||||
|
||||
#include "she/skia/skia_surface.h"
|
||||
#include "she/skia/skia_event_queue.h"
|
||||
#include "she/skia/skia_window.h"
|
||||
#include "she/skia/skia_display.h"
|
||||
#include "she/skia/skia_font.h"
|
||||
#include "she/skia/skia_system.h"
|
||||
|
||||
namespace she {
|
||||
@ -75,12 +63,6 @@ int clock_value()
|
||||
return 0; // clock_var;
|
||||
}
|
||||
|
||||
Font* load_bitmap_font(const char* filename, int scale)
|
||||
{
|
||||
// TODO
|
||||
return new SkiaFont(SkiaFont::DeleteThis);
|
||||
}
|
||||
|
||||
} // namespace she
|
||||
|
||||
extern int app_main(int argc, char* argv[]);
|
||||
|
@ -4,6 +4,8 @@
|
||||
// This file is released under the terms of the MIT license.
|
||||
// Read LICENSE.txt for more information.
|
||||
|
||||
#include <queue>
|
||||
|
||||
namespace she {
|
||||
|
||||
class SkiaEventQueue : public EventQueue {
|
||||
|
@ -6,6 +6,11 @@
|
||||
|
||||
#include "she/common/locked_surface.h"
|
||||
|
||||
#include "SkBitmap.h"
|
||||
#include "SkCanvas.h"
|
||||
#include "SkColorPriv.h"
|
||||
#include "SkImageInfo.h"
|
||||
|
||||
namespace she {
|
||||
|
||||
class SkiaSurface : public NonDisposableSurface
|
||||
@ -16,12 +21,12 @@ public:
|
||||
|
||||
void create(int width, int height) {
|
||||
m_bitmap.tryAllocPixels(
|
||||
SkImageInfo::MakeUnknown(width, height));
|
||||
SkImageInfo::MakeN32Premul(width, height));
|
||||
}
|
||||
|
||||
void createRgba(int width, int height) {
|
||||
m_bitmap.tryAllocPixels(
|
||||
SkImageInfo::MakeN32(width, height, kUnpremul_SkAlphaType));
|
||||
SkImageInfo::MakeN32Premul(width, height));
|
||||
}
|
||||
|
||||
// Surface impl
|
||||
@ -82,6 +87,61 @@ public:
|
||||
}
|
||||
|
||||
void getFormat(SurfaceFormatData* formatData) const override {
|
||||
formatData->format = kRgbaSurfaceFormat;
|
||||
formatData->bitsPerPixel = 8*m_bitmap.bytesPerPixel();
|
||||
|
||||
switch (m_bitmap.colorType()) {
|
||||
case kRGB_565_SkColorType:
|
||||
formatData->redShift = SK_R16_SHIFT;
|
||||
formatData->greenShift = SK_G16_SHIFT;
|
||||
formatData->blueShift = SK_B16_SHIFT;
|
||||
formatData->alphaShift = 0;
|
||||
formatData->redMask = SK_R16_MASK;
|
||||
formatData->greenMask = SK_G16_MASK;
|
||||
formatData->blueMask = SK_B16_MASK;
|
||||
formatData->alphaMask = 0;
|
||||
break;
|
||||
case kARGB_4444_SkColorType:
|
||||
formatData->redShift = SK_R4444_SHIFT;
|
||||
formatData->greenShift = SK_G4444_SHIFT;
|
||||
formatData->blueShift = SK_B4444_SHIFT;
|
||||
formatData->alphaShift = SK_A4444_SHIFT;
|
||||
formatData->redMask = (15 << SK_R4444_SHIFT);
|
||||
formatData->greenMask = (15 << SK_G4444_SHIFT);
|
||||
formatData->blueMask = (15 << SK_B4444_SHIFT);
|
||||
formatData->alphaMask = (15 << SK_A4444_SHIFT);
|
||||
break;
|
||||
case kRGBA_8888_SkColorType:
|
||||
formatData->redShift = SK_RGBA_R32_SHIFT;
|
||||
formatData->greenShift = SK_RGBA_G32_SHIFT;
|
||||
formatData->blueShift = SK_RGBA_B32_SHIFT;
|
||||
formatData->alphaShift = SK_RGBA_A32_SHIFT;
|
||||
formatData->redMask = ((1 << SK_RGBA_R32_SHIFT) - 1);
|
||||
formatData->greenMask = ((1 << SK_RGBA_G32_SHIFT) - 1);
|
||||
formatData->blueMask = ((1 << SK_RGBA_B32_SHIFT) - 1);
|
||||
formatData->alphaMask = ((1 << SK_RGBA_A32_SHIFT) - 1);
|
||||
break;
|
||||
case kBGRA_8888_SkColorType:
|
||||
formatData->redShift = SK_BGRA_R32_SHIFT;
|
||||
formatData->greenShift = SK_BGRA_G32_SHIFT;
|
||||
formatData->blueShift = SK_BGRA_B32_SHIFT;
|
||||
formatData->alphaShift = SK_BGRA_A32_SHIFT;
|
||||
formatData->redMask = ((1 << SK_BGRA_R32_SHIFT) - 1);
|
||||
formatData->greenMask = ((1 << SK_BGRA_G32_SHIFT) - 1);
|
||||
formatData->blueMask = ((1 << SK_BGRA_B32_SHIFT) - 1);
|
||||
formatData->alphaMask = ((1 << SK_BGRA_A32_SHIFT) - 1);
|
||||
break;
|
||||
default:
|
||||
formatData->redShift = 0;
|
||||
formatData->greenShift = 0;
|
||||
formatData->blueShift = 0;
|
||||
formatData->alphaShift = 0;
|
||||
formatData->redMask = 0;
|
||||
formatData->greenMask = 0;
|
||||
formatData->blueMask = 0;
|
||||
formatData->alphaMask = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
gfx::Color getPixel(int x, int y) const override {
|
||||
@ -115,9 +175,15 @@ public:
|
||||
}
|
||||
|
||||
void drawSurface(const LockedSurface* src, int dstx, int dsty) override {
|
||||
SkCanvas canvas(m_bitmap);
|
||||
canvas.drawBitmap(((SkiaSurface*)src)->m_bitmap,
|
||||
SkIntToScalar(dstx), SkIntToScalar(dsty), nullptr);
|
||||
}
|
||||
|
||||
void drawRgbaSurface(const LockedSurface* src, int dstx, int dsty) override {
|
||||
SkCanvas canvas(m_bitmap);
|
||||
canvas.drawBitmap(((SkiaSurface*)src)->m_bitmap,
|
||||
SkIntToScalar(dstx), SkIntToScalar(dsty), nullptr);
|
||||
}
|
||||
|
||||
SkBitmap& bitmap() {
|
||||
|
@ -4,6 +4,12 @@
|
||||
// This file is released under the terms of the MIT license.
|
||||
// Read LICENSE.txt for more information.
|
||||
|
||||
#include "base/file_handle.h"
|
||||
|
||||
#include "SkImageDecoder.h"
|
||||
#include "SkPixelRef.h"
|
||||
#include "SkStream.h"
|
||||
|
||||
namespace she {
|
||||
|
||||
class SkiaSystem : public CommonSystem {
|
||||
@ -50,15 +56,31 @@ public:
|
||||
}
|
||||
|
||||
Surface* loadSurface(const char* filename) override {
|
||||
SkiaSurface* sur = new SkiaSurface;
|
||||
sur->create(32, 32);
|
||||
return sur;
|
||||
base::FileHandle fp(base::open_file_with_exception(filename, "rb"));
|
||||
SkAutoTDelete<SkStreamAsset> stream(SkNEW_ARGS(SkFILEStream, (fp, SkFILEStream::kCallerRetains_Ownership)));
|
||||
|
||||
SkAutoTDelete<SkImageDecoder> decoder(SkImageDecoder::Factory(stream));
|
||||
decoder->setRequireUnpremultipliedColors(true);
|
||||
|
||||
if (decoder) {
|
||||
stream->rewind();
|
||||
SkBitmap bm;
|
||||
SkImageDecoder::Result res = decoder->decode(stream, &bm,
|
||||
kN32_SkColorType, SkImageDecoder::kDecodePixels_Mode);
|
||||
|
||||
if (res == SkImageDecoder::kSuccess) {
|
||||
bm.pixelRef()->setURI(filename);
|
||||
|
||||
SkiaSurface* sur = new SkiaSurface();
|
||||
sur->bitmap().swap(bm);
|
||||
return sur;
|
||||
}
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
Surface* loadRgbaSurface(const char* filename) override {
|
||||
SkiaSurface* sur = new SkiaSurface;
|
||||
sur->create(32, 32);
|
||||
return sur;
|
||||
return loadSurface(filename);
|
||||
}
|
||||
|
||||
private:
|
||||
|
Loading…
x
Reference in New Issue
Block a user