bool FEColorMatrix::platformApplyOpenCL() { FilterContextOpenCL* context = FilterContextOpenCL::context(); if (!context) return false; if (!context->compileFEColorMatrix()) return true; FilterEffect* in = inputEffect(0); OpenCLHandle source = in->openCLImage(); OpenCLHandle destination = createOpenCLImageResult(); IntPoint relativeSourceLocation( absolutePaintRect().x() - in->absolutePaintRect().location().x(), absolutePaintRect().y() - in->absolutePaintRect().location().y()); float components[9]; if (FECOLORMATRIX_TYPE_SATURATE == m_type) calculateSaturateComponents(components, m_values[0]); else if (FECOLORMATRIX_TYPE_HUEROTATE == m_type) calculateHueRotateComponents(components, m_values[0]); context->applyFEColorMatrix(destination, absolutePaintRect().size(), source, relativeSourceLocation, (FECOLORMATRIX_TYPE_MATRIX == m_type) ? m_values.data() : components, m_type); return true; }
bool SourceAlpha::platformApplyOpenCL() { FilterContextOpenCL* context = FilterContextOpenCL::context(); if (!context) return false; platformApplySoftware(); ImageBuffer* sourceImage = asImageBuffer(); if (!sourceImage) return false; RefPtr<Uint8ClampedArray> sourceImageData = sourceImage->getUnmultipliedImageData(IntRect(IntPoint(), sourceImage->internalSize())); createOpenCLImageResult(sourceImageData->data()); return true; }
// This function will be changed to abstract virtual when all filters are landed. bool FilterEffect::platformApplyOpenCL() { if (!FilterContextOpenCL::context()) return false; unsigned size = m_inputEffects.size(); for (unsigned i = 0; i < size; ++i) { FilterEffect* in = m_inputEffects.at(i).get(); // Software code path expects that at least one of the following fileds is valid. if (!in->m_imageBufferResult && !in->m_unmultipliedImageResult && !in->m_premultipliedImageResult) in->asImageBuffer(); } platformApplySoftware(); ImageBuffer* sourceImage = asImageBuffer(); if (sourceImage) { RefPtr<Uint8ClampedArray> sourceImageData = sourceImage->getUnmultipliedImageData(IntRect(IntPoint(), sourceImage->internalSize())); createOpenCLImageResult(sourceImageData->data()); } return true; }