• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2016 Google Inc.
3  *
4  * Use of this source code is governed by a BSD-style license that can be
5  * found in the LICENSE file.
6  */
7 
8 #ifndef SkImageDeserializer_DEFINED
9 #define SkImageDeserializer_DEFINED
10 
11 #include "SkRefCnt.h"
12 
13 struct SkIRect;
14 class SkData;
15 class SkImage;
16 
17 class SK_API SkImageDeserializer {
18 public:
~SkImageDeserializer()19     virtual ~SkImageDeserializer() {}
20 
21     /**
22      *  Given a data containing serialized content, return an SkImage from it.
23      *
24      *  @param data The data containing the encoded image. The subclass may ref this for later
25      *              decoding, or read it and process it immediately.
26      *  @param subset Optional rectangle represent the subset of the encoded data that is being
27      *                requested to be turned into an image.
28      *  @return The new image, or nullptr on failure.
29      *
30      *  The default implementation is to call SkImage::MakeFromEncoded(...)
31      */
32     virtual sk_sp<SkImage> makeFromData(SkData*, const SkIRect* subset);
33     virtual sk_sp<SkImage> makeFromMemory(const void* data, size_t length, const SkIRect* subset);
34 };
35 
36 #endif
37