use SkBlendMode
skbug.com/5814 Test: compile only Change-Id: Ibbaff43df1117b2ca77fd8f917f03d88cc476330 (cherry picked from commit 26edbcba8a2ed4cb300e7f87e679e3b73cec2772)
This commit is contained in:
committed by
Derek Sollenberger
parent
0863156efd
commit
c2f31df8b3
@@ -32,7 +32,7 @@
|
||||
#include "SkPathEffect.h"
|
||||
#include "SkRasterizer.h"
|
||||
#include "SkShader.h"
|
||||
#include "SkXfermode.h"
|
||||
#include "SkBlendMode.h"
|
||||
#include "unicode/uloc.h"
|
||||
#include "unicode/ushape.h"
|
||||
#include "utils/Blur.h"
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
#include "SkGradientShader.h"
|
||||
#include "SkImagePriv.h"
|
||||
#include "SkShader.h"
|
||||
#include "SkXfermode.h"
|
||||
#include "SkBlendMode.h"
|
||||
#include "core_jni_helpers.h"
|
||||
|
||||
#include <Caches.h>
|
||||
@@ -237,7 +237,7 @@ static jlong ComposeShader_create(JNIEnv* env, jobject o,
|
||||
SkBlendMode mode = static_cast<SkBlendMode>(xfermodeHandle);
|
||||
SkShader* shader = SkShader::MakeComposeShader(sk_ref_sp(shaderA),
|
||||
sk_ref_sp(shaderB),
|
||||
(SkXfermode::Mode)mode).release();
|
||||
mode).release();
|
||||
return reinterpret_cast<jlong>(shader);
|
||||
}
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
#include <SkBitmap.h>
|
||||
#include <SkCanvas.h>
|
||||
#include <SkMatrix.h>
|
||||
#include <SkXfermode.h>
|
||||
#include <SkBlendMode.h>
|
||||
|
||||
#include <DeferredLayerUpdater.h>
|
||||
#include <SkiaShader.h>
|
||||
|
||||
@@ -25,7 +25,6 @@
|
||||
|
||||
#include <GLES2/gl2.h>
|
||||
#include <GLES2/gl2ext.h>
|
||||
#include <SkXfermode.h>
|
||||
|
||||
namespace android {
|
||||
namespace uirenderer {
|
||||
|
||||
@@ -257,7 +257,7 @@ void GlopBuilder::setFill(int color, float alphaScale,
|
||||
// If the blend mode cannot be implemented using shaders, fall
|
||||
// back to the default SrcOver blend mode instead
|
||||
if (CC_UNLIKELY(mCaches.extensions().hasFramebufferFetch())) {
|
||||
mDescription.framebufferMode = (SkXfermode::Mode)mode;
|
||||
mDescription.framebufferMode = mode;
|
||||
mDescription.swapSrcDst = (modeUsage == Blend::ModeOrderSwap::Swap);
|
||||
// blending in shader, don't enable
|
||||
} else {
|
||||
@@ -271,11 +271,11 @@ void GlopBuilder::setFill(int color, float alphaScale,
|
||||
|
||||
if (colorFilter) {
|
||||
SkColor color;
|
||||
SkXfermode::Mode xmode;
|
||||
SkBlendMode bmode;
|
||||
SkScalar srcColorMatrix[20];
|
||||
if (colorFilter->asColorMode(&color, &xmode)) {
|
||||
if (colorFilter->asColorMode(&color, &bmode)) {
|
||||
mOutGlop->fill.filterMode = mDescription.colorOp = ProgramDescription::ColorFilterMode::Blend;
|
||||
mDescription.colorMode = xmode;
|
||||
mDescription.colorMode = bmode;
|
||||
mOutGlop->fill.filter.color.set(color);
|
||||
} else if (colorFilter->asColorMatrix(srcColorMatrix)) {
|
||||
mOutGlop->fill.filterMode = mDescription.colorOp = ProgramDescription::ColorFilterMode::Matrix;
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
#include <GLES2/gl2.h>
|
||||
#include <GLES2/gl2ext.h>
|
||||
|
||||
#include <SkXfermode.h>
|
||||
#include <SkBlendMode.h>
|
||||
|
||||
#include "Debug.h"
|
||||
#include "FloatColor.h"
|
||||
@@ -142,7 +142,7 @@ struct ProgramDescription {
|
||||
Gradient gradientType;
|
||||
bool isSimpleGradient;
|
||||
|
||||
SkXfermode::Mode shadersMode;
|
||||
SkBlendMode shadersMode;
|
||||
|
||||
bool isBitmapFirst;
|
||||
GLenum bitmapWrapS;
|
||||
@@ -150,11 +150,11 @@ struct ProgramDescription {
|
||||
|
||||
// Color operations
|
||||
ColorFilterMode colorOp;
|
||||
SkXfermode::Mode colorMode;
|
||||
SkBlendMode colorMode;
|
||||
|
||||
// Framebuffer blending (requires Extensions.hasFramebufferFetch())
|
||||
// Ignored for all values < SkXfermode::kPlus_Mode
|
||||
SkXfermode::Mode framebufferMode;
|
||||
// Ignored for all values < SkBlendMode::kPlus
|
||||
SkBlendMode framebufferMode;
|
||||
bool swapSrcDst;
|
||||
|
||||
bool hasDebugHighlight;
|
||||
@@ -186,16 +186,16 @@ struct ProgramDescription {
|
||||
gradientType = kGradientLinear;
|
||||
isSimpleGradient = false;
|
||||
|
||||
shadersMode = SkXfermode::kClear_Mode;
|
||||
shadersMode = SkBlendMode::kClear;
|
||||
|
||||
isBitmapFirst = false;
|
||||
bitmapWrapS = GL_CLAMP_TO_EDGE;
|
||||
bitmapWrapT = GL_CLAMP_TO_EDGE;
|
||||
|
||||
colorOp = ColorFilterMode::None;
|
||||
colorMode = SkXfermode::kClear_Mode;
|
||||
colorMode = SkBlendMode::kClear;
|
||||
|
||||
framebufferMode = SkXfermode::kClear_Mode;
|
||||
framebufferMode = SkBlendMode::kClear;
|
||||
swapSrcDst = false;
|
||||
|
||||
hasDebugHighlight = false;
|
||||
@@ -244,7 +244,7 @@ struct ProgramDescription {
|
||||
key |= programid(gradientType) << PROGRAM_GRADIENT_TYPE_SHIFT;
|
||||
if (isBitmapFirst) key |= PROGRAM_KEY_BITMAP_FIRST;
|
||||
if (hasBitmap && hasGradient) {
|
||||
key |= (shadersMode & PROGRAM_MAX_XFERMODE) << PROGRAM_XFERMODE_SHADER_SHIFT;
|
||||
key |= ((int)shadersMode & PROGRAM_MAX_XFERMODE) << PROGRAM_XFERMODE_SHADER_SHIFT;
|
||||
}
|
||||
switch (colorOp) {
|
||||
case ColorFilterMode::Matrix:
|
||||
@@ -252,12 +252,12 @@ struct ProgramDescription {
|
||||
break;
|
||||
case ColorFilterMode::Blend:
|
||||
key |= PROGRAM_KEY_COLOR_BLEND;
|
||||
key |= (colorMode & PROGRAM_MAX_XFERMODE) << PROGRAM_XFERMODE_COLOR_OP_SHIFT;
|
||||
key |= ((int)colorMode & PROGRAM_MAX_XFERMODE) << PROGRAM_XFERMODE_COLOR_OP_SHIFT;
|
||||
break;
|
||||
case ColorFilterMode::None:
|
||||
break;
|
||||
}
|
||||
key |= (framebufferMode & PROGRAM_MAX_XFERMODE) << PROGRAM_XFERMODE_FRAMEBUFFER_SHIFT;
|
||||
key |= ((int)framebufferMode & PROGRAM_MAX_XFERMODE) << PROGRAM_XFERMODE_FRAMEBUFFER_SHIFT;
|
||||
if (swapSrcDst) key |= PROGRAM_KEY_SWAP_SRC_DST;
|
||||
if (modulate) key |= programid(0x1) << PROGRAM_MODULATE_SHIFT;
|
||||
if (hasVertexAlpha) key |= programid(0x1) << PROGRAM_HAS_VERTEX_ALPHA_SHIFT;
|
||||
|
||||
@@ -572,7 +572,7 @@ static bool shaderOp(const ProgramDescription& description, String8& shader,
|
||||
String8 ProgramCache::generateFragmentShader(const ProgramDescription& description) {
|
||||
String8 shader(gFS_Header_Start);
|
||||
|
||||
const bool blendFramebuffer = description.framebufferMode >= SkXfermode::kPlus_Mode;
|
||||
const bool blendFramebuffer = description.framebufferMode >= SkBlendMode::kPlus;
|
||||
if (blendFramebuffer) {
|
||||
shader.append(gFS_Header_Extension_FramebufferFetch);
|
||||
}
|
||||
@@ -809,12 +809,12 @@ String8 ProgramCache::generateFragmentShader(const ProgramDescription& descripti
|
||||
return shader;
|
||||
}
|
||||
|
||||
void ProgramCache::generateBlend(String8& shader, const char* name, SkXfermode::Mode mode) {
|
||||
void ProgramCache::generateBlend(String8& shader, const char* name, SkBlendMode mode) {
|
||||
shader.append("\nvec4 ");
|
||||
shader.append(name);
|
||||
shader.append("(vec4 src, vec4 dst) {\n");
|
||||
shader.append(" ");
|
||||
shader.append(gBlendOps[mode]);
|
||||
shader.append(gBlendOps[(int)mode]);
|
||||
shader.append("}\n");
|
||||
}
|
||||
|
||||
|
||||
@@ -51,7 +51,7 @@ private:
|
||||
Program* generateProgram(const ProgramDescription& description, programid key);
|
||||
String8 generateVertexShader(const ProgramDescription& description);
|
||||
String8 generateFragmentShader(const ProgramDescription& description);
|
||||
void generateBlend(String8& shader, const char* name, SkXfermode::Mode mode);
|
||||
void generateBlend(String8& shader, const char* name, SkBlendMode mode);
|
||||
void generateTextureWrap(String8& shader, GLenum wrapS, GLenum wrapT);
|
||||
|
||||
void printLongString(const String8& shader) const;
|
||||
|
||||
@@ -546,7 +546,7 @@ void SkiaCanvas::drawVertices(SkCanvas::VertexMode vertexMode, int vertexCount,
|
||||
#endif
|
||||
const int ptCount = vertexCount >> 1;
|
||||
mCanvas->drawVertices(vertexMode, ptCount, (SkPoint*)verts, (SkPoint*)texs,
|
||||
(SkColor*)colors, NULL, indices, indexCount, paint);
|
||||
(SkColor*)colors, indices, indexCount, paint);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
@@ -670,7 +670,7 @@ void SkiaCanvas::drawBitmapMesh(Bitmap& hwuiBitmap, int meshWidth, int meshHeigh
|
||||
tmpPaint.setShader(image->makeShader(SkShader::kClamp_TileMode, SkShader::kClamp_TileMode));
|
||||
|
||||
mCanvas->drawVertices(SkCanvas::kTriangles_VertexMode, ptCount, (SkPoint*)vertices,
|
||||
texs, (const SkColor*)colors, NULL, indices,
|
||||
texs, (const SkColor*)colors, indices,
|
||||
indexCount, tmpPaint);
|
||||
}
|
||||
|
||||
|
||||
@@ -140,8 +140,9 @@ void SkiaCanvasProxy::onDrawBitmapNine(const SkBitmap& bitmap, const SkIRect& ce
|
||||
}
|
||||
|
||||
void SkiaCanvasProxy::onDrawVertices(VertexMode mode, int vertexCount, const SkPoint vertices[],
|
||||
const SkPoint texs[], const SkColor colors[], SkXfermode*, const uint16_t indices[],
|
||||
const SkPoint texs[], const SkColor colors[], SkBlendMode, const uint16_t indices[],
|
||||
int indexCount, const SkPaint& paint) {
|
||||
// TODO: should we pass through blendmode
|
||||
if (mFilterHwuiCalls) {
|
||||
return;
|
||||
}
|
||||
@@ -374,7 +375,7 @@ void SkiaCanvasProxy::onDrawTextBlob(const SkTextBlob* blob, SkScalar x, SkScala
|
||||
}
|
||||
|
||||
void SkiaCanvasProxy::onDrawPatch(const SkPoint cubics[12], const SkColor colors[4],
|
||||
const SkPoint texCoords[4], SkXfermode* xmode, const SkPaint& paint) {
|
||||
const SkPoint texCoords[4], SkBlendMode bmode, const SkPaint& paint) {
|
||||
if (mFilterHwuiCalls) {
|
||||
return;
|
||||
}
|
||||
@@ -388,7 +389,7 @@ void SkiaCanvasProxy::onDrawPatch(const SkPoint cubics[12], const SkColor colors
|
||||
// If it fails to generate the vertices, then we do not draw.
|
||||
if (SkPatchUtils::getVertexData(&data, cubics, colors, texCoords, lod.width(), lod.height())) {
|
||||
this->drawVertices(SkCanvas::kTriangles_VertexMode, data.fVertexCount, data.fPoints,
|
||||
data.fTexCoords, data.fColors, xmode, data.fIndices, data.fIndexCount,
|
||||
data.fTexCoords, data.fColors, bmode, data.fIndices, data.fIndexCount,
|
||||
paint);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -67,7 +67,7 @@ protected:
|
||||
virtual void onDrawBitmapNine(const SkBitmap& bitmap, const SkIRect& center,
|
||||
const SkRect& dst, const SkPaint*) override;
|
||||
virtual void onDrawVertices(VertexMode, int vertexCount, const SkPoint vertices[],
|
||||
const SkPoint texs[], const SkColor colors[], SkXfermode*,
|
||||
const SkPoint texs[], const SkColor colors[], SkBlendMode,
|
||||
const uint16_t indices[], int indexCount,
|
||||
const SkPaint&) override;
|
||||
|
||||
@@ -87,7 +87,7 @@ protected:
|
||||
const SkPaint& paint) override;
|
||||
|
||||
virtual void onDrawPatch(const SkPoint cubics[12], const SkColor colors[4],
|
||||
const SkPoint texCoords[4], SkXfermode* xmode,
|
||||
const SkPoint texCoords[4], SkBlendMode,
|
||||
const SkPaint& paint) override;
|
||||
|
||||
virtual void onClipRect(const SkRect&, SkRegion::Op, ClipEdgeStyle) override;
|
||||
|
||||
@@ -309,10 +309,7 @@ bool tryStoreCompose(Caches& caches, const SkShader& shader, const Matrix4& mode
|
||||
storeCompose(caches, *rec.fShaderB, *rec.fShaderA,
|
||||
transform, textureUnit, description, outData);
|
||||
}
|
||||
if (!SkXfermode::AsMode(rec.fMode, &description->shadersMode)) {
|
||||
// TODO: Support other modes.
|
||||
description->shadersMode = SkXfermode::kSrcOver_Mode;
|
||||
}
|
||||
description->shadersMode = rec.fBlendMode;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -22,7 +22,6 @@
|
||||
|
||||
#include <GLES2/gl2.h>
|
||||
#include <SkShader.h>
|
||||
#include <SkXfermode.h>
|
||||
#include <cutils/compiler.h>
|
||||
|
||||
namespace android {
|
||||
|
||||
@@ -776,7 +776,7 @@ TEST(RecordingCanvas, refBitmapInShader_composeShader) {
|
||||
SkShader::TileMode::kRepeat_TileMode);
|
||||
|
||||
sk_sp<SkShader> composeShader = SkShader::MakeComposeShader(std::move(shader1), std::move(shader2),
|
||||
SkXfermode::kMultiply_Mode);
|
||||
SkBlendMode::kMultiply);
|
||||
paint.setShader(std::move(composeShader));
|
||||
canvas.drawRoundRect(0, 0, 100, 100, 20.0f, 20.0f, paint);
|
||||
});
|
||||
|
||||
@@ -69,10 +69,10 @@ TEST(SkiaBehavior, lightingColorFilter_simplify) {
|
||||
SkColorMatrixFilter::MakeLightingFilter(0x11223344, 0));
|
||||
|
||||
SkColor observedColor;
|
||||
SkXfermode::Mode observedMode;
|
||||
SkBlendMode observedMode;
|
||||
ASSERT_TRUE(filter->asColorMode(&observedColor, &observedMode));
|
||||
EXPECT_EQ(0xFF223344, observedColor);
|
||||
EXPECT_EQ(SkXfermode::Mode::kModulate_Mode, observedMode);
|
||||
EXPECT_EQ(SkBlendMode::kModulate, observedMode);
|
||||
}
|
||||
|
||||
{
|
||||
|
||||
@@ -21,7 +21,6 @@
|
||||
#include <SkColorFilter.h>
|
||||
#include <SkDrawLooper.h>
|
||||
#include <SkShader.h>
|
||||
#include <SkXfermode.h>
|
||||
|
||||
namespace android {
|
||||
namespace uirenderer {
|
||||
|
||||
@@ -31,7 +31,7 @@
|
||||
#include <SkCanvas.h>
|
||||
#include <SkColor.h>
|
||||
#include <SkPaint.h>
|
||||
#include <SkXfermode.h>
|
||||
#include <SkBlendMode.h>
|
||||
#pragma GCC diagnostic pop
|
||||
|
||||
namespace android {
|
||||
|
||||
@@ -30,7 +30,6 @@
|
||||
#include <SkCanvas.h>
|
||||
#include <SkColor.h>
|
||||
#include <SkPaint.h>
|
||||
#include <SkXfermode.h>
|
||||
#pragma GCC diagnostic pop
|
||||
|
||||
#include <android/native_window.h>
|
||||
|
||||
Reference in New Issue
Block a user