Relocate SK_SUPPORT_LEGACY_PICTURE_PTR

Move to platform-specific defines.

(Chromium already has this guard)

R=reed@google.com
GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1831053002

Review URL: https://codereview.chromium.org/1831053002
This commit is contained in:
fmalita 2016-03-24 11:05:28 -07:00 committed by Commit bot
parent e8597a4dd0
commit 41c409634c
4 changed files with 13 additions and 6 deletions

View File

@ -1,3 +1,10 @@
/*
* Copyright 2014 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#include "nanomsg/src/nn.h"
#include "nanomsg/src/pipeline.h"
#include "nanomsg/src/reqrep.h"
@ -53,7 +60,7 @@ static void send_picture(int socket, const PictureHeader& header, const SkData&
nn_sendmsg(socket, &msg, 0/*flags*/);
}
static SkPicture* recv_picture(int socket, PictureHeader* header) {
static sk_sp<SkPicture> recv_picture(int socket, PictureHeader* header) {
static const size_t hSize = sizeof(*header); // It's easy to slip up and use sizeof(header).
void* msg;
@ -63,7 +70,7 @@ static SkPicture* recv_picture(int socket, PictureHeader* header) {
// msg is first a fixed-size header, then an .skp.
memcpy(header, msg, hSize);
SkMemoryStream stream((uint8_t*)msg + hSize, size - hSize);
SkPicture* pic = SkPicture::CreateFromStream(&stream);
sk_sp<SkPicture> pic = SkPicture::MakeFromStream(&stream);
SkDebugf(" from proccess %d:", header->pid);
@ -79,7 +86,7 @@ static void client(const char* skpPath, const char* dataEndpoint) {
exit(1);
}
SkMemoryStream stream(skp->data(), skp->size());
SkAutoTUnref<SkPicture> picture(SkPicture::CreateFromStream(&stream));
sk_sp<SkPicture> picture(SkPicture::MakeFromStream(&stream));
PictureHeader header;
SkRandom rand(picture->cullRect().width() * picture->cullRect().height());
@ -143,7 +150,7 @@ static void server(const char* dataEndpoint, const char* controlEndpoint, SkCanv
// We should have an .skp waiting for us on data socket.
PictureHeader header;
SkAutoTUnref<SkPicture> picture(recv_picture(data, &header));
sk_sp<SkPicture> picture(recv_picture(data, &header));
SkPaint paint;
paint.setAlpha(header.alpha);

View File

@ -24,6 +24,7 @@
'SK_SUPPORT_LEGACY_CREATESHADER_PTR',
'SK_SUPPORT_LEGACY_PATHEFFECT_PTR',
'SK_SUPPORT_LEGACY_NEW_SURFACE_API',
'SK_SUPPORT_LEGACY_PICTURE_PTR',
],
},
}

View File

@ -27,8 +27,6 @@ class SkWStream;
class SkWriteBuffer;
struct SkPictInfo;
#define SK_SUPPORT_LEGACY_PICTURE_PTR
/** \class SkPicture
An SkPicture records drawing commands made to a canvas to be played back at a later time.

View File

@ -530,6 +530,7 @@ DEFINES_ALL = [
# Staging flags for API changes
"SK_SUPPORT_LEGACY_COLORFILTER_PTR",
"SK_SUPPORT_LEGACY_CREATESHADER_PTR",
"SK_SUPPORT_LEGACY_PICTURE_PTR",
]
################################################################################