diff options
author | Brian Salomon <bsalomon@google.com> | 2018-02-02 20:32:49 -0500 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2018-02-03 01:59:59 +0000 |
commit | bdecacfbe47bc7211336bb847bb33c00ef85ea3e (patch) | |
tree | fdaac47f9254d9a8e3de61604b899eae8cb718ff /tools | |
parent | 816acee9be62d9de323ff5144017451e443b3329 (diff) |
Revert "Revert "Revert "Revert "Revert "Revert "Redefine the meaning of sample counts in GPU backend.""""""
This reverts commit 3a2cc2c2ec124de36d2544b2a523ef1dd317ca32.
Fix code with samplecnt=0 that slipped in between trybots/CQ and landing of previous version
Change-Id: Iab19f2e8d1e9901601c8c76244d7a88c5d707fab
Reviewed-on: https://skia-review.googlesource.com/103181
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Brian Salomon <bsalomon@google.com>
Diffstat (limited to 'tools')
23 files changed, 56 insertions, 49 deletions
diff --git a/tools/fiddle/fiddle_main.cpp b/tools/fiddle/fiddle_main.cpp index 4ba84f38ca..684bc2ae48 100644 --- a/tools/fiddle/fiddle_main.cpp +++ b/tools/fiddle/fiddle_main.cpp @@ -133,7 +133,7 @@ static bool setup_backend_objects(GrContext* context, backingDesc.fHeight = bm.height(); // This config must match the SkColorType used in draw.cpp in the SkImage and Surface factories backingDesc.fConfig = kRGBA_8888_GrPixelConfig; - backingDesc.fSampleCnt = 0; + backingDesc.fSampleCnt = 1; if (!bm.empty()) { SkPixmap originalPixmap; diff --git a/tools/flags/SkCommonFlagsConfig.cpp b/tools/flags/SkCommonFlagsConfig.cpp index d38d70a1dc..9d1c2ddadd 100644 --- a/tools/flags/SkCommonFlagsConfig.cpp +++ b/tools/flags/SkCommonFlagsConfig.cpp @@ -391,7 +391,7 @@ SkCommandLineConfigGpu* parse_command_line_config_gpu(const SkString& tag, bool seenUseDIText =false; bool useDIText = false; bool seenSamples = false; - int samples = 0; + int samples = 1; bool seenColor = false; SkColorType colorType = kRGBA_8888_SkColorType; SkAlphaType alphaType = kPremul_SkAlphaType; diff --git a/tools/gpu/GrTest.cpp b/tools/gpu/GrTest.cpp index 829ddcbe89..06d9b831a5 100644 --- a/tools/gpu/GrTest.cpp +++ b/tools/gpu/GrTest.cpp @@ -182,6 +182,13 @@ void GrGpu::Stats::dumpKeyValuePairs(SkTArray<SkString>* keys, SkTArray<double>* #endif +GrBackendTexture GrGpu::createTestingOnlyBackendTexture(void* pixels, int w, int h, + SkColorType colorType, bool isRenderTarget, + GrMipMapped mipMapped) { + GrPixelConfig config = SkImageInfo2GrPixelConfig(colorType, nullptr, *this->caps()); + return this->createTestingOnlyBackendTexture(pixels, w, h, config, isRenderTarget, mipMapped); +} + #if GR_CACHE_STATS void GrResourceCache::getStats(Stats* stats) const { stats->reset(); diff --git a/tools/sk_app/DisplayParams.h b/tools/sk_app/DisplayParams.h index 959735e8ff..203e8bdeca 100644 --- a/tools/sk_app/DisplayParams.h +++ b/tools/sk_app/DisplayParams.h @@ -13,10 +13,7 @@ namespace sk_app { struct DisplayParams { - DisplayParams() - : fColorType(kN32_SkColorType) - , fColorSpace(nullptr) - , fMSAASampleCount(0) {} + DisplayParams() : fColorType(kN32_SkColorType), fColorSpace(nullptr), fMSAASampleCount(1) {} SkColorType fColorType; sk_sp<SkColorSpace> fColorSpace; diff --git a/tools/sk_app/GLWindowContext.cpp b/tools/sk_app/GLWindowContext.cpp index 9ef5141fee..9d042cf19e 100644 --- a/tools/sk_app/GLWindowContext.cpp +++ b/tools/sk_app/GLWindowContext.cpp @@ -24,9 +24,7 @@ GLWindowContext::GLWindowContext(const DisplayParams& params) : WindowContext(params) , fBackendContext(nullptr) , fSurface(nullptr) { - fDisplayParams.fMSAASampleCount = fDisplayParams.fMSAASampleCount ? - GrNextPow2(fDisplayParams.fMSAASampleCount) : - 0; + fDisplayParams.fMSAASampleCount = GrNextPow2(fDisplayParams.fMSAASampleCount); } void GLWindowContext::initializeContext() { @@ -34,7 +32,7 @@ void GLWindowContext::initializeContext() { fBackendContext = this->onInitializeContext(); fContext = GrContext::MakeGL(fBackendContext, fDisplayParams.fGrContextOptions); - if (!fContext && fDisplayParams.fMSAASampleCount) { + if (!fContext && fDisplayParams.fMSAASampleCount > 1) { fDisplayParams.fMSAASampleCount /= 2; this->initializeContext(); return; diff --git a/tools/sk_app/Window.cpp b/tools/sk_app/Window.cpp index 29e4864ba1..1694beaac8 100644 --- a/tools/sk_app/Window.cpp +++ b/tools/sk_app/Window.cpp @@ -117,7 +117,7 @@ void Window::setRequestedDisplayParams(const DisplayParams& params, bool /* allo int Window::sampleCount() const { if (!fWindowContext) { - return -1; + return 0; } return fWindowContext->sampleCount(); } diff --git a/tools/sk_app/WindowContext.h b/tools/sk_app/WindowContext.h index 5e7d76d4ba..71c21ac089 100644 --- a/tools/sk_app/WindowContext.h +++ b/tools/sk_app/WindowContext.h @@ -21,11 +21,11 @@ namespace sk_app { class WindowContext { public: WindowContext(const DisplayParams& params) - : fContext(nullptr) - , fDisplayParams(params) - , fSurfaceProps(SkSurfaceProps::kLegacyFontHost_InitType) - , fSampleCount(0) - , fStencilBits(0) {} + : fContext(nullptr) + , fDisplayParams(params) + , fSurfaceProps(SkSurfaceProps::kLegacyFontHost_InitType) + , fSampleCount(1) + , fStencilBits(0) {} virtual ~WindowContext() {} diff --git a/tools/sk_app/android/GLWindowContext_android.cpp b/tools/sk_app/android/GLWindowContext_android.cpp index acdb587230..5111114115 100644 --- a/tools/sk_app/android/GLWindowContext_android.cpp +++ b/tools/sk_app/android/GLWindowContext_android.cpp @@ -70,6 +70,8 @@ sk_sp<const GrGLInterface> GLWindowContext_android::onInitializeContext() { SkAssertResult(eglBindAPI(EGL_OPENGL_ES_API)); EGLint numConfigs = 0; + EGLint eglSampleCnt = fDisplayParams.fMSAASampleCount > 1 ? fDisplayParams.fMSAASampleCount > 1 + : 0; const EGLint configAttribs[] = { EGL_SURFACE_TYPE, EGL_PBUFFER_BIT, EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT, @@ -78,8 +80,8 @@ sk_sp<const GrGLInterface> GLWindowContext_android::onInitializeContext() { EGL_BLUE_SIZE, 8, EGL_ALPHA_SIZE, 8, EGL_STENCIL_SIZE, 8, - EGL_SAMPLE_BUFFERS, fDisplayParams.fMSAASampleCount ? 1 : 0, - EGL_SAMPLES, fDisplayParams.fMSAASampleCount, + EGL_SAMPLE_BUFFERS, eglSampleCnt ? 1 : 0, + EGL_SAMPLES, eglSampleCnt, EGL_NONE }; @@ -131,6 +133,7 @@ sk_sp<const GrGLInterface> GLWindowContext_android::onInitializeContext() { eglGetConfigAttrib(fDisplay, surfaceConfig, EGL_STENCIL_SIZE, &fStencilBits); eglGetConfigAttrib(fDisplay, surfaceConfig, EGL_SAMPLES, &fSampleCount); + fSampleCount = SkTMax(fSampleCount, 1); return GrGLMakeNativeInterface(); } diff --git a/tools/sk_app/ios/GLWindowContext_ios.cpp b/tools/sk_app/ios/GLWindowContext_ios.cpp index f4c0d6b3c0..2a57b33e30 100644 --- a/tools/sk_app/ios/GLWindowContext_ios.cpp +++ b/tools/sk_app/ios/GLWindowContext_ios.cpp @@ -67,6 +67,7 @@ sk_sp<const GrGLInterface> GLWindowContext_ios::onInitializeContext() { SDL_GL_GetAttribute(SDL_GL_STENCIL_SIZE, &fStencilBits); SDL_GL_GetAttribute(SDL_GL_MULTISAMPLESAMPLES, &fSampleCount); + fSampleCount = SkTMax(fSampleCount, 1); SDL_GL_GetDrawableSize(fWindow, &fWidth, &fHeight); glViewport(0, 0, fWidth, fHeight); diff --git a/tools/sk_app/ios/RasterWindowContext_ios.cpp b/tools/sk_app/ios/RasterWindowContext_ios.cpp index cae5774c28..53d7c1a372 100644 --- a/tools/sk_app/ios/RasterWindowContext_ios.cpp +++ b/tools/sk_app/ios/RasterWindowContext_ios.cpp @@ -79,6 +79,7 @@ sk_sp<const GrGLInterface> RasterWindowContext_ios::onInitializeContext() { SDL_GL_GetAttribute(SDL_GL_STENCIL_SIZE, &fStencilBits); SDL_GL_GetAttribute(SDL_GL_MULTISAMPLESAMPLES, &fSampleCount); + fSampleCount = SkTMax(fSampleCount, 1); SDL_GL_GetDrawableSize(fWindow, &fWidth, &fHeight); glViewport(0, 0, fWidth, fHeight); diff --git a/tools/sk_app/ios/Window_ios.cpp b/tools/sk_app/ios/Window_ios.cpp index c1bdeae5fc..ac0ad0caa0 100644 --- a/tools/sk_app/ios/Window_ios.cpp +++ b/tools/sk_app/ios/Window_ios.cpp @@ -49,7 +49,7 @@ bool Window_ios::initWindow() { SDL_GL_SetAttribute(SDL_GL_ACCELERATED_VISUAL, 1); - if (fRequestedDisplayParams.fMSAASampleCount > 0) { + if (fRequestedDisplayParams.fMSAASampleCount > 1) { SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, 1); SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, fRequestedDisplayParams.fMSAASampleCount); } else { diff --git a/tools/sk_app/ios/Window_ios.h b/tools/sk_app/ios/Window_ios.h index 667fa74e82..a0fed90697 100644 --- a/tools/sk_app/ios/Window_ios.h +++ b/tools/sk_app/ios/Window_ios.h @@ -18,11 +18,7 @@ namespace sk_app { class Window_ios : public Window { public: - Window_ios() - : INHERITED() - , fWindow(nullptr) - , fWindowID(0) - , fMSAASampleCount(0) {} + Window_ios() : INHERITED(), fWindow(nullptr), fWindowID(0), fMSAASampleCount(1) {} ~Window_ios() override { this->closeWindow(); } bool initWindow(); diff --git a/tools/sk_app/mac/GLWindowContext_mac.cpp b/tools/sk_app/mac/GLWindowContext_mac.cpp index 005fc07df4..67fb853fee 100644 --- a/tools/sk_app/mac/GLWindowContext_mac.cpp +++ b/tools/sk_app/mac/GLWindowContext_mac.cpp @@ -67,6 +67,7 @@ sk_sp<const GrGLInterface> GLWindowContext_mac::onInitializeContext() { SDL_GL_GetAttribute(SDL_GL_STENCIL_SIZE, &fStencilBits); SDL_GL_GetAttribute(SDL_GL_MULTISAMPLESAMPLES, &fSampleCount); + fSampleCount = SkTMax(fSampleCount, 1); SDL_GetWindowSize(fWindow, &fWidth, &fHeight); glViewport(0, 0, fWidth, fHeight); diff --git a/tools/sk_app/mac/RasterWindowContext_mac.cpp b/tools/sk_app/mac/RasterWindowContext_mac.cpp index 67022af7fe..fbe9837911 100644 --- a/tools/sk_app/mac/RasterWindowContext_mac.cpp +++ b/tools/sk_app/mac/RasterWindowContext_mac.cpp @@ -79,6 +79,7 @@ sk_sp<const GrGLInterface> RasterWindowContext_mac::onInitializeContext() { SDL_GL_GetAttribute(SDL_GL_STENCIL_SIZE, &fStencilBits); SDL_GL_GetAttribute(SDL_GL_MULTISAMPLESAMPLES, &fSampleCount); + fSampleCount = SkTMax(fSampleCount, 1); SDL_GetWindowSize(fWindow, &fWidth, &fHeight); glViewport(0, 0, fWidth, fHeight); diff --git a/tools/sk_app/mac/Window_mac.cpp b/tools/sk_app/mac/Window_mac.cpp index 8de5b10450..f2620518a2 100644 --- a/tools/sk_app/mac/Window_mac.cpp +++ b/tools/sk_app/mac/Window_mac.cpp @@ -49,7 +49,7 @@ bool Window_mac::initWindow() { SDL_GL_SetAttribute(SDL_GL_ACCELERATED_VISUAL, 1); - if (fRequestedDisplayParams.fMSAASampleCount > 0) { + if (fRequestedDisplayParams.fMSAASampleCount > 1) { SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, 1); SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, fRequestedDisplayParams.fMSAASampleCount); } else { diff --git a/tools/sk_app/mac/Window_mac.h b/tools/sk_app/mac/Window_mac.h index aa5c8df696..35cba095fa 100644 --- a/tools/sk_app/mac/Window_mac.h +++ b/tools/sk_app/mac/Window_mac.h @@ -18,11 +18,7 @@ namespace sk_app { class Window_mac : public Window { public: - Window_mac() - : INHERITED() - , fWindow(nullptr) - , fWindowID(0) - , fMSAASampleCount(0) {} + Window_mac() : INHERITED(), fWindow(nullptr), fWindowID(0), fMSAASampleCount(1) {} ~Window_mac() override { this->closeWindow(); } bool initWindow(); diff --git a/tools/sk_app/unix/GLWindowContext_unix.cpp b/tools/sk_app/unix/GLWindowContext_unix.cpp index 25ec95cdd6..3a3a4b16d4 100644 --- a/tools/sk_app/unix/GLWindowContext_unix.cpp +++ b/tools/sk_app/unix/GLWindowContext_unix.cpp @@ -99,6 +99,7 @@ sk_sp<const GrGLInterface> GLWindowContext_xlib::onInitializeContext() { glXGetConfig(fDisplay, fVisualInfo, GLX_STENCIL_SIZE, &fStencilBits); glXGetConfig(fDisplay, fVisualInfo, GLX_SAMPLES_ARB, &fSampleCount); + fSampleCount = SkTMax(fSampleCount, 1); XWindow root; int x, y; diff --git a/tools/sk_app/unix/Window_unix.cpp b/tools/sk_app/unix/Window_unix.cpp index f5ca5ee073..745b4dd3fb 100644 --- a/tools/sk_app/unix/Window_unix.cpp +++ b/tools/sk_app/unix/Window_unix.cpp @@ -72,7 +72,7 @@ bool Window_unix::initWindow(Display* display) { None }; SkASSERT(nullptr == fVisualInfo); - if (fRequestedDisplayParams.fMSAASampleCount > 0) { + if (fRequestedDisplayParams.fMSAASampleCount > 1) { static const GLint kChooseFBConifgAttCnt = SK_ARRAY_COUNT(kChooseFBConfigAtt); GLint msaaChooseFBConfigAtt[kChooseFBConifgAttCnt + 4]; memcpy(msaaChooseFBConfigAtt, kChooseFBConfigAtt, sizeof(kChooseFBConfigAtt)); diff --git a/tools/sk_app/unix/Window_unix.h b/tools/sk_app/unix/Window_unix.h index b59f502eb9..62a2795098 100644 --- a/tools/sk_app/unix/Window_unix.h +++ b/tools/sk_app/unix/Window_unix.h @@ -20,13 +20,14 @@ namespace sk_app { class Window_unix : public Window { public: - Window_unix() : Window() - , fDisplay(nullptr) - , fWindow(0) - , fGC(nullptr) - , fFBConfig(nullptr) - , fVisualInfo(nullptr) - , fMSAASampleCount(0) {} + Window_unix() + : Window() + , fDisplay(nullptr) + , fWindow(0) + , fGC(nullptr) + , fFBConfig(nullptr) + , fVisualInfo(nullptr) + , fMSAASampleCount(1) {} ~Window_unix() override { this->closeWindow(); } bool initWindow(Display* display); diff --git a/tools/sk_app/win/ANGLEWindowContext_win.cpp b/tools/sk_app/win/ANGLEWindowContext_win.cpp index 649528d6cd..452b462ba9 100644 --- a/tools/sk_app/win/ANGLEWindowContext_win.cpp +++ b/tools/sk_app/win/ANGLEWindowContext_win.cpp @@ -76,7 +76,8 @@ sk_sp<const GrGLInterface> ANGLEGLWindowContext_win::onInitializeContext() { } EGLint numConfigs; fSampleCount = this->getDisplayParams().fMSAASampleCount; - const int sampleBuffers = fSampleCount > 0 ? 1 : 0; + const int sampleBuffers = fSampleCount > 1 ? 1 : 0; + const int eglSampleCnt = fSampleCount > 1 ? fSampleCount : 0; const EGLint configAttribs[] = {EGL_RENDERABLE_TYPE, // We currently only support ES3. EGL_OPENGL_ES3_BIT, @@ -91,7 +92,7 @@ sk_sp<const GrGLInterface> ANGLEGLWindowContext_win::onInitializeContext() { EGL_SAMPLE_BUFFERS, sampleBuffers, EGL_SAMPLES, - fSampleCount, + eglSampleCnt, EGL_NONE}; EGLConfig surfaceConfig; diff --git a/tools/sk_app/win/GLWindowContext_win.cpp b/tools/sk_app/win/GLWindowContext_win.cpp index 7e43d2b544..1c583cb1ed 100644 --- a/tools/sk_app/win/GLWindowContext_win.cpp +++ b/tools/sk_app/win/GLWindowContext_win.cpp @@ -96,8 +96,9 @@ sk_sp<const GrGLInterface> GLWindowContext_win::onInitializeContext() { 1, &kSampleCountAttr, &fSampleCount); + fSampleCount = SkTMax(fSampleCount, 1); } else { - fSampleCount = 0; + fSampleCount = 1; } RECT rect; diff --git a/tools/skpbench/skpbench.cpp b/tools/skpbench/skpbench.cpp index fcab2d3af8..6b89bc27ff 100644 --- a/tools/skpbench/skpbench.cpp +++ b/tools/skpbench/skpbench.cpp @@ -292,7 +292,8 @@ int main(int argc, char** argv) { GrPixelConfig grPixConfig = SkImageInfo2GrPixelConfig(config->getColorType(), config->getColorSpace(), *ctx->caps()); - int supportedSampleCount = ctx->caps()->getSampleCount(config->getSamples(), grPixConfig); + int supportedSampleCount = + ctx->caps()->getRenderTargetSampleCount(config->getSamples(), grPixConfig); if (supportedSampleCount != config->getSamples()) { exitf(ExitErr::kUnavailable, "sample count %i not supported by platform", config->getSamples()); diff --git a/tools/viewer/Viewer.cpp b/tools/viewer/Viewer.cpp index 198f9baab6..35b0e146f9 100644 --- a/tools/viewer/Viewer.cpp +++ b/tools/viewer/Viewer.cpp @@ -78,7 +78,7 @@ static DEFINE_string(jsons, "jsons", "Directory to read (Bodymovin) jsons from." static DEFINE_string2(backend, b, "sw", "Backend to use. Allowed values are " BACKENDS_STR "."); -static DEFINE_int32(msaa, 0, "Number of subpixel samples. 0 for no HW antialiasing."); +static DEFINE_int32(msaa, 1, "Number of subpixel samples. 0 for no HW antialiasing."); DECLARE_int32(threads) @@ -501,7 +501,7 @@ void Viewer::updateTitle() { if (!fWindow) { return; } - if (fWindow->sampleCount() < 0) { + if (fWindow->sampleCount() < 1) { return; // Surface hasn't been created yet. } @@ -561,7 +561,8 @@ void Viewer::updateTitle() { title.append(" ["); title.append(kBackendTypeStrings[fBackendType]); - if (int msaa = fWindow->sampleCount()) { + int msaa = fWindow->sampleCount(); + if (msaa > 1) { title.appendf(" MSAA: %i", msaa); } title.append("]"); @@ -994,7 +995,7 @@ void Viewer::drawImGui() { if (ctx) { int sampleCount = fWindow->sampleCount(); ImGui::Text("MSAA: "); ImGui::SameLine(); - ImGui::RadioButton("0", &sampleCount, 0); ImGui::SameLine(); + ImGui::RadioButton("1", &sampleCount, 1); ImGui::SameLine(); ImGui::RadioButton("4", &sampleCount, 4); ImGui::SameLine(); ImGui::RadioButton("8", &sampleCount, 8); ImGui::SameLine(); ImGui::RadioButton("16", &sampleCount, 16); @@ -1018,7 +1019,7 @@ void Viewer::drawImGui() { if (!ctx) { ImGui::RadioButton("Software", true); - } else if (fWindow->sampleCount()) { + } else if (fWindow->sampleCount() > 1) { prButton(GpuPathRenderers::kDefault); prButton(GpuPathRenderers::kAll); if (ctx->caps()->shaderCaps()->pathRenderingSupport()) { @@ -1198,7 +1199,7 @@ void Viewer::updateUIState() { if (!fWindow) { return; } - if (fWindow->sampleCount() < 0) { + if (fWindow->sampleCount() < 1) { return; // Surface hasn't been created yet. } @@ -1244,7 +1245,7 @@ void Viewer::updateUIState() { const GrContext* ctx = fWindow->getGrContext(); if (!ctx) { prState[kOptions].append("Software"); - } else if (fWindow->sampleCount()) { + } else if (fWindow->sampleCount() > 1) { prState[kOptions].append(gPathRendererNames[GpuPathRenderers::kDefault]); prState[kOptions].append(gPathRendererNames[GpuPathRenderers::kAll]); if (ctx->caps()->shaderCaps()->pathRenderingSupport()) { |