aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar kkinnunen <kkinnunen@nvidia.com>2016-01-18 01:18:34 -0800
committerGravatar Commit bot <commit-bot@chromium.org>2016-01-18 01:18:35 -0800
commit973d92cf91b21013361209e8a5c0c4685728847f (patch)
treecfd62c01fc0a605bd2925c807c5fc00bb5ebf571
parent3ca73360493ba71831c86c8c5f9c36187c0355ca (diff)
SampleApp: Remove SkWindow::setColorType
Remove SkWindow::setColorType, it is used wrong and inconsistently. The color type is actually property of window backbuffer, used when the window is painted with software. This is as opposed to a generic window property that would affect all operation. Similar to MSAA sample count for window GPU backbuffer, the bitmap backbuffer color type should be a parameter of "attach" or "create window" functions, should this property ever be added back. The apps use the call wrong, setting the type as kRGBA_8888 or kBGRRA_8888 without no apparent rationale. These color types are incorrect, as the raster surface can not work with these. Reorganize the SkWindow::resize, since no change in SkWindow backbuffer size does not neccessarily mean that SkView would not need the call. Do not show the sw backbuffer color type in SampleApp title, as it does not really provide any information. On small screens, kBGRA_8888_ColorType fills up the whole title. BUG=skia:4733 GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1595503002 Review URL: https://codereview.chromium.org/1595503002
-rw-r--r--example/HelloWorld.cpp1
-rw-r--r--experimental/SkV8Example/SkV8Example.cpp1
-rw-r--r--experimental/iOSSampleApp/Shared/SkUIView.mm9
-rw-r--r--experimental/iOSSampleApp/SkSampleUIView.mm3
-rw-r--r--include/views/SkWindow.h4
-rw-r--r--samplecode/SampleApp.cpp3
-rw-r--r--src/views/SkWindow.cpp20
-rw-r--r--src/views/mac/SkNSView.mm3
-rw-r--r--tools/VisualBench/VisualBench.cpp1
9 files changed, 15 insertions, 30 deletions
diff --git a/example/HelloWorld.cpp b/example/HelloWorld.cpp
index c7c6bcd1dc..6833a33828 100644
--- a/example/HelloWorld.cpp
+++ b/example/HelloWorld.cpp
@@ -59,7 +59,6 @@ void HelloWorldWindow::setTitle() {
}
bool HelloWorldWindow::setUpBackend() {
- this->setColorType(kRGBA_8888_SkColorType);
this->setVisibleP(true);
this->setClipToBounds(false);
diff --git a/experimental/SkV8Example/SkV8Example.cpp b/experimental/SkV8Example/SkV8Example.cpp
index 03a8826c88..fe205d740d 100644
--- a/experimental/SkV8Example/SkV8Example.cpp
+++ b/experimental/SkV8Example/SkV8Example.cpp
@@ -52,7 +52,6 @@ SkV8ExampleWindow::SkV8ExampleWindow(void* hwnd, JsContext* context)
, fCurSurface(NULL)
#endif
{
- this->setColorType(kBGRA_8888_SkColorType);
this->setVisibleP(true);
this->setClipToBounds(false);
diff --git a/experimental/iOSSampleApp/Shared/SkUIView.mm b/experimental/iOSSampleApp/Shared/SkUIView.mm
index e2dce54a69..df55619e4c 100644
--- a/experimental/iOSSampleApp/Shared/SkUIView.mm
+++ b/experimental/iOSSampleApp/Shared/SkUIView.mm
@@ -1,3 +1,9 @@
+/*
+ * Copyright 2011 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
#import "SkUIView.h"
#include "SkCanvas.h"
#include "SkCGUtils.h"
@@ -29,8 +35,7 @@
- (void)setUpWindow {
if (NULL != fWind) {
fWind->setVisibleP(true);
- fWind->resize(self.frame.size.width, self.frame.size.height,
- kN32_SkColorType);
+ fWind->resize(self.frame.size.width, self.frame.size.height);
}
}
diff --git a/experimental/iOSSampleApp/SkSampleUIView.mm b/experimental/iOSSampleApp/SkSampleUIView.mm
index f2a8977d92..0c5209fa26 100644
--- a/experimental/iOSSampleApp/SkSampleUIView.mm
+++ b/experimental/iOSSampleApp/SkSampleUIView.mm
@@ -326,8 +326,7 @@ static FPSState gFPS;
fDevManager = new SkiOSDeviceManager(fGL.fFramebuffer);
fWind = new SampleWindow(self, argc, argv, fDevManager);
- fWind->resize(self.frame.size.width, self.frame.size.height,
- kN32_SkColorType);
+ fWind->resize(self.frame.size.width, self.frame.size.height);
for (int i = 0; i < argc; ++i) {
delete [] argv[i];
diff --git a/include/views/SkWindow.h b/include/views/SkWindow.h
index 0d47875bf7..6db85a421c 100644
--- a/include/views/SkWindow.h
+++ b/include/views/SkWindow.h
@@ -43,8 +43,7 @@ public:
const SkBitmap& getBitmap() const { return fBitmap; }
- void setColorType(SkColorType);
- void resize(int width, int height, SkColorType = kUnknown_SkColorType);
+ void resize(int width, int height);
bool isDirty() const { return !fDirtyRgn.isEmpty(); }
bool update(SkIRect* updateArea);
@@ -96,7 +95,6 @@ protected:
private:
SkSurfaceProps fSurfaceProps;
- SkColorType fColorType;
SkBitmap fBitmap;
SkRegion fDirtyRgn;
diff --git a/samplecode/SampleApp.cpp b/samplecode/SampleApp.cpp
index a3a81d8516..65e3c17a44 100644
--- a/samplecode/SampleApp.cpp
+++ b/samplecode/SampleApp.cpp
@@ -1982,9 +1982,6 @@ void SampleWindow::updateTitle() {
title.prepend(gDeviceTypePrefix[fDeviceType]);
- title.prepend(" ");
- title.prepend(sk_tool_utils::colortype_name(this->getBitmap().colorType()));
-
if (fTilingMode != kNo_Tiling) {
title.prependf("<T: %s> ", gTilingInfo[fTilingMode].label);
}
diff --git a/src/views/SkWindow.cpp b/src/views/SkWindow.cpp
index d93bc96a66..0e6da0b02d 100644
--- a/src/views/SkWindow.cpp
+++ b/src/views/SkWindow.cpp
@@ -20,7 +20,6 @@ SkWindow::SkWindow()
{
fClicks.reset();
fWaitingOnInval = false;
- fColorType = kN32_SkColorType;
fMatrix.reset();
}
@@ -53,22 +52,13 @@ void SkWindow::postConcat(const SkMatrix& matrix) {
this->setMatrix(m);
}
-void SkWindow::setColorType(SkColorType ct) {
- this->resize(fBitmap.width(), fBitmap.height(), ct);
-}
-
-void SkWindow::resize(int width, int height, SkColorType ct) {
- if (ct == kUnknown_SkColorType)
- ct = fColorType;
-
- if (width != fBitmap.width() || height != fBitmap.height() || ct != fColorType) {
- fColorType = ct;
- fBitmap.allocPixels(SkImageInfo::Make(width, height,
- ct, kPremul_SkAlphaType));
-
- this->setSize(SkIntToScalar(width), SkIntToScalar(height));
+void SkWindow::resize(int width, int height) {
+ if (width != fBitmap.width() || height != fBitmap.height()) {
+ fBitmap.allocPixels(SkImageInfo::Make(width, height, kN32_SkColorType,
+ kPremul_SkAlphaType));
this->inval(nullptr);
}
+ this->setSize(SkIntToScalar(width), SkIntToScalar(height));
}
bool SkWindow::handleInval(const SkRect* localR) {
diff --git a/src/views/mac/SkNSView.mm b/src/views/mac/SkNSView.mm
index a8376e62c9..ada79f8e14 100644
--- a/src/views/mac/SkNSView.mm
+++ b/src/views/mac/SkNSView.mm
@@ -56,8 +56,7 @@ static_assert(SK_SUPPORT_GPU, "not_implemented_for_non_gpu_build");
#if RETINA_API_AVAILABLE
size = [self convertSizeToBacking:self.frame.size];
#endif
- fWind->resize((int) size.width, (int) size.height,
- kN32_SkColorType);
+ fWind->resize((int) size.width, (int) size.height);
[[self window] setAcceptsMouseMovedEvents:YES];
}
}
diff --git a/tools/VisualBench/VisualBench.cpp b/tools/VisualBench/VisualBench.cpp
index 476ac1654b..6d0268a708 100644
--- a/tools/VisualBench/VisualBench.cpp
+++ b/tools/VisualBench/VisualBench.cpp
@@ -86,7 +86,6 @@ SkSurface* VisualBench::createSurface() {
}
bool VisualBench::setupBackend() {
- this->setColorType(kRGBA_8888_SkColorType);
this->setVisibleP(true);
this->setClipToBounds(false);