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

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

Issue 563283004: Use per-typeface sets of glyphs for nvpr text (Closed) Base URL: https://skia.googlesource.com/skia.git@upload_glyphmemorypath
Patch Set: Fix builds Created 6 years, 3 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 | « src/gpu/GrGpu.cpp ('k') | src/gpu/GrPathRange.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 2014 Google Inc. 2 * Copyright 2014 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 GrPathRange_DEFINED 8 #ifndef GrPathRange_DEFINED
9 #define GrPathRange_DEFINED 9 #define GrPathRange_DEFINED
10 10
11 #include "GrGpuResource.h" 11 #include "GrGpuResource.h"
12 #include "GrResourceCache.h" 12 #include "GrResourceCache.h"
13 #include "SkRefCnt.h"
13 #include "SkStrokeRec.h" 14 #include "SkStrokeRec.h"
15 #include "SkTArray.h"
14 16
15 class SkPath; 17 class SkPath;
18 class SkDescriptor;
16 19
17 /** 20 /**
18 * Represents a contiguous range of GPU path objects with a common stroke. The 21 * Represents a contiguous range of GPU path objects, all with a common stroke.
19 * path range is immutable with the exception that individual paths can be 22 * This object is immutable with the exception that individual paths may be
20 * initialized lazily. Unititialized paths are silently ignored by drawing 23 * initialized lazily.
21 * functions.
22 */ 24 */
25
23 class GrPathRange : public GrGpuResource { 26 class GrPathRange : public GrGpuResource {
24 public: 27 public:
25 SK_DECLARE_INST_COUNT(GrPathRange); 28 SK_DECLARE_INST_COUNT(GrPathRange);
26 29
27 static const bool kIsWrapped = false; 30 static const bool kIsWrapped = false;
28 31
32 /**
33 * Return the resourceType intended for cache lookups involving GrPathRange.
34 */
29 static GrResourceKey::ResourceType resourceType() { 35 static GrResourceKey::ResourceType resourceType() {
30 static const GrResourceKey::ResourceType type = GrResourceKey::GenerateR esourceType(); 36 static const GrResourceKey::ResourceType type = GrResourceKey::GenerateR esourceType();
31 return type; 37 return type;
32 } 38 }
33 39
34 /** 40 /**
35 * Initialize to a range with a fixed size and stroke. Stroke must not be ha irline. 41 * Class that generates the paths for a specific range.
36 */ 42 */
37 GrPathRange(GrGpu* gpu, size_t size, const SkStrokeRec& stroke) 43 class PathGenerator : public SkRefCnt {
38 : INHERITED(gpu, kIsWrapped), 44 public:
39 fSize(size), 45 virtual int getNumPaths() = 0;
40 fStroke(stroke) { 46 virtual void generatePath(int index, SkPath* out) = 0;
41 this->registerWithCache(); 47 virtual bool isEqualTo(const SkDescriptor&) const { return false; }
48 virtual ~PathGenerator() {}
49 };
50
51 /**
52 * Initialize a lazy-loaded path range. This class will generate an SkPath a nd call
53 * onInitPath() for each path within the range before it is drawn for the fi rst time.
54 */
55 GrPathRange(GrGpu*, PathGenerator*, const SkStrokeRec& stroke);
56
57 /**
58 * Initialize an eager-loaded path range. The subclass is responsible for en suring all
59 * the paths are initialized up front.
60 */
61 GrPathRange(GrGpu*, int numPaths, const SkStrokeRec& stroke);
62
63 virtual bool isEqualTo(const SkDescriptor& desc) const {
64 return NULL != fPathGenerator.get() && fPathGenerator->isEqualTo(desc);
42 } 65 }
43 66
44 size_t getSize() const { return fSize; } 67 int getNumPaths() const { return fNumPaths; }
45 const SkStrokeRec& getStroke() const { return fStroke; } 68 const SkStrokeRec& getStroke() const { return fStroke; }
46 69 const PathGenerator* getPathGenerator() const { return fPathGenerator.get(); }
47 /**
48 * Initialize a path in the range. It is invalid to call this method for a
49 * path that has already been initialized.
50 */
51 virtual void initAt(size_t index, const SkPath&) = 0;
52 70
53 protected: 71 protected:
54 size_t fSize; 72 // Initialize a path in the range before drawing. This is only called when
55 SkStrokeRec fStroke; 73 // fPathGenerator is non-null. The child class need not call didChangeGpuMem orySize(),
74 // GrPathRange will take care of that after the call is complete.
75 virtual void onInitPath(int index, const SkPath&) const = 0;
56 76
57 private: 77 private:
78 // Notify when paths will be drawn in case this is a lazy-loaded path range.
79 friend class GrGpu;
80 void willDrawPaths(const uint32_t indices[], int count) const;
81
82 mutable SkAutoTUnref<PathGenerator> fPathGenerator;
83 mutable SkTArray<uint8_t, true /*MEM_COPY*/> fGeneratedPaths;
84 const int fNumPaths;
85 const SkStrokeRec fStroke;
86
58 typedef GrGpuResource INHERITED; 87 typedef GrGpuResource INHERITED;
59 }; 88 };
60 89
61 #endif 90 #endif
OLDNEW
« no previous file with comments | « src/gpu/GrGpu.cpp ('k') | src/gpu/GrPathRange.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698