diff options
author | Brian Salomon <bsalomon@google.com> | 2017-11-20 11:01:54 -0500 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2017-11-20 17:59:48 +0000 |
commit | 40dc8a71f5d55dd7ed4e64c883664efae6da70ca (patch) | |
tree | adf8660a7069e7586353baa12f0466d8002150a8 /tools/gpu | |
parent | 34b4b37a40fbed01770ebfaa4993769bb17b3d05 (diff) |
Add clear function to TestAtlasTextRendering interface
Bug: skia:
Change-Id: I24563abe5e72e57e6764ddf6aca76ccf098cc488
Reviewed-on: https://skia-review.googlesource.com/73640
Reviewed-by: Jim Van Verth <jvanverth@google.com>
Commit-Queue: Brian Salomon <bsalomon@google.com>
Diffstat (limited to 'tools/gpu')
-rw-r--r-- | tools/gpu/atlastext/GLTestAtlasTextRenderer.cpp | 44 | ||||
-rw-r--r-- | tools/gpu/atlastext/TestAtlasTextRenderer.h | 3 |
2 files changed, 33 insertions, 14 deletions
diff --git a/tools/gpu/atlastext/GLTestAtlasTextRenderer.cpp b/tools/gpu/atlastext/GLTestAtlasTextRenderer.cpp index 543f46012b..e113096692 100644 --- a/tools/gpu/atlastext/GLTestAtlasTextRenderer.cpp +++ b/tools/gpu/atlastext/GLTestAtlasTextRenderer.cpp @@ -31,9 +31,11 @@ public: void* makeTargetHandle(int width, int height) override; - void targetDeleted(void* target) override; + void targetDeleted(void* targetHandle) override; - SkBitmap readTargetHandle(void* target) override; + SkBitmap readTargetHandle(void* targetHandle) override; + + void clearTarget(void* targetHandle, uint32_t color) override; bool initialized() const { return 0 != fProgram; } @@ -381,7 +383,7 @@ void* GLTestAtlasTextRenderer::makeTargetHandle(int width, int height) { return nullptr; } callgl(Disable, GR_GL_SCISSOR_TEST); - callgl(ClearColor, 0.5, 0.5, 0.5, 1.0); + callgl(ClearColor, 0, 0, 0, 0.0); callgl(Clear, GR_GL_COLOR_BUFFER_BIT); checkgl(); Target* target = new Target; @@ -392,33 +394,47 @@ void* GLTestAtlasTextRenderer::makeTargetHandle(int width, int height) { return target; } -void GLTestAtlasTextRenderer::targetDeleted(void* target) { +void GLTestAtlasTextRenderer::targetDeleted(void* targetHandle) { auto restore = fContext->makeCurrentAndAutoRestore(); - Target* t = reinterpret_cast<Target*>(target); - callgl(DeleteFramebuffers, 1, &t->fFBOID); - callgl(DeleteRenderbuffers, 1, &t->fRBID); - delete t; + Target* target = reinterpret_cast<Target*>(targetHandle); + callgl(DeleteFramebuffers, 1, &target->fFBOID); + callgl(DeleteRenderbuffers, 1, &target->fRBID); + delete target; } -SkBitmap GLTestAtlasTextRenderer::readTargetHandle(void* target) { +SkBitmap GLTestAtlasTextRenderer::readTargetHandle(void* targetHandle) { auto restore = fContext->makeCurrentAndAutoRestore(); - Target* t = reinterpret_cast<Target*>(target); + Target* target = reinterpret_cast<Target*>(targetHandle); auto info = - SkImageInfo::Make(t->fWidth, t->fHeight, kRGBA_8888_SkColorType, kPremul_SkAlphaType); + SkImageInfo::Make(target->fWidth, target->fHeight, kRGBA_8888_SkColorType, kPremul_SkAlphaType); SkBitmap bmp; - bmp.setInfo(info, sizeof(uint32_t) * t->fWidth); + bmp.setInfo(info, sizeof(uint32_t) * target->fWidth); bmp.allocPixels(); - callgl(BindFramebuffer, GR_GL_FRAMEBUFFER, t->fFBOID); - callgl(ReadPixels, 0, 0, t->fWidth, t->fHeight, GR_GL_RGBA, GR_GL_UNSIGNED_BYTE, + callgl(BindFramebuffer, GR_GL_FRAMEBUFFER, target->fFBOID); + callgl(ReadPixels, 0, 0, target->fWidth, target->fHeight, GR_GL_RGBA, GR_GL_UNSIGNED_BYTE, bmp.getPixels()); checkgl(); return bmp; } +void GLTestAtlasTextRenderer::clearTarget(void* targetHandle, uint32_t color) { + auto restore = fContext->makeCurrentAndAutoRestore(); + + Target* target = reinterpret_cast<Target*>(targetHandle); + callgl(BindFramebuffer, GR_GL_FRAMEBUFFER, target->fFBOID); + callgl(Disable, GR_GL_SCISSOR_TEST); + float r = ((color >> 0) & 0xff) / 255.f; + float g = ((color >> 8) & 0xff) / 255.f; + float b = ((color >> 16) & 0xff) / 255.f; + float a = ((color >> 24) & 0xff) / 255.f; + callgl(ClearColor, r, g, b, a); + callgl(Clear, GR_GL_COLOR_BUFFER_BIT); +} + } // anonymous namespace namespace sk_gpu_test { diff --git a/tools/gpu/atlastext/TestAtlasTextRenderer.h b/tools/gpu/atlastext/TestAtlasTextRenderer.h index 068a60d2bb..6ba4326064 100644 --- a/tools/gpu/atlastext/TestAtlasTextRenderer.h +++ b/tools/gpu/atlastext/TestAtlasTextRenderer.h @@ -27,6 +27,9 @@ public: /** Makes a SkBitmap of the target handle's contents. */ virtual SkBitmap readTargetHandle(void* targetHandle) = 0; + + /** Clears the target to the specified color, encoded as RGBA (low to high byte order) */ + virtual void clearTarget(void* targetHandle, uint32_t color) = 0; }; } // namespace sk_gpu_test |