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

Side by Side Diff: src/gpu/gl/GrGLProgramDesc.cpp

Issue 1583863002: Beginning of support for texture rectangles. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: fix temporary address warning 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
OLDNEW
1 /* 1 /*
2 * Copyright 2013 Google Inc. 2 * Copyright 2013 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 #include "GrGLProgramDesc.h" 7 #include "GrGLProgramDesc.h"
8 8
9 #include "GrProcessor.h" 9 #include "GrProcessor.h"
10 #include "GrGLGpu.h"
11 #include "GrPipeline.h" 10 #include "GrPipeline.h"
12 #include "SkChecksum.h" 11 #include "SkChecksum.h"
12 #include "gl/GrGLDefines.h"
13 #include "gl/GrGLTexture.h"
14 #include "gl/GrGLTypes.h"
13 #include "glsl/GrGLSLFragmentProcessor.h" 15 #include "glsl/GrGLSLFragmentProcessor.h"
14 #include "glsl/GrGLSLFragmentShaderBuilder.h" 16 #include "glsl/GrGLSLFragmentShaderBuilder.h"
17 #include "glsl/GrGLSLCaps.h"
15 18
19 static uint16_t texture_target_key(GrGLenum target) {
jvanverth1 2016/01/14 16:47:21 Could you use TextureTargetToCopyProgramIdx as the
bsalomon 2016/01/14 17:11:50 Actually I can just use the GLenum... they're all
20 switch (target) {
21 case GR_GL_TEXTURE_2D:
22 return 0;
23 case GR_GL_TEXTURE_EXTERNAL:
24 return 1;
25 case GR_GL_TEXTURE_RECTANGLE:
26 return 2;
27 default:
28 SkFAIL("Unexpected texture target type.");
29 return 0;
30 }
31 }
16 32
17 static void add_texture_key(GrProcessorKeyBuilder* b, const GrProcessor& proc, 33 static void add_texture_key(GrProcessorKeyBuilder* b, const GrProcessor& proc,
18 const GrGLSLCaps& caps) { 34 const GrGLSLCaps& caps) {
19 int numTextures = proc.numTextures(); 35 int numTextures = proc.numTextures();
20 // Need two bytes per key (swizzle and target). 36 // Need two bytes per key (swizzle and target).
21 int word32Count = (proc.numTextures() + 1) / 2; 37 int word32Count = (proc.numTextures() + 1) / 2;
22 if (0 == word32Count) { 38 if (0 == word32Count) {
23 return; 39 return;
24 } 40 }
25 uint16_t* k16 = SkTCast<uint16_t*>(b->add32n(word32Count)); 41 uint16_t* k16 = SkTCast<uint16_t*>(b->add32n(word32Count));
26 for (int i = 0; i < numTextures; ++i) { 42 for (int i = 0; i < numTextures; ++i) {
27 const GrTextureAccess& access = proc.textureAccess(i); 43 const GrTextureAccess& access = proc.textureAccess(i);
28 bool isExternal = (GR_GL_TEXTURE_EXTERNAL == 44 GrGLTexture* texture = static_cast<GrGLTexture*>(access.getTexture());
29 static_cast<GrGLTexture*>(access.getTexture())->targe t()); 45 k16[i] = caps.configTextureSwizzle(texture->config()).asKey() |
30 k16[i] = caps.configTextureSwizzle(access.getTexture()->config()).asKey( ) | 46 (texture_target_key(texture->target()) << 16);
31 (isExternal ? 0xFF00 : 0x0000);
32 } 47 }
33 // zero the last 16 bits if the number of textures is odd. 48 // zero the last 16 bits if the number of textures is odd.
34 if (numTextures & 0x1) { 49 if (numTextures & 0x1) {
35 k16[numTextures] = 0; 50 k16[numTextures] = 0;
36 } 51 }
37 } 52 }
38 53
39 /** 54 /**
40 * A function which emits a meta key into the key builder. This is required bec ause shader code may 55 * A function which emits a meta key into the key builder. This is required bec ause shader code may
41 * be dependent on properties of the effect that the effect itself doesn't use 56 * be dependent on properties of the effect that the effect itself doesn't use
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 } else { 159 } else {
145 header->fIgnoresCoverage = 0; 160 header->fIgnoresCoverage = 0;
146 } 161 }
147 162
148 header->fSnapVerticesToPixelCenters = pipeline.snapVerticesToPixelCenters(); 163 header->fSnapVerticesToPixelCenters = pipeline.snapVerticesToPixelCenters();
149 header->fColorEffectCnt = pipeline.numColorFragmentProcessors(); 164 header->fColorEffectCnt = pipeline.numColorFragmentProcessors();
150 header->fCoverageEffectCnt = pipeline.numCoverageFragmentProcessors(); 165 header->fCoverageEffectCnt = pipeline.numCoverageFragmentProcessors();
151 glDesc->finalize(); 166 glDesc->finalize();
152 return true; 167 return true;
153 } 168 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698