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

Side by Side Diff: src/gpu/GrProcessor.cpp

Issue 582963002: Solo gp (Closed) Base URL: https://skia.googlesource.com/skia.git@no_peb
Patch Set: rebase Created 6 years, 2 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/GrPathRenderer.h ('k') | src/gpu/GrRODrawState.h » ('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 #include "GrEffect.h" 8 #include "GrProcessor.h"
9 #include "GrBackendEffectFactory.h" 9 #include "GrBackendProcessorFactory.h"
10 #include "GrContext.h" 10 #include "GrContext.h"
11 #include "GrCoordTransform.h" 11 #include "GrCoordTransform.h"
12 #include "GrMemoryPool.h" 12 #include "GrMemoryPool.h"
13 #include "SkTLS.h" 13 #include "SkTLS.h"
14 14
15 #if SK_ALLOW_STATIC_GLOBAL_INITIALIZERS 15 namespace GrProcessorUnitTest {
16 SkTArray<GrEffectTestFactory*, true>* GrEffectTestFactory::GetFactories() {
17 static SkTArray<GrEffectTestFactory*, true> gFactories;
18 return &gFactories;
19 }
20 #endif
21
22 namespace GrEffectUnitTest {
23 const SkMatrix& TestMatrix(SkRandom* random) { 16 const SkMatrix& TestMatrix(SkRandom* random) {
24 static SkMatrix gMatrices[5]; 17 static SkMatrix gMatrices[5];
25 static bool gOnce; 18 static bool gOnce;
26 if (!gOnce) { 19 if (!gOnce) {
27 gMatrices[0].reset(); 20 gMatrices[0].reset();
28 gMatrices[1].setTranslate(SkIntToScalar(-100), SkIntToScalar(100)); 21 gMatrices[1].setTranslate(SkIntToScalar(-100), SkIntToScalar(100));
29 gMatrices[2].setRotate(SkIntToScalar(17)); 22 gMatrices[2].setRotate(SkIntToScalar(17));
30 gMatrices[3].setRotate(SkIntToScalar(185)); 23 gMatrices[3].setRotate(SkIntToScalar(185));
31 gMatrices[3].postTranslate(SkIntToScalar(66), SkIntToScalar(-33)); 24 gMatrices[3].postTranslate(SkIntToScalar(66), SkIntToScalar(-33));
32 gMatrices[3].postScale(SkIntToScalar(2), SK_ScalarHalf); 25 gMatrices[3].postScale(SkIntToScalar(2), SK_ScalarHalf);
33 gMatrices[4].setRotate(SkIntToScalar(215)); 26 gMatrices[4].setRotate(SkIntToScalar(215));
34 gMatrices[4].set(SkMatrix::kMPersp0, 0.00013f); 27 gMatrices[4].set(SkMatrix::kMPersp0, 0.00013f);
35 gMatrices[4].set(SkMatrix::kMPersp1, -0.000039f); 28 gMatrices[4].set(SkMatrix::kMPersp1, -0.000039f);
36 gOnce = true; 29 gOnce = true;
37 } 30 }
38 return gMatrices[random->nextULessThan(static_cast<uint32_t>(SK_ARRAY_COUNT( gMatrices)))]; 31 return gMatrices[random->nextULessThan(static_cast<uint32_t>(SK_ARRAY_COUNT( gMatrices)))];
39 } 32 }
40 } 33 }
41 34
42 class GrEffect_Globals { 35 class GrProcessor_Globals {
43 public: 36 public:
44 static GrMemoryPool* GetTLS() { 37 static GrMemoryPool* GetTLS() {
45 return (GrMemoryPool*)SkTLS::Get(CreateTLS, DeleteTLS); 38 return (GrMemoryPool*)SkTLS::Get(CreateTLS, DeleteTLS);
46 } 39 }
47 40
48 private: 41 private:
49 static void* CreateTLS() { 42 static void* CreateTLS() {
50 return SkNEW_ARGS(GrMemoryPool, (4096, 4096)); 43 return SkNEW_ARGS(GrMemoryPool, (4096, 4096));
51 } 44 }
52 45
53 static void DeleteTLS(void* pool) { 46 static void DeleteTLS(void* pool) {
54 SkDELETE(reinterpret_cast<GrMemoryPool*>(pool)); 47 SkDELETE(reinterpret_cast<GrMemoryPool*>(pool));
55 } 48 }
56 }; 49 };
57 50
58 int32_t GrBackendEffectFactory::fCurrEffectClassID = GrBackendEffectFactory::kIl legalEffectClassID; 51 int32_t GrBackendProcessorFactory::fCurrEffectClassID =
52 GrBackendProcessorFactory::kIllegalEffectClassID;
59 53
60 /////////////////////////////////////////////////////////////////////////////// 54 ///////////////////////////////////////////////////////////////////////////////
61 55
62 GrEffect::~GrEffect() {} 56 GrProcessor::~GrProcessor() {}
63 57
64 const char* GrEffect::name() const { 58 const char* GrProcessor::name() const {
65 return this->getFactory().name(); 59 return this->getFactory().name();
66 } 60 }
67 61
68 void GrEffect::addCoordTransform(const GrCoordTransform* transform) { 62 void GrProcessor::addCoordTransform(const GrCoordTransform* transform) {
69 fCoordTransforms.push_back(transform); 63 fCoordTransforms.push_back(transform);
70 SkDEBUGCODE(transform->setInEffect();) 64 SkDEBUGCODE(transform->setInEffect();)
71 } 65 }
72 66
73 void GrEffect::addTextureAccess(const GrTextureAccess* access) { 67 void GrProcessor::addTextureAccess(const GrTextureAccess* access) {
74 fTextureAccesses.push_back(access); 68 fTextureAccesses.push_back(access);
75 this->addGpuResource(access->getProgramTexture()); 69 this->addGpuResource(access->getProgramTexture());
76 } 70 }
77 71
78 void* GrEffect::operator new(size_t size) { 72 void* GrProcessor::operator new(size_t size) {
79 return GrEffect_Globals::GetTLS()->allocate(size); 73 return GrProcessor_Globals::GetTLS()->allocate(size);
80 } 74 }
81 75
82 void GrEffect::operator delete(void* target) { 76 void GrProcessor::operator delete(void* target) {
83 GrEffect_Globals::GetTLS()->release(target); 77 GrProcessor_Globals::GetTLS()->release(target);
84 } 78 }
85 79
86 #ifdef SK_DEBUG 80 #ifdef SK_DEBUG
87 void GrEffect::assertEquality(const GrEffect& other) const { 81 void GrProcessor::assertEquality(const GrProcessor& other) const {
88 SkASSERT(this->numTransforms() == other.numTransforms()); 82 SkASSERT(this->numTransforms() == other.numTransforms());
89 for (int i = 0; i < this->numTransforms(); ++i) { 83 for (int i = 0; i < this->numTransforms(); ++i) {
90 SkASSERT(this->coordTransform(i) == other.coordTransform(i)); 84 SkASSERT(this->coordTransform(i) == other.coordTransform(i));
91 } 85 }
92 SkASSERT(this->numTextures() == other.numTextures()); 86 SkASSERT(this->numTextures() == other.numTextures());
93 for (int i = 0; i < this->numTextures(); ++i) { 87 for (int i = 0; i < this->numTextures(); ++i) {
94 SkASSERT(this->textureAccess(i) == other.textureAccess(i)); 88 SkASSERT(this->textureAccess(i) == other.textureAccess(i));
95 } 89 }
96 } 90 }
97 #endif 91 #endif
OLDNEW
« no previous file with comments | « src/gpu/GrPathRenderer.h ('k') | src/gpu/GrRODrawState.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698