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

Side by Side Diff: gm/texdata.cpp

Issue 936943002: Pass clip to context (Closed) Base URL: https://skia.googlesource.com/skia.git@pass_down_rendertarget
Patch Set: feedback inc Created 5 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 | « no previous file | include/core/SkMaskFilter.h » ('j') | src/gpu/GrTextContext.cpp » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 1
2 /* 2 /*
3 * Copyright 2011 Google Inc. 3 * Copyright 2011 Google Inc.
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 8
9 // This test only works with the GPU backend. 9 // This test only works with the GPU backend.
10 10
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 desc.fConfig = kSkia8888_GrPixelConfig; 84 desc.fConfig = kSkia8888_GrPixelConfig;
85 desc.fWidth = 2 * S; 85 desc.fWidth = 2 * S;
86 desc.fHeight = 2 * S; 86 desc.fHeight = 2 * S;
87 GrTexture* texture = ctx->createTexture(desc, false, gTextureDat a.get(), 0); 87 GrTexture* texture = ctx->createTexture(desc, false, gTextureDat a.get(), 0);
88 88
89 if (!texture) { 89 if (!texture) {
90 return; 90 return;
91 } 91 }
92 SkAutoTUnref<GrTexture> au(texture); 92 SkAutoTUnref<GrTexture> au(texture);
93 93
94 GrContext::AutoClip acs(ctx, SkRect::MakeWH(2*S, 2*S)); 94 // setup new clip
95 GrClip clip(SkRect::MakeWH(2*S, 2*S));
95 96
96 GrPaint paint; 97 GrPaint paint;
97 paint.setPorterDuffXPFactory(SkXfermode::kSrcOver_Mode); 98 paint.setPorterDuffXPFactory(SkXfermode::kSrcOver_Mode);
98 99
99 SkMatrix vm; 100 SkMatrix vm;
100 if (i) { 101 if (i) {
101 vm.setRotate(90 * SK_Scalar1, 102 vm.setRotate(90 * SK_Scalar1,
102 S * SK_Scalar1, 103 S * SK_Scalar1,
103 S * SK_Scalar1); 104 S * SK_Scalar1);
104 } else { 105 } else {
105 vm.reset(); 106 vm.reset();
106 } 107 }
107 SkMatrix tm; 108 SkMatrix tm;
108 tm = vm; 109 tm = vm;
109 tm.postIDiv(2*S, 2*S); 110 tm.postIDiv(2*S, 2*S);
110 paint.addColorTextureProcessor(texture, tm); 111 paint.addColorTextureProcessor(texture, tm);
111 112
112 ctx->drawRect(target, paint, vm, SkRect::MakeWH(2*S, 2*S)); 113 ctx->drawRect(target, clip, paint, vm, SkRect::MakeWH(2*S, 2*S)) ;
113 114
114 // now update the lower right of the texture in first pass 115 // now update the lower right of the texture in first pass
115 // or upper right in second pass 116 // or upper right in second pass
116 offset = 0; 117 offset = 0;
117 for (int y = 0; y < S; ++y) { 118 for (int y = 0; y < S; ++y) {
118 for (int x = 0; x < S; ++x) { 119 for (int x = 0; x < S; ++x) {
119 gTextureData[offset + y * stride + x] = 120 gTextureData[offset + y * stride + x] =
120 ((x + y) % 2) ? (i ? green : red) : blue; 121 ((x + y) % 2) ? (i ? green : red) : blue;
121 } 122 }
122 } 123 }
123 texture->writePixels(S, (i ? 0 : S), S, S, 124 texture->writePixels(S, (i ? 0 : S), S, S,
124 texture->config(), gTextureData.get(), 125 texture->config(), gTextureData.get(),
125 4 * stride); 126 4 * stride);
126 ctx->drawRect(target, paint, vm, SkRect::MakeWH(2*S, 2*S)); 127 ctx->drawRect(target, clip, paint, vm, SkRect::MakeWH(2*S, 2*S)) ;
127 } 128 }
128 } else { 129 } else {
129 this->drawGpuOnlyMessage(canvas); 130 this->drawGpuOnlyMessage(canvas);
130 } 131 }
131 } 132 }
132 133
133 private: 134 private:
134 typedef GM INHERITED; 135 typedef GM INHERITED;
135 }; 136 };
136 137
137 ////////////////////////////////////////////////////////////////////////////// 138 //////////////////////////////////////////////////////////////////////////////
138 139
139 static GM* MyFactory(void*) { return new TexDataGM; } 140 static GM* MyFactory(void*) { return new TexDataGM; }
140 static GMRegistry reg(MyFactory); 141 static GMRegistry reg(MyFactory);
141 142
142 } 143 }
143 144
144 #endif 145 #endif
OLDNEW
« no previous file with comments | « no previous file | include/core/SkMaskFilter.h » ('j') | src/gpu/GrTextContext.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698