Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(153)

Side by Side Diff: src/core/SkSpecialImage.h

Issue 1579323002: Add SkSpecialImage & SkSpecialSurface classes (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Fix another no-gpu issue Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « include/core/SkPixelRef.h ('k') | src/core/SkSpecialImage.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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 SkSpecialImage_DEFINED
9 #define SkSpecialImage_DEFINED
10
11 #include "SkRefCnt.h"
12
13 class GrTexture;
14 class SkBitmap;
15 class SkCanvas;
16 class SkImage;
17 struct SkImageInfo;
18 class SkPaint;
19 class SkSpecialSurface;
20
21 /**
22 * This is a restricted form of SkImage solely intended for internal use. It
23 * differs from SkImage in that:
24 * - it can only be backed by raster or gpu (no generators)
25 * - it can be backed by a GrTexture larger than its nominal bounds
26 * - it can't be drawn tiled
27 * - it can't be drawn with MIPMAPs
28 * It is similar to SkImage in that it abstracts how the pixels are stored/repre sented.
29 *
30 * Note: the contents of the backing storage outside of the subset rect are unde fined.
31 */
32 class SkSpecialImage : public SkRefCnt {
33 public:
34 int width() const { return fSubset.width(); }
35 int height() const { return fSubset.height(); }
36
37 /**
38 * Draw this SpecialImage into the canvas.
39 */
40 void draw(SkCanvas*, int x, int y, const SkPaint*) const;
41
42 static SkSpecialImage* NewFromImage(const SkIRect& subset, const SkImage*);
43 static SkSpecialImage* NewFromRaster(const SkIRect& subset, const SkBitmap&) ;
44 static SkSpecialImage* NewFromGpu(const SkIRect& subset, GrTexture*);
45
46 /**
47 * Create a new surface with a backend that is compatible with this image.
48 */
49 SkSpecialSurface* newSurface(const SkImageInfo&) const;
50
51 protected:
52 SkSpecialImage(const SkIRect& subset) : fSubset(subset) { }
53
54 // The following 3 are for testing and shouldn't be used.
55 friend class TestingSpecialImageAccess;
56 friend class TestingSpecialSurfaceAccess;
57 const SkIRect& subset() const { return fSubset; }
58
59 /**
60 * If the SpecialImage is backed by cpu pixels, return the const address
61 * of those pixels and, if not null, return the ImageInfo and rowBytes.
62 * The returned address is only valid while the image object is in scope.
63 *
64 * The returned ImageInfo represents the backing memory. Use 'subset'
65 * to get the active portion's dimensions.
66 *
67 * On failure, return false and ignore the pixmap parameter.
68 */
69 bool peekPixels(SkPixmap*) const;
70
71 /**
72 * If the SpecialImage is backed by a gpu texture, return that texture.
73 * The active portion of the texture can be retrieved via 'subset'.
74 */
75 GrTexture* peekTexture() const;
76
77 private:
78 const SkIRect fSubset;
79
80 typedef SkRefCnt INHERITED;
81 };
82
83 #endif
84
OLDNEW
« no previous file with comments | « include/core/SkPixelRef.h ('k') | src/core/SkSpecialImage.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698