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

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

Issue 1925303002: Add mipmap loading to Vulkan. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Fixes to handle mipmap allocations and autogen Created 4 years, 7 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 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 #include "GrGLGpu.h" 8 #include "GrGLGpu.h"
9 #include "GrGLBuffer.h" 9 #include "GrGLBuffer.h"
10 #include "GrGLGLSL.h" 10 #include "GrGLGLSL.h"
(...skipping 862 matching lines...) Expand 10 before | Expand all | Expand 10 after
873 if (GrPixelConfigIsCompressed(glTex->desc().fConfig)) { 873 if (GrPixelConfigIsCompressed(glTex->desc().fConfig)) {
874 // We check that config == desc.fConfig in GrGLGpu::canWriteTexturePixel s() 874 // We check that config == desc.fConfig in GrGLGpu::canWriteTexturePixel s()
875 SkASSERT(config == glTex->desc().fConfig); 875 SkASSERT(config == glTex->desc().fConfig);
876 success = this->uploadCompressedTexData(glTex->desc(), glTex->target(), texels, 876 success = this->uploadCompressedTexData(glTex->desc(), glTex->target(), texels,
877 kWrite_UploadType, left, top, wi dth, height); 877 kWrite_UploadType, left, top, wi dth, height);
878 } else { 878 } else {
879 success = this->uploadTexData(glTex->desc(), glTex->target(), kWrite_Upl oadType, 879 success = this->uploadTexData(glTex->desc(), glTex->target(), kWrite_Upl oadType,
880 left, top, width, height, config, texels); 880 left, top, width, height, config, texels);
881 } 881 }
882 882
883 if (success) {
884 SkIRect rect = SkIRect::MakeXYWH(left, top, width, height);
885 this->didWriteToSurface(surface, &rect, texels.count());
886 }
887
888 return success; 883 return success;
889 } 884 }
890 885
891 bool GrGLGpu::onTransferPixels(GrSurface* surface, 886 bool GrGLGpu::onTransferPixels(GrSurface* surface,
892 int left, int top, int width, int height, 887 int left, int top, int width, int height,
893 GrPixelConfig config, GrBuffer* transferBuffer, 888 GrPixelConfig config, GrBuffer* transferBuffer,
894 size_t offset, size_t rowBytes) { 889 size_t offset, size_t rowBytes) {
895 GrGLTexture* glTex = static_cast<GrGLTexture*>(surface->asTexture()); 890 GrGLTexture* glTex = static_cast<GrGLTexture*>(surface->asTexture());
896 891
897 if (!check_write_and_transfer_input(glTex, surface, config)) { 892 if (!check_write_and_transfer_input(glTex, surface, config)) {
(...skipping 14 matching lines...) Expand all
912 this->bindBuffer(kXferCpuToGpu_GrBufferType, glBuffer); 907 this->bindBuffer(kXferCpuToGpu_GrBufferType, glBuffer);
913 908
914 bool success = false; 909 bool success = false;
915 GrMipLevel mipLevel; 910 GrMipLevel mipLevel;
916 mipLevel.fPixels = transferBuffer; 911 mipLevel.fPixels = transferBuffer;
917 mipLevel.fRowBytes = rowBytes; 912 mipLevel.fRowBytes = rowBytes;
918 SkSTArray<1, GrMipLevel> texels; 913 SkSTArray<1, GrMipLevel> texels;
919 texels.push_back(mipLevel); 914 texels.push_back(mipLevel);
920 success = this->uploadTexData(glTex->desc(), glTex->target(), kTransfer_Uplo adType, 915 success = this->uploadTexData(glTex->desc(), glTex->target(), kTransfer_Uplo adType,
921 left, top, width, height, config, texels); 916 left, top, width, height, config, texels);
922 if (success) { 917 return success;
923 SkIRect rect = SkIRect::MakeXYWH(left, top, width, height);
924 this->didWriteToSurface(surface, &rect);
925 return true;
926 }
927
928 return false;
929 } 918 }
930 919
931 // For GL_[UN]PACK_ALIGNMENT. 920 // For GL_[UN]PACK_ALIGNMENT.
932 static inline GrGLint config_alignment(GrPixelConfig config) { 921 static inline GrGLint config_alignment(GrPixelConfig config) {
933 SkASSERT(!GrPixelConfigIsCompressed(config)); 922 SkASSERT(!GrPixelConfigIsCompressed(config));
934 switch (config) { 923 switch (config) {
935 case kAlpha_8_GrPixelConfig: 924 case kAlpha_8_GrPixelConfig:
936 return 1; 925 return 1;
937 case kRGB_565_GrPixelConfig: 926 case kRGB_565_GrPixelConfig:
938 case kRGBA_4444_GrPixelConfig: 927 case kRGBA_4444_GrPixelConfig:
(...skipping 1726 matching lines...) Expand 10 before | Expand all | Expand 10 after
2665 this->didWriteToSurface(target, bounds); 2654 this->didWriteToSurface(target, bounds);
2666 } 2655 }
2667 2656
2668 void GrGLGpu::flushViewport(const GrGLIRect& viewport) { 2657 void GrGLGpu::flushViewport(const GrGLIRect& viewport) {
2669 if (fHWViewport != viewport) { 2658 if (fHWViewport != viewport) {
2670 viewport.pushToGLViewport(this->glInterface()); 2659 viewport.pushToGLViewport(this->glInterface());
2671 fHWViewport = viewport; 2660 fHWViewport = viewport;
2672 } 2661 }
2673 } 2662 }
2674 2663
2675 void GrGLGpu::didWriteToSurface(GrSurface* surface, const SkIRect* bounds, int m ipLevels) const {
2676 SkASSERT(surface);
2677 // Mark any MIP chain and resolve buffer as dirty if and only if there is a non-empty bounds.
2678 if (nullptr == bounds || !bounds->isEmpty()) {
2679 if (GrRenderTarget* target = surface->asRenderTarget()) {
2680 target->flagAsNeedingResolve(bounds);
2681 }
2682 GrTexture* texture = surface->asTexture();
2683 if (texture && 1 == mipLevels) {
2684 texture->texturePriv().dirtyMipMaps(true);
2685 }
2686 }
2687 }
2688
2689 GrGLenum gPrimitiveType2GLMode[] = { 2664 GrGLenum gPrimitiveType2GLMode[] = {
2690 GR_GL_TRIANGLES, 2665 GR_GL_TRIANGLES,
2691 GR_GL_TRIANGLE_STRIP, 2666 GR_GL_TRIANGLE_STRIP,
2692 GR_GL_TRIANGLE_FAN, 2667 GR_GL_TRIANGLE_FAN,
2693 GR_GL_POINTS, 2668 GR_GL_POINTS,
2694 GR_GL_LINES, 2669 GR_GL_LINES,
2695 GR_GL_LINE_STRIP 2670 GR_GL_LINE_STRIP
2696 }; 2671 };
2697 2672
2698 #define SWAP_PER_DRAW 0 2673 #define SWAP_PER_DRAW 0
(...skipping 1573 matching lines...) Expand 10 before | Expand all | Expand 10 after
4272 if (GR_GL_TEXTURE_EXTERNAL == glTexture->target() || 4247 if (GR_GL_TEXTURE_EXTERNAL == glTexture->target() ||
4273 GR_GL_TEXTURE_RECTANGLE == glTexture->target()) { 4248 GR_GL_TEXTURE_RECTANGLE == glTexture->target()) {
4274 copyParams->fFilter = GrTextureParams::kNone_FilterMode; 4249 copyParams->fFilter = GrTextureParams::kNone_FilterMode;
4275 copyParams->fWidth = texture->width(); 4250 copyParams->fWidth = texture->width();
4276 copyParams->fHeight = texture->height(); 4251 copyParams->fHeight = texture->height();
4277 return true; 4252 return true;
4278 } 4253 }
4279 } 4254 }
4280 return false; 4255 return false;
4281 } 4256 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698