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

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: Address code review comments Created 4 years, 11 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 active rect are unde fined.
31 */
32 class SkSpecialImage : public SkRefCnt {
33 public:
34 const SkIRect& activeRect() const { return fActiveRect; }
bsalomon 2016/01/14 20:09:10 width() height() still seems handy Speculating...
robertphillips 2016/01/15 13:12:47 I readded width() & height(). I'm not sure re the
35
36 /**
37 * Draw this SpecialImage into the canvas.
38 */
39 void draw(SkCanvas*, int x, int y, const SkPaint*) const;
40
41 /**
42 * If the SpecialImage is backed by cpu pixels, return the const address
43 * of those pixels and, if not null, return the ImageInfo and rowBytes.
44 * The returned address is only valid while the image object is in scope.
45 *
46 * The returned ImageInfo represents the backing memory. Use 'activeRect'
47 * to get the active portion's dimensions.
48 *
49 * On failure, return false and ignore the pixmap parameter.
50 */
51 bool peekPixels(SkPixmap*) const;
52
bsalomon 2016/01/14 20:09:10 Should we have peekTexture? Maybe peekTexture(SkI
robertphillips 2016/01/15 13:12:47 There is a peekTexture below. I think we should al
53 /**
54 * If the SpecialImage is backed by a gpu texture, return that texture.
55 * The active portion of the texture can be retrieved via 'width' & 'height '.
56 */
57 GrTexture* peekTexture() const;
58
59 static SkSpecialImage* NewImage(const SkIRect& activeRect, const SkImage*);
60 static SkSpecialImage* NewRaster(const SkIRect& activeRect, const SkBitmap&) ;
61 static SkSpecialImage* NewGpu(const SkIRect& activeRect, GrTexture*);
bsalomon 2016/01/14 20:09:10 NewFromTexture to match SkImage? wonder if subset
robertphillips 2016/01/15 13:12:47 Done.
62
63 /**
64 * Create a new surface with a backend that is compatible with this image.
65 */
66 SkSpecialSurface* newSurface(const SkImageInfo&) const;
67
68 protected:
69 SkSpecialImage(const SkIRect& activeRect) : fActiveRect(activeRect) { }
70
71 private:
72 const SkIRect fActiveRect;
73
74 typedef SkRefCnt INHERITED;
75 };
76
77 #endif
78
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