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

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

Issue 1431433003: Move shader compiling to ProgramBuilder and various ShaderBuilder cleanups. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: nits Created 5 years, 1 month 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/gl/GrGLGpu.h ('k') | src/gpu/gl/GrGLProgram.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 2011 Google Inc. 2 * Copyright 2011 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 8
9 #include "GrGLGpu.h" 9 #include "GrGLGpu.h"
10 #include "GrGLGLSL.h" 10 #include "GrGLGLSL.h"
(...skipping 2378 matching lines...) Expand 10 before | Expand all | Expand 10 after
2389 GR_GL_REPEAT, 2389 GR_GL_REPEAT,
2390 GR_GL_MIRRORED_REPEAT 2390 GR_GL_MIRRORED_REPEAT
2391 }; 2391 };
2392 GR_STATIC_ASSERT(SkShader::kTileModeCount == SK_ARRAY_COUNT(gWrapModes)); 2392 GR_STATIC_ASSERT(SkShader::kTileModeCount == SK_ARRAY_COUNT(gWrapModes));
2393 GR_STATIC_ASSERT(0 == SkShader::kClamp_TileMode); 2393 GR_STATIC_ASSERT(0 == SkShader::kClamp_TileMode);
2394 GR_STATIC_ASSERT(1 == SkShader::kRepeat_TileMode); 2394 GR_STATIC_ASSERT(1 == SkShader::kRepeat_TileMode);
2395 GR_STATIC_ASSERT(2 == SkShader::kMirror_TileMode); 2395 GR_STATIC_ASSERT(2 == SkShader::kMirror_TileMode);
2396 return gWrapModes[tm]; 2396 return gWrapModes[tm];
2397 } 2397 }
2398 2398
2399 const GrGLenum* GrGLGpu::GetTexParamSwizzle(GrPixelConfig config, const GrGLCaps & caps) {
2400 if (caps.textureSwizzleSupport() && GrPixelConfigIsAlphaOnly(config)) {
2401 if (caps.textureRedSupport()) {
2402 static const GrGLenum gRedSmear[] = { GR_GL_RED, GR_GL_RED, GR_GL_RE D, GR_GL_RED };
2403 return gRedSmear;
2404 } else {
2405 static const GrGLenum gAlphaSmear[] = { GR_GL_ALPHA, GR_GL_ALPHA,
2406 GR_GL_ALPHA, GR_GL_ALPHA };
2407 return gAlphaSmear;
2408 }
2409 } else {
2410 static const GrGLenum gStraight[] = { GR_GL_RED, GR_GL_GREEN, GR_GL_BLUE , GR_GL_ALPHA };
2411 return gStraight;
2412 }
2413 }
2414
2399 void GrGLGpu::bindTexture(int unitIdx, const GrTextureParams& params, GrGLTextur e* texture) { 2415 void GrGLGpu::bindTexture(int unitIdx, const GrTextureParams& params, GrGLTextur e* texture) {
2400 SkASSERT(texture); 2416 SkASSERT(texture);
2401 2417
2402 #ifdef SK_DEBUG 2418 #ifdef SK_DEBUG
2403 if (!this->caps()->npotTextureTileSupport()) { 2419 if (!this->caps()->npotTextureTileSupport()) {
2404 const bool tileX = SkShader::kClamp_TileMode != params.getTileModeX(); 2420 const bool tileX = SkShader::kClamp_TileMode != params.getTileModeX();
2405 const bool tileY = SkShader::kClamp_TileMode != params.getTileModeY(); 2421 const bool tileY = SkShader::kClamp_TileMode != params.getTileModeY();
2406 if (tileX || tileY) { 2422 if (tileX || tileY) {
2407 const int w = texture->width(); 2423 const int w = texture->width();
2408 const int h = texture->height(); 2424 const int h = texture->height();
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
2455 2471
2456 if (GrTextureParams::kMipMap_FilterMode == filterMode && 2472 if (GrTextureParams::kMipMap_FilterMode == filterMode &&
2457 texture->texturePriv().mipMapsAreDirty()) { 2473 texture->texturePriv().mipMapsAreDirty()) {
2458 GL_CALL(GenerateMipmap(target)); 2474 GL_CALL(GenerateMipmap(target));
2459 texture->texturePriv().dirtyMipMaps(false); 2475 texture->texturePriv().dirtyMipMaps(false);
2460 } 2476 }
2461 2477
2462 newTexParams.fWrapS = tile_to_gl_wrap(params.getTileModeX()); 2478 newTexParams.fWrapS = tile_to_gl_wrap(params.getTileModeX());
2463 newTexParams.fWrapT = tile_to_gl_wrap(params.getTileModeY()); 2479 newTexParams.fWrapT = tile_to_gl_wrap(params.getTileModeY());
2464 memcpy(newTexParams.fSwizzleRGBA, 2480 memcpy(newTexParams.fSwizzleRGBA,
2465 GrGLShaderBuilder::GetTexParamSwizzle(texture->config(), this->glCaps ()), 2481 GetTexParamSwizzle(texture->config(), this->glCaps()),
2466 sizeof(newTexParams.fSwizzleRGBA)); 2482 sizeof(newTexParams.fSwizzleRGBA));
2467 if (setAll || newTexParams.fMagFilter != oldTexParams.fMagFilter) { 2483 if (setAll || newTexParams.fMagFilter != oldTexParams.fMagFilter) {
2468 this->setTextureUnit(unitIdx); 2484 this->setTextureUnit(unitIdx);
2469 GL_CALL(TexParameteri(target, GR_GL_TEXTURE_MAG_FILTER, newTexParams.fMa gFilter)); 2485 GL_CALL(TexParameteri(target, GR_GL_TEXTURE_MAG_FILTER, newTexParams.fMa gFilter));
2470 } 2486 }
2471 if (setAll || newTexParams.fMinFilter != oldTexParams.fMinFilter) { 2487 if (setAll || newTexParams.fMinFilter != oldTexParams.fMinFilter) {
2472 this->setTextureUnit(unitIdx); 2488 this->setTextureUnit(unitIdx);
2473 GL_CALL(TexParameteri(target, GR_GL_TEXTURE_MIN_FILTER, newTexParams.fMi nFilter)); 2489 GL_CALL(TexParameteri(target, GR_GL_TEXTURE_MIN_FILTER, newTexParams.fMi nFilter));
2474 } 2490 }
2475 if (setAll || newTexParams.fWrapS != oldTexParams.fWrapS) { 2491 if (setAll || newTexParams.fWrapS != oldTexParams.fWrapS) {
(...skipping 819 matching lines...) Expand 10 before | Expand all | Expand 10 after
3295 this->setVertexArrayID(gpu, 0); 3311 this->setVertexArrayID(gpu, 0);
3296 } 3312 }
3297 int attrCount = gpu->glCaps().maxVertexAttributes(); 3313 int attrCount = gpu->glCaps().maxVertexAttributes();
3298 if (fDefaultVertexArrayAttribState.count() != attrCount) { 3314 if (fDefaultVertexArrayAttribState.count() != attrCount) {
3299 fDefaultVertexArrayAttribState.resize(attrCount); 3315 fDefaultVertexArrayAttribState.resize(attrCount);
3300 } 3316 }
3301 attribState = &fDefaultVertexArrayAttribState; 3317 attribState = &fDefaultVertexArrayAttribState;
3302 } 3318 }
3303 return attribState; 3319 return attribState;
3304 } 3320 }
OLDNEW
« no previous file with comments | « src/gpu/gl/GrGLGpu.h ('k') | src/gpu/gl/GrGLProgram.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698