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

Side by Side Diff: src/gpu/GrSWMaskHelper.h

Issue 446103002: Pass compressed blitters to our mask drawing algorithm (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Code review comments Created 6 years, 4 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 | « gyp/ktx.gyp ('k') | src/gpu/GrSWMaskHelper.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2012 Google Inc. 2 * Copyright 2012 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #ifndef GrSWMaskHelper_DEFINED 8 #ifndef GrSWMaskHelper_DEFINED
9 #define GrSWMaskHelper_DEFINED 9 #define GrSWMaskHelper_DEFINED
10 10
(...skipping 24 matching lines...) Expand all
35 * draw one or more paths/rects specifying the required boolean ops 35 * draw one or more paths/rects specifying the required boolean ops
36 * 36 *
37 * toTexture(); // to get it from the internal bitmap to the GPU 37 * toTexture(); // to get it from the internal bitmap to the GPU
38 * 38 *
39 * The result of this process will be the final mask (on the GPU) in the 39 * The result of this process will be the final mask (on the GPU) in the
40 * upper left hand corner of the texture. 40 * upper left hand corner of the texture.
41 */ 41 */
42 class GrSWMaskHelper : SkNoncopyable { 42 class GrSWMaskHelper : SkNoncopyable {
43 public: 43 public:
44 GrSWMaskHelper(GrContext* context) 44 GrSWMaskHelper(GrContext* context)
45 : fContext(context), fCompressMask(false) { 45 : fContext(context)
46 , fCompressionMode(kNone_CompressionMode)
robertphillips 2014/08/07 14:52:24 Don't need this now.
47 , fCompressedBuffer(0) {
46 } 48 }
47 49
48 // set up the internal state in preparation for draws. Since many masks 50 // set up the internal state in preparation for draws. Since many masks
49 // may be accumulated in the helper during creation, "resultBounds" 51 // may be accumulated in the helper during creation, "resultBounds"
50 // allows the caller to specify the region of interest - to limit the 52 // allows the caller to specify the region of interest - to limit the
51 // amount of work. 53 // amount of work.
52 bool init(const SkIRect& resultBounds, const SkMatrix* matrix); 54 bool init(const SkIRect& resultBounds, const SkMatrix* matrix);
53 55
54 // Draw a single rect into the accumulation bitmap using the specified op 56 // Draw a single rect into the accumulation bitmap using the specified op
55 void draw(const SkRect& rect, SkRegion::Op op, 57 void draw(const SkRect& rect, SkRegion::Op op,
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 // geometry and the current drawState. The current drawState is altered to 89 // geometry and the current drawState. The current drawState is altered to
88 // accommodate the mask. 90 // accommodate the mask.
89 // Note that this method assumes that the GrPaint::kTotalStages slot in 91 // Note that this method assumes that the GrPaint::kTotalStages slot in
90 // the draw state can be used to hold the mask texture stage. 92 // the draw state can be used to hold the mask texture stage.
91 // This method is really only intended to be used with the 93 // This method is really only intended to be used with the
92 // output of DrawPathMaskToTexture. 94 // output of DrawPathMaskToTexture.
93 static void DrawToTargetWithPathMask(GrTexture* texture, 95 static void DrawToTargetWithPathMask(GrTexture* texture,
94 GrDrawTarget* target, 96 GrDrawTarget* target,
95 const SkIRect& rect); 97 const SkIRect& rect);
96 98
97 protected:
98 private: 99 private:
99 GrContext* fContext; 100 GrContext* fContext;
100 SkMatrix fMatrix; 101 SkMatrix fMatrix;
101 SkBitmap fBM; 102 SkBitmap fBM;
102 SkDraw fDraw; 103 SkDraw fDraw;
103 SkRasterClip fRasterClip; 104 SkRasterClip fRasterClip;
104 105
105 // This flag says whether or not we should compress the mask. If 106 // This enum says whether or not we should compress the mask:
106 // it is true, then fCompressedFormat is always valid. 107 // kNone_CompressionMode: compression is not supported on this device.
107 bool fCompressMask; 108 // kCompress_CompressionMode: compress the bitmap before it gets sent to the gpu
109 // kBlitter_CompressionMode: write to the bitmap using a special compressed blitter.
110 enum CompressionMode {
111 kNone_CompressionMode,
112 kCompress_CompressionMode,
113 kBlitter_CompressionMode,
114 } fCompressionMode;
115
116 // This is the buffer into which we store our compressed data. This buffer i s
117 // only allocated (non-null) if fCompressionMode is kBlitter_CompressionMode
118 SkAutoMalloc fCompressedBuffer;
108 119
109 // This is the desired format within which to compress the 120 // This is the desired format within which to compress the
110 // texture. This value is only valid if fCompressMask is true. 121 // texture. This value is only valid if fCompressionMode is not kNone_Compre ssionMode.
111 SkTextureCompressor::Format fCompressedFormat; 122 SkTextureCompressor::Format fCompressedFormat;
112 123
113 // Actually sends the texture data to the GPU. This is called from 124 // Actually sends the texture data to the GPU. This is called from
114 // toTexture with the data filled in depending on the texture config. 125 // toTexture with the data filled in depending on the texture config.
115 void sendTextureData(GrTexture *texture, const GrTextureDesc& desc, 126 void sendTextureData(GrTexture *texture, const GrTextureDesc& desc,
116 const void *data, int rowbytes); 127 const void *data, int rowbytes);
117 128
118 // Compresses the bitmap stored in fBM and sends the compressed data 129 // Compresses the bitmap stored in fBM and sends the compressed data
119 // to the GPU to be stored in 'texture' using sendTextureData. 130 // to the GPU to be stored in 'texture' using sendTextureData.
120 void compressTextureData(GrTexture *texture, const GrTextureDesc& desc); 131 void compressTextureData(GrTexture *texture, const GrTextureDesc& desc);
121 132
122 typedef SkNoncopyable INHERITED; 133 typedef SkNoncopyable INHERITED;
123 }; 134 };
124 135
125 #endif // GrSWMaskHelper_DEFINED 136 #endif // GrSWMaskHelper_DEFINED
OLDNEW
« no previous file with comments | « gyp/ktx.gyp ('k') | src/gpu/GrSWMaskHelper.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698