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

Unified Diff: src/core/SkFilterShader.cpp

Issue 1562193002: add SkShader::newWithColorFilter (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: tweak formatting 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/core/SkFilterShader.h ('k') | src/ports/SkGlobalInitialization_chromium.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkFilterShader.cpp
diff --git a/src/core/SkFilterShader.cpp b/src/core/SkFilterShader.cpp
deleted file mode 100644
index 2f07c23d95d99299b13541dafd9ab1877dde5050..0000000000000000000000000000000000000000
--- a/src/core/SkFilterShader.cpp
+++ /dev/null
@@ -1,99 +0,0 @@
-/*
- * Copyright 2013 Google Inc.
- *
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#include "SkFilterShader.h"
-
-#include "SkColorFilter.h"
-#include "SkReadBuffer.h"
-#include "SkWriteBuffer.h"
-#include "SkShader.h"
-#include "SkString.h"
-
-SkFilterShader::SkFilterShader(SkShader* shader, SkColorFilter* filter) {
- fShader = shader;
- shader->ref();
-
- fFilter = filter;
- filter->ref();
-}
-
-SkFilterShader::~SkFilterShader() {
- fFilter->unref();
- fShader->unref();
-}
-
-SkFlattenable* SkFilterShader::CreateProc(SkReadBuffer& buffer) {
- SkAutoTUnref<SkShader> shader(buffer.readShader());
- SkAutoTUnref<SkColorFilter> filter(buffer.readColorFilter());
- if (!shader.get() || !filter.get()) {
- return nullptr;
- }
- return new SkFilterShader(shader, filter);
-}
-
-void SkFilterShader::flatten(SkWriteBuffer& buffer) const {
- buffer.writeFlattenable(fShader);
- buffer.writeFlattenable(fFilter);
-}
-
-uint32_t SkFilterShader::FilterShaderContext::getFlags() const {
- const SkFilterShader& filterShader = static_cast<const SkFilterShader&>(fShader);
-
- uint32_t shaderF = fShaderContext->getFlags();
- uint32_t filterF = filterShader.fFilter->getFlags();
-
- // if the filter might change alpha, clear the opaque flag in the shader
- if (!(filterF & SkColorFilter::kAlphaUnchanged_Flag)) {
- shaderF &= ~SkShader::kOpaqueAlpha_Flag;
- }
- return shaderF;
-}
-
-SkShader::Context* SkFilterShader::onCreateContext(const ContextRec& rec, void* storage) const {
- char* shaderContextStorage = (char*)storage + sizeof(FilterShaderContext);
- SkShader::Context* shaderContext = fShader->createContext(rec, shaderContextStorage);
- if (nullptr == shaderContext) {
- return nullptr;
- }
- return new (storage) FilterShaderContext(*this, shaderContext, rec);
-}
-
-size_t SkFilterShader::contextSize() const {
- return sizeof(FilterShaderContext) + fShader->contextSize();
-}
-
-SkFilterShader::FilterShaderContext::FilterShaderContext(const SkFilterShader& filterShader,
- SkShader::Context* shaderContext,
- const ContextRec& rec)
- : INHERITED(filterShader, rec)
- , fShaderContext(shaderContext) {}
-
-SkFilterShader::FilterShaderContext::~FilterShaderContext() {
- fShaderContext->~Context();
-}
-
-void SkFilterShader::FilterShaderContext::shadeSpan(int x, int y, SkPMColor result[], int count) {
- const SkFilterShader& filterShader = static_cast<const SkFilterShader&>(fShader);
-
- fShaderContext->shadeSpan(x, y, result, count);
- filterShader.fFilter->filterSpan(result, count, result);
-}
-
-#ifndef SK_IGNORE_TO_STRING
-void SkFilterShader::toString(SkString* str) const {
- str->append("SkFilterShader: (");
-
- str->append("Shader: ");
- fShader->toString(str);
- str->append(" Filter: ");
- // TODO: add "fFilter->toString(str);" once SkColorFilter::toString is added
-
- this->INHERITED::toString(str);
-
- str->append(")");
-}
-#endif
« no previous file with comments | « src/core/SkFilterShader.h ('k') | src/ports/SkGlobalInitialization_chromium.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698