{"action":"created","comment":{"url":"https://api.github.com/repos/MonoGame/MonoGame/pulls/comments/88366529","pull_request_review_id":8942679,"id":88366529,"diff_hunk":"@@ -465,5 +465,109 @@ public void SetData5ParameterExceptionTest(int arraySize, int startIndex, int el\n                 t.Dispose();\n             }\n         }\n+\n+        [Test]\n+        public void GetAndSetDataDxtCompressed()\n+        {\n+            var t = content.Load<Texture2D>(Paths.Texture (\"random_16px_dxt\"));\n+\n+            var b = new byte[t.Width*t.Height/2];\n+            var b2 = new byte[t.Width*t.Height/2];\n+\n+            t.GetData(b);\n+            t.SetData(b);\n+            t.GetData(b2);\n+\n+            Assert.AreEqual(b, b2);\n+\n+            t.Dispose();\n+        }\n+\n+        [TestCase(0)]\n+        [TestCase(1)]\n+        public void GetAndSetDataDxtNotMultipleOf4Rounding(int mip)\n+        {\n+            var t = content.Load<Texture2D>(Paths.Texture (\"random_16px_dxt\"));\n+\n+            var before = new byte[t.Width*t.Height/2];\n+            t.GetData(before);\n+\n+            var b1 = new byte[8];\n+            var b2 = new byte[8];\n+\n+            t.GetData(mip, new Rectangle(0,0,4,4), b1, 0, 8);\n+\n+            t.GetData(mip, new Rectangle(0,0,1,1), b2, 0, 8);\n+            t.SetData(mip, new Rectangle(0,0,1,1), b2, 0, 8);\n+            Assert.AreEqual(b1, b2);\n+\n+            t.GetData(mip, new Rectangle(0,0,1,3), b2, 0, 8);\n+            t.SetData(mip, new Rectangle(0,0,1,3), b2, 0, 8);\n+            Assert.AreEqual(b1, b2);\n+\n+            t.GetData(mip, new Rectangle(0,0,4,3), b2, 0, 8);\n+            t.SetData(mip, new Rectangle(0,0,4,3), b2, 0, 8);\n+            Assert.AreEqual(b1, b2);\n+\n+            t.GetData(mip, new Rectangle(0, 2, 4, 4), b2, 0, 8);\n+            t.SetData(mip, new Rectangle(0, 2, 4, 4), b2, 0, 8);\n+            Assert.AreEqual(b1, b2);\n+\n+            t.GetData(mip, new Rectangle(2, 2, 4, 4), b2, 0, 8);\n+            t.SetData(mip, new Rectangle(2, 2, 4, 4), b2, 0, 8);\n+            Assert.AreEqual(b1, b2);\n+\n+            t.GetData(mip, new Rectangle(3, 3, 4, 4), b2, 0, 8);\n+            t.SetData(mip, new Rectangle(3, 3, 4, 4), b2, 0, 8);\n+            Assert.AreEqual(b1, b2);\n+\n+            t.GetData(mip, new Rectangle(4, 4, 4, 4), b2, 0, 8);\n+            t.SetData(mip, new Rectangle(4, 4, 4, 4), b2, 0, 8);\n+            Assert.AreNotEqual(b1, b2);\n+\n+            var after = new byte[t.Width*t.Height/2];\n+            t.GetData(after);\n+\n+            Assert.AreEqual(before, after);\n+\n+            t.Dispose();\n+        }\n+\n+        [Test]\n+        public void GetAndSetDataDxtDontRoundWhenOutsideBounds()\n+        {\n+            var t = content.Load<Texture2D>(Paths.Texture(\"random_16px_dxt\"));\n+\n+            var b = new byte[8];\n+\n+            // don't round if the unrounded rectangle would be outside the texture area\n+            Assert.Throws<ArgumentException>(() => t.GetData(0, new Rectangle(15, 15, 3, 3), b, 0, 8));\n+            // this does work\n+            t.GetData(0, new Rectangle(15, 15, 1, 1), b, 0, 8);\n+\n+            t.Dispose();\n+        }\n+\n+        [Test]\n+        public void GetAndSetDataDxtLowerMips()\n+        {\n+            var t = content.Load<Texture2D>(Paths.Texture(\"random_16px_dxt\"));\n+\n+            var b = new byte[8];\n+            var b2 = new byte[8];\n+\n+            t.GetData(0, new Rectangle(0,0,4,4), b, 0, 8);\n+            t.GetData(1, new Rectangle(0,0,4,4), b2, 0, 8);\n+            t.GetData(2, new Rectangle(0,0,4,4), b2, 0, 8);\n+            t.GetData(3, new Rectangle(0,0,2,2), b2, 0, 8);\n+            t.GetData(4, new Rectangle(0,0,1,1), b2, 0, 8);","path":"Test/Framework/Graphics/Texture2DNonVisualTest.cs","position":288,"original_position":99,"commit_id":"5bb5bcfe449c31c6596159fb0dd87c8070fd7607","original_commit_id":"5bb5bcfe449c31c6596159fb0dd87c8070fd7607","user":{"login":"KonajuGames","id":694943,"avatar_url":"https://avatars.githubusercontent.com/u/694943?v=3","gravatar_id":"","url":"https://api.github.com/users/KonajuGames","html_url":"https://github.com/KonajuGames","followers_url":"https://api.github.com/users/KonajuGames/followers","following_url":"https://api.github.com/users/KonajuGames/following{/other_user}","gists_url":"https://api.github.com/users/KonajuGames/gists{/gist_id}","starred_url":"https://api.github.com/users/KonajuGames/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/KonajuGames/subscriptions","organizations_url":"https://api.github.com/users/KonajuGames/orgs","repos_url":"https://api.github.com/users/KonajuGames/repos","events_url":"https://api.github.com/users/KonajuGames/events{/privacy}","received_events_url":"https://api.github.com/users/KonajuGames/received_events","type":"User","site_admin":false},"body":"Add a texture with a non-opaque alpha channel, process it in the content pipeline and it will produce a DXT5 texture.  DXT5 uses a 128bit block.","created_at":"2016-11-17T00:57:16Z","updated_at":"2016-11-17T00:57:16Z","html_url":"https://github.com/MonoGame/MonoGame/pull/5121#discussion_r88366529","pull_request_url":"https://api.github.com/repos/MonoGame/MonoGame/pulls/5121","_links":{"self":{"href":"https://api.github.com/repos/MonoGame/MonoGame/pulls/comments/88366529"},"html":{"href":"https://github.com/MonoGame/MonoGame/pull/5121#discussion_r88366529"},"pull_request":{"href":"https://api.github.com/repos/MonoGame/MonoGame/pulls/5121"}}},"pull_request":{"url":"https://api.github.com/repos/MonoGame/MonoGame/pulls/5121","id":81653964,"html_url":"https://github.com/MonoGame/MonoGame/pull/5121","diff_url":"https://github.com/MonoGame/MonoGame/pull/5121.diff","patch_url":"https://github.com/MonoGame/MonoGame/pull/5121.patch","issue_url":"https://api.github.com/repos/MonoGame/MonoGame/issues/5121","number":5121,"state":"open","locked":false,"title":"Improve Texture.GetData and SetData parameter validation","user":{"login":"Jjagg","id":14875382,"avatar_url":"https://avatars.githubusercontent.com/u/14875382?v=3","gravatar_id":"","url":"https://api.github.com/users/Jjagg","html_url":"https://github.com/Jjagg","followers_url":"https://api.github.com/users/Jjagg/followers","following_url":"https://api.github.com/users/Jjagg/following{/other_user}","gists_url":"https://api.github.com/users/Jjagg/gists{/gist_id}","starred_url":"https://api.github.com/users/Jjagg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Jjagg/subscriptions","organizations_url":"https://api.github.com/users/Jjagg/orgs","repos_url":"https://api.github.com/users/Jjagg/repos","events_url":"https://api.github.com/users/Jjagg/events{/privacy}","received_events_url":"https://api.github.com/users/Jjagg/received_events","type":"User","site_admin":false},"body":"This fixes the issues mentioned in #5119 and fixes #1455. Only Texture2D is thoroughly tested for now. I also implemented TextureCube.GetData overloads that were missing.\n\nSomething that not everyone might agree with is I changed back the validation of elementCount as it was in XNA. We changed this so that when elementCount >= data.Width \\* data.Height the functions worked, while in XNA they check elementCount == data.Width \\* data.Height. I changed this back because I think this is ambiguous. You could argue we're more flexible than XNA if we allow elementCount to be larger, but in fact elementCount itself is not used, so allowing arbitrary values might confuse the user. \n\nThe fact that elementCount is even in there is a bit weird in the API... It's really only used for validation. Maybe when we start moving away from XNA we can break this by removing it and make it optional for a while (default value of 0 and remove the check) to ease the transition. Or just overload and obsolete the old calls. IMO it makes a lot more sense to have `GetData<T>(T[] data)`, `GetData<T>(Rectangle rect, T[] data)`, `GetData<T>(Rectangle rect, T[] data, int startIndex)` and overloads as needed for mip level, arraySlice etc.\n\nJust a quick snippet that points out why I think elementCount is misplaced (named params for your convenience):\n\n```\nvar tex = new Texture2D(graphicsDevice: gd, width: 20, height: 1);\nvar buffer = new Color[10];\ntex.GetData(data: buffer, startIndex: 0, elementCount: 10);\n```\n\nThis fails in XNA (and MG) with \n\n```\nSystem.ArgumentException : The size of the data passed in is too large or too small for this resource.\n```\n\nFixes #5172 \n","created_at":"2016-08-17T14:33:27Z","updated_at":"2016-11-17T00:57:16Z","closed_at":null,"merged_at":null,"merge_commit_sha":"ab8019659858ab235069468ead3d9416da219732","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/MonoGame/MonoGame/pulls/5121/commits","review_comments_url":"https://api.github.com/repos/MonoGame/MonoGame/pulls/5121/comments","review_comment_url":"https://api.github.com/repos/MonoGame/MonoGame/pulls/comments{/number}","comments_url":"https://api.github.com/repos/MonoGame/MonoGame/issues/5121/comments","statuses_url":"https://api.github.com/repos/MonoGame/MonoGame/statuses/5bb5bcfe449c31c6596159fb0dd87c8070fd7607","head":{"label":"Jjagg:texCube","ref":"texCube","sha":"5bb5bcfe449c31c6596159fb0dd87c8070fd7607","user":{"login":"Jjagg","id":14875382,"avatar_url":"https://avatars.githubusercontent.com/u/14875382?v=3","gravatar_id":"","url":"https://api.github.com/users/Jjagg","html_url":"https://github.com/Jjagg","followers_url":"https://api.github.com/users/Jjagg/followers","following_url":"https://api.github.com/users/Jjagg/following{/other_user}","gists_url":"https://api.github.com/users/Jjagg/gists{/gist_id}","starred_url":"https://api.github.com/users/Jjagg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Jjagg/subscriptions","organizations_url":"https://api.github.com/users/Jjagg/orgs","repos_url":"https://api.github.com/users/Jjagg/repos","events_url":"https://api.github.com/users/Jjagg/events{/privacy}","received_events_url":"https://api.github.com/users/Jjagg/received_events","type":"User","site_admin":false},"repo":{"id":56497141,"name":"MonoGame","full_name":"Jjagg/MonoGame","owner":{"login":"Jjagg","id":14875382,"avatar_url":"https://avatars.githubusercontent.com/u/14875382?v=3","gravatar_id":"","url":"https://api.github.com/users/Jjagg","html_url":"https://github.com/Jjagg","followers_url":"https://api.github.com/users/Jjagg/followers","following_url":"https://api.github.com/users/Jjagg/following{/other_user}","gists_url":"https://api.github.com/users/Jjagg/gists{/gist_id}","starred_url":"https://api.github.com/users/Jjagg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Jjagg/subscriptions","organizations_url":"https://api.github.com/users/Jjagg/orgs","repos_url":"https://api.github.com/users/Jjagg/repos","events_url":"https://api.github.com/users/Jjagg/events{/privacy}","received_events_url":"https://api.github.com/users/Jjagg/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/Jjagg/MonoGame","description":"One framework for creating powerful cross-platform games.","fork":true,"url":"https://api.github.com/repos/Jjagg/MonoGame","forks_url":"https://api.github.com/repos/Jjagg/MonoGame/forks","keys_url":"https://api.github.com/repos/Jjagg/MonoGame/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Jjagg/MonoGame/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Jjagg/MonoGame/teams","hooks_url":"https://api.github.com/repos/Jjagg/MonoGame/hooks","issue_events_url":"https://api.github.com/repos/Jjagg/MonoGame/issues/events{/number}","events_url":"https://api.github.com/repos/Jjagg/MonoGame/events","assignees_url":"https://api.github.com/repos/Jjagg/MonoGame/assignees{/user}","branches_url":"https://api.github.com/repos/Jjagg/MonoGame/branches{/branch}","tags_url":"https://api.github.com/repos/Jjagg/MonoGame/tags","blobs_url":"https://api.github.com/repos/Jjagg/MonoGame/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Jjagg/MonoGame/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Jjagg/MonoGame/git/refs{/sha}","trees_url":"https://api.github.com/repos/Jjagg/MonoGame/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Jjagg/MonoGame/statuses/{sha}","languages_url":"https://api.github.com/repos/Jjagg/MonoGame/languages","stargazers_url":"https://api.github.com/repos/Jjagg/MonoGame/stargazers","contributors_url":"https://api.github.com/repos/Jjagg/MonoGame/contributors","subscribers_url":"https://api.github.com/repos/Jjagg/MonoGame/subscribers","subscription_url":"https://api.github.com/repos/Jjagg/MonoGame/subscription","commits_url":"https://api.github.com/repos/Jjagg/MonoGame/commits{/sha}","git_commits_url":"https://api.github.com/repos/Jjagg/MonoGame/git/commits{/sha}","comments_url":"https://api.github.com/repos/Jjagg/MonoGame/comments{/number}","issue_comment_url":"https://api.github.com/repos/Jjagg/MonoGame/issues/comments{/number}","contents_url":"https://api.github.com/repos/Jjagg/MonoGame/contents/{+path}","compare_url":"https://api.github.com/repos/Jjagg/MonoGame/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Jjagg/MonoGame/merges","archive_url":"https://api.github.com/repos/Jjagg/MonoGame/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Jjagg/MonoGame/downloads","issues_url":"https://api.github.com/repos/Jjagg/MonoGame/issues{/number}","pulls_url":"https://api.github.com/repos/Jjagg/MonoGame/pulls{/number}","milestones_url":"https://api.github.com/repos/Jjagg/MonoGame/milestones{/number}","notifications_url":"https://api.github.com/repos/Jjagg/MonoGame/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Jjagg/MonoGame/labels{/name}","releases_url":"https://api.github.com/repos/Jjagg/MonoGame/releases{/id}","deployments_url":"https://api.github.com/repos/Jjagg/MonoGame/deployments","created_at":"2016-04-18T10:02:12Z","updated_at":"2016-04-18T10:02:17Z","pushed_at":"2016-11-16T16:23:38Z","git_url":"git://github.com/Jjagg/MonoGame.git","ssh_url":"git@github.com:Jjagg/MonoGame.git","clone_url":"https://github.com/Jjagg/MonoGame.git","svn_url":"https://github.com/Jjagg/MonoGame","homepage":"http://www.monogame.net","size":70582,"stargazers_count":0,"watchers_count":0,"language":"C#","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"develop"}},"base":{"label":"MonoGame:develop","ref":"develop","sha":"dc05c19b1493616330cfad9381407c482b50d7ea","user":{"login":"MonoGame","id":4772066,"avatar_url":"https://avatars.githubusercontent.com/u/4772066?v=3","gravatar_id":"","url":"https://api.github.com/users/MonoGame","html_url":"https://github.com/MonoGame","followers_url":"https://api.github.com/users/MonoGame/followers","following_url":"https://api.github.com/users/MonoGame/following{/other_user}","gists_url":"https://api.github.com/users/MonoGame/gists{/gist_id}","starred_url":"https://api.github.com/users/MonoGame/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MonoGame/subscriptions","organizations_url":"https://api.github.com/users/MonoGame/orgs","repos_url":"https://api.github.com/users/MonoGame/repos","events_url":"https://api.github.com/users/MonoGame/events{/privacy}","received_events_url":"https://api.github.com/users/MonoGame/received_events","type":"Organization","site_admin":false},"repo":{"id":1579990,"name":"MonoGame","full_name":"MonoGame/MonoGame","owner":{"login":"MonoGame","id":4772066,"avatar_url":"https://avatars.githubusercontent.com/u/4772066?v=3","gravatar_id":"","url":"https://api.github.com/users/MonoGame","html_url":"https://github.com/MonoGame","followers_url":"https://api.github.com/users/MonoGame/followers","following_url":"https://api.github.com/users/MonoGame/following{/other_user}","gists_url":"https://api.github.com/users/MonoGame/gists{/gist_id}","starred_url":"https://api.github.com/users/MonoGame/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MonoGame/subscriptions","organizations_url":"https://api.github.com/users/MonoGame/orgs","repos_url":"https://api.github.com/users/MonoGame/repos","events_url":"https://api.github.com/users/MonoGame/events{/privacy}","received_events_url":"https://api.github.com/users/MonoGame/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/MonoGame/MonoGame","description":"One framework for creating powerful cross-platform games.","fork":false,"url":"https://api.github.com/repos/MonoGame/MonoGame","forks_url":"https://api.github.com/repos/MonoGame/MonoGame/forks","keys_url":"https://api.github.com/repos/MonoGame/MonoGame/keys{/key_id}","collaborators_url":"https://api.github.com/repos/MonoGame/MonoGame/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/MonoGame/MonoGame/teams","hooks_url":"https://api.github.com/repos/MonoGame/MonoGame/hooks","issue_events_url":"https://api.github.com/repos/MonoGame/MonoGame/issues/events{/number}","events_url":"https://api.github.com/repos/MonoGame/MonoGame/events","assignees_url":"https://api.github.com/repos/MonoGame/MonoGame/assignees{/user}","branches_url":"https://api.github.com/repos/MonoGame/MonoGame/branches{/branch}","tags_url":"https://api.github.com/repos/MonoGame/MonoGame/tags","blobs_url":"https://api.github.com/repos/MonoGame/MonoGame/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/MonoGame/MonoGame/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/MonoGame/MonoGame/git/refs{/sha}","trees_url":"https://api.github.com/repos/MonoGame/MonoGame/git/trees{/sha}","statuses_url":"https://api.github.com/repos/MonoGame/MonoGame/statuses/{sha}","languages_url":"https://api.github.com/repos/MonoGame/MonoGame/languages","stargazers_url":"https://api.github.com/repos/MonoGame/MonoGame/stargazers","contributors_url":"https://api.github.com/repos/MonoGame/MonoGame/contributors","subscribers_url":"https://api.github.com/repos/MonoGame/MonoGame/subscribers","subscription_url":"https://api.github.com/repos/MonoGame/MonoGame/subscription","commits_url":"https://api.github.com/repos/MonoGame/MonoGame/commits{/sha}","git_commits_url":"https://api.github.com/repos/MonoGame/MonoGame/git/commits{/sha}","comments_url":"https://api.github.com/repos/MonoGame/MonoGame/comments{/number}","issue_comment_url":"https://api.github.com/repos/MonoGame/MonoGame/issues/comments{/number}","contents_url":"https://api.github.com/repos/MonoGame/MonoGame/contents/{+path}","compare_url":"https://api.github.com/repos/MonoGame/MonoGame/compare/{base}...{head}","merges_url":"https://api.github.com/repos/MonoGame/MonoGame/merges","archive_url":"https://api.github.com/repos/MonoGame/MonoGame/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/MonoGame/MonoGame/downloads","issues_url":"https://api.github.com/repos/MonoGame/MonoGame/issues{/number}","pulls_url":"https://api.github.com/repos/MonoGame/MonoGame/pulls{/number}","milestones_url":"https://api.github.com/repos/MonoGame/MonoGame/milestones{/number}","notifications_url":"https://api.github.com/repos/MonoGame/MonoGame/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/MonoGame/MonoGame/labels{/name}","releases_url":"https://api.github.com/repos/MonoGame/MonoGame/releases{/id}","deployments_url":"https://api.github.com/repos/MonoGame/MonoGame/deployments","created_at":"2011-04-07T00:23:40Z","updated_at":"2016-11-16T22:57:26Z","pushed_at":"2016-11-16T16:23:40Z","git_url":"git://github.com/MonoGame/MonoGame.git","ssh_url":"git@github.com:MonoGame/MonoGame.git","clone_url":"https://github.com/MonoGame/MonoGame.git","svn_url":"https://github.com/MonoGame/MonoGame","homepage":"http://www.monogame.net","size":356220,"stargazers_count":3897,"watchers_count":3897,"language":"C#","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":1866,"mirror_url":null,"open_issues_count":846,"forks":1866,"open_issues":846,"watchers":3897,"default_branch":"develop"}},"_links":{"self":{"href":"https://api.github.com/repos/MonoGame/MonoGame/pulls/5121"},"html":{"href":"https://github.com/MonoGame/MonoGame/pull/5121"},"issue":{"href":"https://api.github.com/repos/MonoGame/MonoGame/issues/5121"},"comments":{"href":"https://api.github.com/repos/MonoGame/MonoGame/issues/5121/comments"},"review_comments":{"href":"https://api.github.com/repos/MonoGame/MonoGame/pulls/5121/comments"},"review_comment":{"href":"https://api.github.com/repos/MonoGame/MonoGame/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/MonoGame/MonoGame/pulls/5121/commits"},"statuses":{"href":"https://api.github.com/repos/MonoGame/MonoGame/statuses/5bb5bcfe449c31c6596159fb0dd87c8070fd7607"}}}}
{"actor":{"display_login":"KonajuGames"}}