Remove GrContext::getRecommendedSampleCount and SkPictureContentInfo::suitableForGpuRasterization
Change-Id: I8c5521f87c5eae185e68622aa104cb8911efa8c8 Reviewed-on: https://skia-review.googlesource.com/100183 Reviewed-by: Robert Phillips <robertphillips@google.com> Reviewed-by: Brian Salomon <bsalomon@google.com> Commit-Queue: Brian Salomon <bsalomon@google.com>
This commit is contained in:
parent
1bd556a177
commit
33bf56d6b4
@ -216,19 +216,6 @@ public:
|
||||
/** Access the context capabilities */
|
||||
const GrCaps* caps() const { return fCaps.get(); }
|
||||
|
||||
/**
|
||||
* Returns the recommended sample count for a render target when using this
|
||||
* context.
|
||||
*
|
||||
* @param config the configuration of the render target.
|
||||
* @param dpi the display density in dots per inch.
|
||||
*
|
||||
* @return sample count that should be perform well and have good enough
|
||||
* rendering quality for the display. Alternatively returns 0 if
|
||||
* MSAA is not supported or recommended to be used by default.
|
||||
*/
|
||||
int getRecommendedSampleCount(GrPixelConfig config, SkScalar dpi) const;
|
||||
|
||||
/*
|
||||
* Create a new render target context backed by a deferred-style
|
||||
* GrRenderTargetProxy. We guarantee that "asTextureProxy" will succeed for
|
||||
|
@ -9,41 +9,6 @@
|
||||
#include "SkPathEffect.h"
|
||||
#include "SkPictureContentInfo.h"
|
||||
|
||||
bool SkPictureContentInfo::suitableForGpuRasterization(GrContext* context, const char **reason,
|
||||
int sampleCount) const {
|
||||
// TODO: the heuristic used here needs to be refined
|
||||
static const int kNumPaintWithPathEffectUsesTol = 1;
|
||||
static const int kNumAAConcavePaths = 5;
|
||||
|
||||
SkASSERT(fNumAAHairlineConcavePaths <= fNumAAConcavePaths);
|
||||
|
||||
int numNonDashedPathEffects = fNumPaintWithPathEffectUses -
|
||||
fNumFastPathDashEffects;
|
||||
|
||||
bool suitableForDash = (0 == fNumPaintWithPathEffectUses) ||
|
||||
(numNonDashedPathEffects < kNumPaintWithPathEffectUsesTol
|
||||
&& 0 == sampleCount);
|
||||
|
||||
bool ret = suitableForDash &&
|
||||
(fNumAAConcavePaths - fNumAAHairlineConcavePaths - fNumAADFEligibleConcavePaths)
|
||||
< kNumAAConcavePaths;
|
||||
if (!ret && reason) {
|
||||
if (!suitableForDash) {
|
||||
if (0 != sampleCount) {
|
||||
*reason = "Can't use multisample on dash effect.";
|
||||
} else {
|
||||
*reason = "Too many non dashed path effects.";
|
||||
}
|
||||
} else if ((fNumAAConcavePaths - fNumAAHairlineConcavePaths - fNumAADFEligibleConcavePaths)
|
||||
>= kNumAAConcavePaths) {
|
||||
*reason = "Too many anti-aliased concave paths.";
|
||||
} else {
|
||||
*reason = "Unknown reason for GPU unsuitability.";
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
void SkPictureContentInfo::onDrawPoints(size_t count, const SkPaint& paint) {
|
||||
if (paint.getPathEffect() != nullptr) {
|
||||
SkPathEffect::DashInfo info;
|
||||
|
@ -25,9 +25,6 @@ public:
|
||||
int numInteriorLayers() const { return fNumInteriorLayers; }
|
||||
int numLeafLayers() const { return fNumLeafLayers; }
|
||||
|
||||
bool suitableForGpuRasterization(GrContext* context, const char **reason,
|
||||
int sampleCount) const;
|
||||
|
||||
void addOperation() { ++fNumOperations; }
|
||||
|
||||
void onDrawPoints(size_t count, const SkPaint& paint);
|
||||
|
@ -626,29 +626,3 @@ bool SkPictureData::parseBuffer(SkReadBuffer& buffer) {
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#if SK_SUPPORT_GPU
|
||||
bool SkPictureData::suitableForGpuRasterization(GrContext* context, const char **reason,
|
||||
int sampleCount) const {
|
||||
return fContentInfo.suitableForGpuRasterization(context, reason, sampleCount);
|
||||
}
|
||||
|
||||
bool SkPictureData::suitableForGpuRasterization(GrContext* context, const char **reason,
|
||||
GrPixelConfig config, SkScalar dpi) const {
|
||||
|
||||
if (context != nullptr) {
|
||||
return this->suitableForGpuRasterization(context, reason,
|
||||
context->getRecommendedSampleCount(config, dpi));
|
||||
} else {
|
||||
return this->suitableForGpuRasterization(nullptr, reason);
|
||||
}
|
||||
}
|
||||
|
||||
bool SkPictureData::suitableForLayerOptimization() const {
|
||||
return fContentInfo.numLayers() > 0;
|
||||
}
|
||||
#endif
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -138,24 +138,6 @@ public:
|
||||
return reader->validateIndex(index, fVerticesCount) ? fVerticesRefs[index] : nullptr;
|
||||
}
|
||||
|
||||
#if SK_SUPPORT_GPU
|
||||
/**
|
||||
* sampleCount is the number of samples-per-pixel or zero if non-MSAA.
|
||||
* It is defaulted to be zero.
|
||||
*/
|
||||
bool suitableForGpuRasterization(GrContext* context, const char **reason,
|
||||
int sampleCount = 0) const;
|
||||
|
||||
/**
|
||||
* Calls getRecommendedSampleCount with GrPixelConfig and dpi to calculate sampleCount
|
||||
* and then calls the above version of suitableForGpuRasterization
|
||||
*/
|
||||
bool suitableForGpuRasterization(GrContext* context, const char **reason,
|
||||
GrPixelConfig config, SkScalar dpi) const;
|
||||
|
||||
bool suitableForLayerOptimization() const;
|
||||
#endif
|
||||
|
||||
private:
|
||||
void init();
|
||||
|
||||
|
@ -798,24 +798,6 @@ void GrContextPriv::flushSurfaceIO(GrSurfaceProxy* proxy) {
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
int GrContext::getRecommendedSampleCount(GrPixelConfig config,
|
||||
SkScalar dpi) const {
|
||||
ASSERT_SINGLE_OWNER
|
||||
|
||||
if (!this->caps()->isConfigRenderable(config, true)) {
|
||||
return 0;
|
||||
}
|
||||
int chosenSampleCount = 0;
|
||||
if (fGpu->caps()->shaderCaps()->pathRenderingSupport()) {
|
||||
if (dpi >= 250.0f) {
|
||||
chosenSampleCount = 4;
|
||||
} else {
|
||||
chosenSampleCount = 16;
|
||||
}
|
||||
}
|
||||
int supportedSampleCount = fGpu->caps()->getSampleCount(chosenSampleCount, config);
|
||||
return chosenSampleCount <= supportedSampleCount ? supportedSampleCount : 0;
|
||||
}
|
||||
|
||||
sk_sp<GrSurfaceContext> GrContextPriv::makeWrappedSurfaceContext(sk_sp<GrSurfaceProxy> proxy,
|
||||
sk_sp<SkColorSpace> colorSpace) {
|
||||
|
@ -1,169 +0,0 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
# Copyright 2014 Google Inc.
|
||||
#
|
||||
# Use of this source code is governed by a BSD-style license that can be
|
||||
# found in the LICENSE file.
|
||||
|
||||
"""Script to test out suitableForGpuRasterization (via gpuveto)"""
|
||||
|
||||
import argparse
|
||||
import glob
|
||||
import os
|
||||
import re
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
# Set the PYTHONPATH to include the tools directory.
|
||||
sys.path.append(
|
||||
os.path.join(os.path.dirname(os.path.realpath(__file__)), os.pardir))
|
||||
import find_run_binary
|
||||
|
||||
def list_files(dir_or_file):
|
||||
"""Returns a list of all the files from the provided argument
|
||||
|
||||
@param dir_or_file: either a directory or skp file
|
||||
|
||||
@returns a list containing the files in the directory or a single file
|
||||
"""
|
||||
files = []
|
||||
for globbedpath in glob.iglob(dir_or_file): # useful on win32
|
||||
if os.path.isdir(globbedpath):
|
||||
for filename in os.listdir(globbedpath):
|
||||
newpath = os.path.join(globbedpath, filename)
|
||||
if os.path.isfile(newpath):
|
||||
files.append(newpath)
|
||||
elif os.path.isfile(globbedpath):
|
||||
files.append(globbedpath)
|
||||
return files
|
||||
|
||||
|
||||
def execute_program(args):
|
||||
"""Executes a process and waits for it to complete.
|
||||
|
||||
@param args: is passed into subprocess.Popen().
|
||||
|
||||
@returns a tuple of the process output (returncode, output)
|
||||
"""
|
||||
proc = subprocess.Popen(args, stdout=subprocess.PIPE,
|
||||
stderr=subprocess.STDOUT)
|
||||
output, _ = proc.communicate()
|
||||
errcode = proc.returncode
|
||||
return (errcode, output)
|
||||
|
||||
|
||||
class GpuVeto(object):
|
||||
|
||||
def __init__(self):
|
||||
self.bench_pictures = find_run_binary.find_path_to_program(
|
||||
'bench_pictures')
|
||||
sys.stdout.write('Running: %s\n' % (self.bench_pictures))
|
||||
self.gpuveto = find_run_binary.find_path_to_program('gpuveto')
|
||||
assert os.path.isfile(self.bench_pictures)
|
||||
assert os.path.isfile(self.gpuveto)
|
||||
self.indeterminate = 0
|
||||
self.truePositives = 0
|
||||
self.falsePositives = 0
|
||||
self.trueNegatives = 0
|
||||
self.falseNegatives = 0
|
||||
|
||||
def process_skps(self, dir_or_file):
|
||||
for skp in enumerate(dir_or_file):
|
||||
self.process_skp(skp[1])
|
||||
|
||||
sys.stdout.write('TP %d FP %d TN %d FN %d IND %d\n' % (
|
||||
self.truePositives,
|
||||
self.falsePositives,
|
||||
self.trueNegatives,
|
||||
self.falseNegatives,
|
||||
self.indeterminate))
|
||||
|
||||
|
||||
def process_skp(self, skp_file):
|
||||
assert os.path.isfile(skp_file)
|
||||
#print skp_file
|
||||
|
||||
# run gpuveto on the skp
|
||||
args = [self.gpuveto, '-r', skp_file]
|
||||
returncode, output = execute_program(args)
|
||||
if (returncode != 0):
|
||||
return
|
||||
|
||||
if ('unsuitable' in output):
|
||||
suitable = False
|
||||
else:
|
||||
assert 'suitable' in output
|
||||
suitable = True
|
||||
|
||||
# run raster config
|
||||
args = [self.bench_pictures, '-r', skp_file,
|
||||
'--repeat', '20',
|
||||
'--timers', 'w',
|
||||
'--config', '8888']
|
||||
returncode, output = execute_program(args)
|
||||
if (returncode != 0):
|
||||
return
|
||||
|
||||
matches = re.findall('[\d]+\.[\d]+', output)
|
||||
if len(matches) != 1:
|
||||
return
|
||||
|
||||
rasterTime = float(matches[0])
|
||||
|
||||
# run gpu config
|
||||
args2 = [self.bench_pictures, '-r', skp_file,
|
||||
'--repeat', '20',
|
||||
'--timers', 'w',
|
||||
'--config', 'gpu']
|
||||
returncode, output = execute_program(args2)
|
||||
if (returncode != 0):
|
||||
return
|
||||
|
||||
matches = re.findall('[\d]+\.[\d]+', output)
|
||||
if len(matches) != 1:
|
||||
return
|
||||
|
||||
gpuTime = float(matches[0])
|
||||
|
||||
# happens if page is too big it will not render
|
||||
if 0 == gpuTime:
|
||||
return
|
||||
|
||||
tolerance = 0.05
|
||||
tol_range = tolerance * gpuTime
|
||||
|
||||
|
||||
if gpuTime - tol_range < rasterTime < gpuTime + tol_range:
|
||||
result = "NONE"
|
||||
self.indeterminate += 1
|
||||
elif suitable:
|
||||
if gpuTime < rasterTime:
|
||||
self.truePositives += 1
|
||||
result = "TP"
|
||||
else:
|
||||
self.falsePositives += 1
|
||||
result = "FP"
|
||||
else:
|
||||
if gpuTime < rasterTime:
|
||||
self.falseNegatives += 1
|
||||
result = "FN"
|
||||
else:
|
||||
self.trueNegatives += 1
|
||||
result = "TN"
|
||||
|
||||
|
||||
sys.stdout.write('%s: gpuveto: %d raster %.2f gpu: %.2f Result: %s\n'
|
||||
% (skp_file, suitable, rasterTime, gpuTime, result))
|
||||
|
||||
def main(main_argv):
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument('--skp_path',
|
||||
help='Path to the SKP(s). Can either be a directory ' \
|
||||
'containing SKPs or a single SKP.',
|
||||
required=True)
|
||||
|
||||
args = parser.parse_args()
|
||||
GpuVeto().process_skps(list_files(args.skp_path))
|
||||
|
||||
if __name__ == '__main__':
|
||||
sys.exit(main(sys.argv[1]))
|
Loading…
Reference in New Issue
Block a user