aboutsummaryrefslogtreecommitdiffhomepage
path: root/tools/skiaserve/urlhandlers
diff options
context:
space:
mode:
authorGravatar joshualitt <joshualitt@chromium.org>2016-03-09 10:07:02 -0800
committerGravatar Commit bot <commit-bot@chromium.org>2016-03-09 10:07:02 -0800
commite0449cf9f43e179a809eb1b87ca3bf77cf6f1222 (patch)
treeaaa1df0e986009305e7e14def016d3f8b04cd8b3 /tools/skiaserve/urlhandlers
parent0fcfb7525f60eabfdaf9761c75c7d4fd1b46d0c5 (diff)
Fix up picture clip bounds in SkiaServe
Diffstat (limited to 'tools/skiaserve/urlhandlers')
-rw-r--r--tools/skiaserve/urlhandlers/BreakHandler.cpp17
-rw-r--r--tools/skiaserve/urlhandlers/DownloadHandler.cpp19
-rw-r--r--tools/skiaserve/urlhandlers/UrlHandler.h2
3 files changed, 3 insertions, 35 deletions
diff --git a/tools/skiaserve/urlhandlers/BreakHandler.cpp b/tools/skiaserve/urlhandlers/BreakHandler.cpp
index 0b044634fe..b701955f90 100644
--- a/tools/skiaserve/urlhandlers/BreakHandler.cpp
+++ b/tools/skiaserve/urlhandlers/BreakHandler.cpp
@@ -19,19 +19,6 @@ bool BreakHandler::canHandle(const char* method, const char* url) {
0 == strncmp(url, kBasePath, strlen(kBasePath));
}
-SkColor BreakHandler::GetPixel(Request* request, int x, int y) {
- SkCanvas* canvas = request->getCanvas();
- canvas->flush();
- SkAutoTDelete<SkBitmap> bitmap(request->getBitmapFromCanvas(canvas));
- SkASSERT(bitmap);
- bitmap->lockPixels();
- uint8_t* start = ((uint8_t*) bitmap->getPixels()) + (y * Request::kImageWidth + x) * 4;
- SkColor result = SkColorSetARGB(start[3], start[0], start[1], start[2]);
- bitmap->unlockPixels();
- return result;
-}
-
-
int BreakHandler::handle(Request* request, MHD_Connection* connection,
const char* url, const char* method,
const char* upload_data, size_t* upload_data_size) {
@@ -59,7 +46,7 @@ int BreakHandler::handle(Request* request, MHD_Connection* connection,
for (int i = 0; i <= n; ++i) {
request->fDebugCanvas->getDrawCommandAt(i)->execute(canvas);
}
- SkColor target = GetPixel(request, x, y);
+ SkColor target = request->getPixel(x, y);
Json::Value response(Json::objectValue);
Json::Value startColor(Json::arrayValue);
startColor.append(Json::Value(SkColorGetR(target)));
@@ -78,7 +65,7 @@ int BreakHandler::handle(Request* request, MHD_Connection* connection,
saveCount = canvas->save();
}
request->fDebugCanvas->getDrawCommandAt(index)->execute(canvas);
- SkColor current = GetPixel(request, x, y);
+ SkColor current = request->getPixel(x, y);
if (current != target) {
Json::Value endColor(Json::arrayValue);
endColor.append(Json::Value(SkColorGetR(current)));
diff --git a/tools/skiaserve/urlhandlers/DownloadHandler.cpp b/tools/skiaserve/urlhandlers/DownloadHandler.cpp
index cc55c3b4b9..fd9308d26e 100644
--- a/tools/skiaserve/urlhandlers/DownloadHandler.cpp
+++ b/tools/skiaserve/urlhandlers/DownloadHandler.cpp
@@ -8,8 +8,6 @@
#include "UrlHandler.h"
#include "microhttpd.h"
-#include "SkPictureRecorder.h"
-#include "SkPixelSerializer.h"
#include "../Request.h"
#include "../Response.h"
@@ -27,22 +25,7 @@ int DownloadHandler::handle(Request* request, MHD_Connection* connection,
return MHD_NO;
}
- // TODO move to a function
- // Playback into picture recorder
- SkPictureRecorder recorder;
- SkCanvas* canvas = recorder.beginRecording(Request::kImageWidth,
- Request::kImageHeight);
-
- request->fDebugCanvas->draw(canvas);
-
- SkAutoTUnref<SkPicture> picture(recorder.endRecording());
-
- SkDynamicMemoryWStream outStream;
-
- SkAutoTUnref<SkPixelSerializer> serializer(SkImageEncoder::CreatePixelSerializer());
- picture->serialize(&outStream, serializer);
-
- SkAutoTUnref<SkData> data(outStream.copyToData());
+ SkAutoTUnref<SkData> data(request->writeOutSkp());
// TODO fancier name handling
return SendData(connection, data, "application/octet-stream", true,
diff --git a/tools/skiaserve/urlhandlers/UrlHandler.h b/tools/skiaserve/urlhandlers/UrlHandler.h
index 3fe269a57f..4fa9731da1 100644
--- a/tools/skiaserve/urlhandlers/UrlHandler.h
+++ b/tools/skiaserve/urlhandlers/UrlHandler.h
@@ -41,8 +41,6 @@ public:
int handle(Request* request, MHD_Connection* connection,
const char* url, const char* method,
const char* upload_data, size_t* upload_data_size) override;
-private:
- static SkColor GetPixel(Request* request, int x, int y);
};
/**